@@ -55,8 +55,14 @@
#define WAITLINK_TMO 2
#define POLL_TMO 0
+static struct nm_desc mmap_desc; /** Used to store the mmap address;
+ filled in first time, used for
+ subsequent calls to nm_open */
+static odp_spinlock_t nm_global_lock;
+
int odp_netmap_init_global(void)
{
+ odp_spinlock_init(&nm_global_lock);
return 0;
}
@@ -142,13 +148,30 @@ int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const char *netdev,
strncpy(pkt_nm->ifname, netdev, sizeof(pkt_nm->ifname));
snprintf(ifname, sizeof(ifname), "netmap:%s", netdev);
- pkt_nm->desc = nm_open(ifname, NULL, 0, 0);
+
+ odp_spinlock_lock(&nm_global_lock);
+ ODP_DBG("[%04d] Initial mmap addr: %p\n",
+ odp_thread_id(),
+ mmap_desc.mem);
+
+ if (mmap_desc.mem == NULL)
+ pkt_nm->desc = nm_open(ifname, NULL, 0, NULL);
+ else
+ pkt_nm->desc = nm_open(ifname, NULL, NM_OPEN_NO_MMAP,
+ &mmap_desc);
if (pkt_nm->desc == NULL) {
ODP_ERR("Error opening nm interface: %s\n", strerror(errno));
+ odp_spinlock_unlock(&nm_global_lock);
return -1;
}
+ if (mmap_desc.mem == NULL) {
+ mmap_desc.mem = pkt_nm->desc->mem;
+ mmap_desc.memsize = pkt_nm->desc->memsize;
+ }
+ odp_spinlock_unlock(&nm_global_lock);
+
ODP_DBG("[%04d] mmap addr %p\n",
odp_thread_id(),
pkt_nm->desc->mem);
Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org> --- platform/linux-netmap/odp_packet_netmap.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)