common/octeontx2: enable build only on 64-bit Linux
[dpdk.git] / drivers / common / octeontx2 / otx2_dev.c
index d61c712..ce4f0e7 100644 (file)
@@ -11,6 +11,7 @@
 #include <rte_common.h>
 #include <rte_eal.h>
 #include <rte_memcpy.h>
+#include <rte_eal_paging.h>
 
 #include "otx2_dev.h"
 #include "otx2_mbox.h"
@@ -34,10 +35,11 @@ mbox_mem_map(off_t off, size_t size)
        if (mem_fd < 0)
                goto error;
 
-       va = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, mem_fd, off);
+       va = rte_mem_map(NULL, size, RTE_PROT_READ | RTE_PROT_WRITE,
+                       RTE_MAP_SHARED, mem_fd, off);
        close(mem_fd);
 
-       if (va == MAP_FAILED)
+       if (va == NULL)
                otx2_err("Failed to mmap sz=0x%zx, fd=%d, off=%jd",
                         size, mem_fd, (intmax_t)off);
 error:
@@ -48,7 +50,7 @@ static void
 mbox_mem_unmap(void *va, size_t size)
 {
        if (va)
-               munmap(va, size);
+               rte_mem_unmap(va, size);
 }
 
 static int
@@ -161,6 +163,35 @@ af_pf_wait_msg(struct otx2_dev *dev, uint16_t vf, int num_msg)
                rsp->rc = msg->rc;
                rsp->pcifunc = msg->pcifunc;
 
+               /* Whenever a PF comes up, AF sends the link status to it but
+                * when VF comes up no such event is sent to respective VF.
+                * Using MBOX_MSG_NIX_LF_START_RX response from AF for the
+                * purpose and send the link status of PF to VF.
+                */
+               if (msg->id == MBOX_MSG_NIX_LF_START_RX) {
+                       /* Send link status to VF */
+                       struct cgx_link_user_info linfo;
+                       struct mbox_msghdr *vf_msg;
+                       size_t sz;
+
+                       /* Get the link status */
+                       if (dev->ops && dev->ops->link_status_get)
+                               dev->ops->link_status_get(dev, &linfo);
+
+                       sz = RTE_ALIGN(otx2_mbox_id2size(
+                               MBOX_MSG_CGX_LINK_EVENT), MBOX_MSG_ALIGN);
+                       /* Prepare the message to be sent */
+                       vf_msg = otx2_mbox_alloc_msg(&dev->mbox_vfpf_up, vf,
+                                                    sz);
+                       otx2_mbox_req_init(MBOX_MSG_CGX_LINK_EVENT, vf_msg);
+                       memcpy((uint8_t *)vf_msg + sizeof(struct mbox_msghdr),
+                              &linfo, sizeof(struct cgx_link_user_info));
+
+                       vf_msg->rc = msg->rc;
+                       vf_msg->pcifunc = msg->pcifunc;
+                       /* Send to VF */
+                       otx2_mbox_msg_send(&dev->mbox_vfpf_up, vf);
+               }
                offset = mbox->rx_start + msg->next_msgoff;
        }
        rte_spinlock_unlock(&mdev->mbox_lock);