Author: mmacy
Date: Fri May 18 03:38:17 2018
New Revision: 333778
URL: https://svnweb.freebsd.org/changeset/base/333778

Log:
  netmap: pull fix for 32-bit support from upstream
  
  Approved by:  sbruno

Modified:
  head/sys/conf/makeLINT.mk
  head/sys/dev/netmap/if_ptnet.c
  head/sys/dev/netmap/netmap.c
  head/sys/dev/netmap/netmap_freebsd.c
  head/sys/dev/netmap/netmap_generic.c
  head/sys/dev/netmap/netmap_kern.h
  head/sys/dev/netmap/netmap_legacy.c
  head/sys/dev/netmap/netmap_mem2.c
  head/sys/dev/netmap/netmap_monitor.c
  head/sys/dev/netmap/netmap_pipe.c
  head/sys/dev/netmap/netmap_pt.c
  head/sys/dev/netmap/netmap_vale.c

Modified: head/sys/conf/makeLINT.mk
==============================================================================
--- head/sys/conf/makeLINT.mk   Fri May 18 02:58:26 2018        (r333777)
+++ head/sys/conf/makeLINT.mk   Fri May 18 03:38:17 2018        (r333778)
@@ -53,7 +53,6 @@ LINT: ${NOTES} ${MAKELINT_SED}
 .if ${TARGET} == "powerpc"
        # cat is available, not sure if cp is?
        cat ${.TARGET} > ${.TARGET}64
-       echo "nodevice netmap"  >> ${.TARGET}
        echo "machine   ${TARGET} powerpc" >> ${.TARGET}
        echo "machine   ${TARGET} powerpc64" >> ${.TARGET}64
 .endif

Modified: head/sys/dev/netmap/if_ptnet.c
==============================================================================
--- head/sys/dev/netmap/if_ptnet.c      Fri May 18 02:58:26 2018        
(r333777)
+++ head/sys/dev/netmap/if_ptnet.c      Fri May 18 03:38:17 2018        
(r333778)
@@ -210,7 +210,7 @@ static int  ptnet_irqs_init(struct ptnet_softc *sc);
 static void    ptnet_irqs_fini(struct ptnet_softc *sc);
 
 static uint32_t ptnet_nm_ptctl(if_t ifp, uint32_t cmd);
-static int     ptnet_nm_config(struct netmap_adapter *na,
+static int      ptnet_nm_config(struct netmap_adapter *na,
                                struct nm_config_info *info);
 static void    ptnet_update_vnet_hdr(struct ptnet_softc *sc);
 static int     ptnet_nm_register(struct netmap_adapter *na, int onoff);

Modified: head/sys/dev/netmap/netmap.c
==============================================================================
--- head/sys/dev/netmap/netmap.c        Fri May 18 02:58:26 2018        
(r333777)
+++ head/sys/dev/netmap/netmap.c        Fri May 18 03:38:17 2018        
(r333778)
@@ -536,35 +536,35 @@ SYSBEGIN(main_init);
 SYSCTL_DECL(_dev_netmap);
 SYSCTL_NODE(_dev, OID_AUTO, netmap, CTLFLAG_RW, 0, "Netmap args");
 SYSCTL_INT(_dev_netmap, OID_AUTO, verbose,
-    CTLFLAG_RW, &netmap_verbose, 0, "Verbose mode");
+               CTLFLAG_RW, &netmap_verbose, 0, "Verbose mode");
 SYSCTL_INT(_dev_netmap, OID_AUTO, no_timestamp,
-    CTLFLAG_RW, &netmap_no_timestamp, 0, "no_timestamp");
+               CTLFLAG_RW, &netmap_no_timestamp, 0, "no_timestamp");
 SYSCTL_INT(_dev_netmap, OID_AUTO, no_pendintr, CTLFLAG_RW, &netmap_no_pendintr,
-    0, "Always look for new received packets.");
+               0, "Always look for new received packets.");
 SYSCTL_INT(_dev_netmap, OID_AUTO, txsync_retry, CTLFLAG_RW,
-    &netmap_txsync_retry, 0, "Number of txsync loops in bridge's flush.");
+               &netmap_txsync_retry, 0, "Number of txsync loops in bridge's 
flush.");
 
 SYSCTL_INT(_dev_netmap, OID_AUTO, fwd, CTLFLAG_RW, &netmap_fwd, 0,
-    "Force NR_FORWARD mode");
+               "Force NR_FORWARD mode");
 SYSCTL_INT(_dev_netmap, OID_AUTO, admode, CTLFLAG_RW, &netmap_admode, 0,
-    "Adapter mode. 0 selects the best option available,"
-    "1 forces native adapter, 2 forces emulated adapter");
+               "Adapter mode. 0 selects the best option available,"
+               "1 forces native adapter, 2 forces emulated adapter");
 SYSCTL_INT(_dev_netmap, OID_AUTO, generic_mit, CTLFLAG_RW, &netmap_generic_mit,
-    0, "RX notification interval in nanoseconds");
+               0, "RX notification interval in nanoseconds");
 SYSCTL_INT(_dev_netmap, OID_AUTO, generic_ringsize, CTLFLAG_RW,
-    &netmap_generic_ringsize, 0,
-    "Number of per-ring slots for emulated netmap mode");
+               &netmap_generic_ringsize, 0,
+               "Number of per-ring slots for emulated netmap mode");
 SYSCTL_INT(_dev_netmap, OID_AUTO, generic_rings, CTLFLAG_RW,
-    &netmap_generic_rings, 0,
-    "Number of TX/RX queues for emulated netmap adapters");
+               &netmap_generic_rings, 0,
+               "Number of TX/RX queues for emulated netmap adapters");
 #ifdef linux
 SYSCTL_INT(_dev_netmap, OID_AUTO, generic_txqdisc, CTLFLAG_RW,
-    &netmap_generic_txqdisc, 0, "Use qdisc for generic adapters");
+               &netmap_generic_txqdisc, 0, "Use qdisc for generic adapters");
 #endif
 SYSCTL_INT(_dev_netmap, OID_AUTO, ptnet_vnet_hdr, CTLFLAG_RW, &ptnet_vnet_hdr,
-    0, "Allow ptnet devices to use virtio-net headers");
+               0, "Allow ptnet devices to use virtio-net headers");
 SYSCTL_INT(_dev_netmap, OID_AUTO, ptnetmap_tx_workers, CTLFLAG_RW,
-    &ptnetmap_tx_workers, 0, "Use worker threads for pnetmap TX processing");
+               &ptnetmap_tx_workers, 0, "Use worker threads for pnetmap TX 
processing");
 
 SYSEND;
 
@@ -765,15 +765,15 @@ netmap_update_config(struct netmap_adapter *na)
            na->rx_buf_maxsize == info.rx_buf_maxsize)
                return 0; /* nothing changed */
        if (na->active_fds == 0) {
-               D("configuration changed for %s: txring %d x %d, "
-                       "rxring %d x %d, rxbufsz %d",
-                       na->name, na->num_tx_rings, na->num_tx_desc,
-                       na->num_rx_rings, na->num_rx_desc, na->rx_buf_maxsize);
                na->num_tx_rings = info.num_tx_rings;
                na->num_tx_desc = info.num_tx_descs;
                na->num_rx_rings = info.num_rx_rings;
                na->num_rx_desc = info.num_rx_descs;
                na->rx_buf_maxsize = info.rx_buf_maxsize;
+               D("configuration changed for %s: txring %d x %d, "
+                       "rxring %d x %d, rxbufsz %d",
+                       na->name, na->num_tx_rings, na->num_tx_desc,
+                       na->num_rx_rings, na->num_rx_desc, na->rx_buf_maxsize);
                return 0;
        }
        D("WARNING: configuration changed for %s while active: "
@@ -830,7 +830,7 @@ netmap_krings_create(struct netmap_adapter *na, u_int 
        n[NR_TX] = na->num_tx_rings + 1;
        n[NR_RX] = na->num_rx_rings + 1;
 
-       len = (n[NR_TX] + n[NR_RX]) * 
+       len = (n[NR_TX] + n[NR_RX]) *
                (sizeof(struct netmap_kring) + sizeof(struct netmap_kring *))
                + tailroom;
 
@@ -841,7 +841,7 @@ netmap_krings_create(struct netmap_adapter *na, u_int 
        }
        na->rx_rings = na->tx_rings + n[NR_TX];
        na->tailroom = na->rx_rings + n[NR_RX];
- 
+
        /* link the krings in the krings array */
        kring = (struct netmap_kring *)((char *)na->tailroom + tailroom);
        for (i = 0; i < n[NR_TX] + n[NR_RX]; i++) {
@@ -1006,9 +1006,9 @@ netmap_do_unregif(struct netmap_priv_d *priv)
                if (netmap_verbose)
                        D("deleting last instance for %s", na->name);
 
-                if (nm_netmap_on(na)) {
-                    D("BUG: netmap on while going to delete the krings");
-                }
+               if (nm_netmap_on(na)) {
+                       D("BUG: netmap on while going to delete the krings");
+               }
 
                na->nm_krings_delete(na);
        }
@@ -1324,7 +1324,7 @@ netmap_rxsync_from_host(struct netmap_kring *kring, in
                        m_copydata(m, 0, len, NMB(na, slot));
                        ND("nm %d len %d", nm_i, len);
                        if (netmap_verbose)
-                                D("%s", nm_dump_buf(NMB(na, slot),len, 128, 
NULL));
+                               D("%s", nm_dump_buf(NMB(na, slot),len, 128, 
NULL));
 
                        slot->len = len;
                        slot->flags = 0;
@@ -1476,7 +1476,7 @@ netmap_get_na(struct nmreq_header *hdr,
              struct netmap_adapter **na, struct ifnet **ifp,
              struct netmap_mem_d *nmd, int create)
 {
-       struct nmreq_register *req = (struct nmreq_register *)hdr->nr_body;
+       struct nmreq_register *req = (struct nmreq_register 
*)(uintptr_t)hdr->nr_body;
        int error = 0;
        struct netmap_adapter *ret = NULL;
        int nmd_ref = 0;
@@ -2091,9 +2091,6 @@ netmap_do_regif(struct netmap_priv_d *priv, struct net
 
        NMG_LOCK_ASSERT();
        priv->np_na = na;     /* store the reference */
-       error = netmap_set_ringid(priv, nr_mode, nr_ringid, nr_flags);
-       if (error)
-               goto err;
        error = netmap_mem_finalize(na->nm_mem, na);
        if (error)
                goto err;
@@ -2109,7 +2106,14 @@ netmap_do_regif(struct netmap_priv_d *priv, struct net
 
                /* ring configuration may have changed, fetch from the card */
                netmap_update_config(na);
+       }
 
+       /* compute the range of tx and rx rings to monitor */
+       error = netmap_set_ringid(priv, nr_mode, nr_ringid, nr_flags);
+       if (error)
+               goto err_put_lut;
+
+       if (na->active_fds == 0) {
                /*
                 * If this is the first registration of the adapter,
                 * perform sanity checks and create the in-kernel view
@@ -2117,12 +2121,18 @@ netmap_do_regif(struct netmap_priv_d *priv, struct net
                 */
                if (na->ifp && nm_priv_rx_enabled(priv)) {
                        /* This netmap adapter is attached to an ifnet. */
-                       unsigned nbs = netmap_mem_bufsize(na->nm_mem);
+                       unsigned nbs = NETMAP_BUF_SIZE(na);
                        unsigned mtu = nm_os_ifnet_mtu(na->ifp);
 
-                       ND("mtu %d rx_buf_maxsize %d netmap_buf_size %d",
-                                       mtu, na->rx_buf_maxsize, nbs);
+                       ND("%s: mtu %d rx_buf_maxsize %d netmap_buf_size %d",
+                                       na->name, mtu, na->rx_buf_maxsize, nbs);
 
+                       if (na->rx_buf_maxsize == 0) {
+                               D("%s: error: rx_buf_maxsize == 0", na->name);
+                               error = EIO;
+                               goto err_drop_mem;
+                       }
+
                        if (mtu <= na->rx_buf_maxsize) {
                                /* The MTU fits a single NIC slot. We only
                                 * Need to check that netmap buffers are
@@ -2191,7 +2201,7 @@ netmap_do_regif(struct netmap_priv_d *priv, struct net
        nifp = netmap_mem_if_new(na, priv);
        if (nifp == NULL) {
                error = ENOMEM;
-               goto err_del_rings;
+               goto err_rel_excl;
        }
 
        if (nm_kring_pending(priv)) {
@@ -2217,10 +2227,9 @@ netmap_do_regif(struct netmap_priv_d *priv, struct net
 
 err_del_if:
        netmap_mem_if_delete(na, nifp);
-err_del_rings:
-       netmap_mem_rings_delete(na);
 err_rel_excl:
        netmap_krings_put(priv);
+       netmap_mem_rings_delete(na);
 err_del_krings:
        if (na->active_fds == 0)
                na->nm_krings_delete(na);
@@ -2313,8 +2322,8 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
                 * For convenince, the nr_body pointer and the pointers
                 * in the options list will be replaced with their
                 * kernel-space counterparts. The original pointers are
-                * saved internally and later restored by nmreq_copyout
-                */
+                * saved internally and later restored by nmreq_copyout
+                */
                error = nmreq_copyin(hdr, nr_body_is_user);
                if (error) {
                        return error;
@@ -2326,7 +2335,7 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
                switch (hdr->nr_reqtype) {
                case NETMAP_REQ_REGISTER: {
                        struct nmreq_register *req =
-                               (struct nmreq_register *)hdr->nr_body;
+                               (struct nmreq_register 
*)(uintptr_t)hdr->nr_body;
                        /* Protect access to priv from concurrent requests. */
                        NMG_LOCK();
                        do {
@@ -2341,7 +2350,7 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
                                }
 
 #ifdef WITH_EXTMEM
-                               opt = nmreq_findoption((struct nmreq_option 
*)hdr->nr_options,
+                               opt = nmreq_findoption((struct nmreq_option 
*)(uintptr_t)hdr->nr_options,
                                                NETMAP_REQ_OPT_EXTMEM);
                                if (opt != NULL) {
                                        struct nmreq_opt_extmem *e =
@@ -2444,7 +2453,7 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
 
                case NETMAP_REQ_PORT_INFO_GET: {
                        struct nmreq_port_info_get *req =
-                               (struct nmreq_port_info_get *)hdr->nr_body;
+                               (struct nmreq_port_info_get 
*)(uintptr_t)hdr->nr_body;
 
                        NMG_LOCK();
                        do {
@@ -2463,10 +2472,10 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
 
                                        /* get a refcount */
                                        hdr->nr_reqtype = NETMAP_REQ_REGISTER;
-                                       hdr->nr_body = (uint64_t)&regreq;
+                                       hdr->nr_body = (uintptr_t)&regreq;
                                        error = netmap_get_na(hdr, &na, &ifp, 
NULL, 1 /* create */);
                                        hdr->nr_reqtype = 
NETMAP_REQ_PORT_INFO_GET; /* reset type */
-                                       hdr->nr_body = (uint64_t)req; /* reset 
nr_body */
+                                       hdr->nr_body = (uintptr_t)req; /* reset 
nr_body */
                                        if (error) {
                                                na = NULL;
                                                ifp = NULL;
@@ -2517,7 +2526,7 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
 
                case NETMAP_REQ_PORT_HDR_SET: {
                        struct nmreq_port_hdr *req =
-                               (struct nmreq_port_hdr *)hdr->nr_body;
+                               (struct nmreq_port_hdr 
*)(uintptr_t)hdr->nr_body;
                        /* Build a nmreq_register out of the nmreq_port_hdr,
                         * so that we can call netmap_get_bdg_na(). */
                        struct nmreq_register regreq;
@@ -2533,10 +2542,10 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
                        }
                        NMG_LOCK();
                        hdr->nr_reqtype = NETMAP_REQ_REGISTER;
-                       hdr->nr_body = (uint64_t)&regreq;
+                       hdr->nr_body = (uintptr_t)&regreq;
                        error = netmap_get_bdg_na(hdr, &na, NULL, 0);
                        hdr->nr_reqtype = NETMAP_REQ_PORT_HDR_SET;
-                       hdr->nr_body = (uint64_t)req;
+                       hdr->nr_body = (uintptr_t)req;
                        if (na && !error) {
                                struct netmap_vp_adapter *vpna =
                                        (struct netmap_vp_adapter *)na;
@@ -2556,7 +2565,7 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
                case NETMAP_REQ_PORT_HDR_GET: {
                        /* Get vnet-header length for this netmap port */
                        struct nmreq_port_hdr *req =
-                               (struct nmreq_port_hdr *)hdr->nr_body;
+                               (struct nmreq_port_hdr 
*)(uintptr_t)hdr->nr_body;
                        /* Build a nmreq_register out of the nmreq_port_hdr,
                         * so that we can call netmap_get_bdg_na(). */
                        struct nmreq_register regreq;
@@ -2565,10 +2574,10 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
                        bzero(&regreq, sizeof(regreq));
                        NMG_LOCK();
                        hdr->nr_reqtype = NETMAP_REQ_REGISTER;
-                       hdr->nr_body = (uint64_t)&regreq;
+                       hdr->nr_body = (uintptr_t)&regreq;
                        error = netmap_get_na(hdr, &na, &ifp, NULL, 0);
                        hdr->nr_reqtype = NETMAP_REQ_PORT_HDR_GET;
-                       hdr->nr_body = (uint64_t)req;
+                       hdr->nr_body = (uintptr_t)req;
                        if (na && !error) {
                                req->nr_hdr_len = na->virt_hdr_len;
                        }
@@ -2595,7 +2604,7 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, c
 #endif  /* WITH_VALE */
                case NETMAP_REQ_POOLS_INFO_GET: {
                        struct nmreq_pools_info *req =
-                               (struct nmreq_pools_info *)hdr->nr_body;
+                               (struct nmreq_pools_info 
*)(uintptr_t)hdr->nr_body;
                        /* Get information from the memory allocator. This
                         * netmap device must already be bound to a port.
                         * Note that hdr->nr_name is ignored. */
@@ -2774,8 +2783,8 @@ nmreq_copyin(struct nmreq_header *hdr, int nr_body_is_
                error = EMSGSIZE;
                goto out_err;
        }
-       if ((rqsz && hdr->nr_body == (uint64_t)NULL) ||
-               (!rqsz && hdr->nr_body != (uint64_t)NULL)) {
+       if ((rqsz && hdr->nr_body == (uintptr_t)NULL) ||
+               (!rqsz && hdr->nr_body != (uintptr_t)NULL)) {
                /* Request body expected, but not found; or
                 * request body found but unexpected. */
                error = EINVAL;
@@ -2784,8 +2793,8 @@ nmreq_copyin(struct nmreq_header *hdr, int nr_body_is_
 
        bufsz = 2 * sizeof(void *) + rqsz;
        optsz = 0;
-       for (src = (struct nmreq_option *)hdr->nr_options; src;
-            src = (struct nmreq_option *)buf.nro_next)
+       for (src = (struct nmreq_option *)(uintptr_t)hdr->nr_options; src;
+            src = (struct nmreq_option *)(uintptr_t)buf.nro_next)
        {
                error = copyin(src, &buf, sizeof(*src));
                if (error)
@@ -2813,11 +2822,11 @@ nmreq_copyin(struct nmreq_header *hdr, int nr_body_is_
        p = (char *)ptrs;
 
        /* copy the body */
-       error = copyin((void *)hdr->nr_body, p, rqsz);
+       error = copyin((void *)(uintptr_t)hdr->nr_body, p, rqsz);
        if (error)
                goto out_restore;
        /* overwrite the user pointer with the in-kernel one */
-       hdr->nr_body = (uint64_t)p;
+       hdr->nr_body = (uintptr_t)p;
        p += rqsz;
 
        /* copy the options */
@@ -2874,7 +2883,7 @@ static int
 nmreq_copyout(struct nmreq_header *hdr, int rerror)
 {
        struct nmreq_option *src, *dst;
-       void *ker = (void *)hdr->nr_body, *bufstart;
+       void *ker = (void *)(uintptr_t)hdr->nr_body, *bufstart;
        uint64_t *ptrs;
        size_t bodysz;
        int error;
@@ -2886,13 +2895,13 @@ nmreq_copyout(struct nmreq_header *hdr, int rerror)
        ptrs = (uint64_t *)ker - 2;
        bufstart = ptrs;
        hdr->nr_body = *ptrs++;
-       src = (struct nmreq_option *)hdr->nr_options;
+       src = (struct nmreq_option *)(uintptr_t)hdr->nr_options;
        hdr->nr_options = *ptrs;
 
        if (!rerror) {
                /* copy the body */
                bodysz = nmreq_size_by_type(hdr->nr_reqtype);
-               error = copyout(ker, (void *)hdr->nr_body, bodysz);
+               error = copyout(ker, (void *)(uintptr_t)hdr->nr_body, bodysz);
                if (error) {
                        rerror = error;
                        goto out;
@@ -2900,7 +2909,7 @@ nmreq_copyout(struct nmreq_header *hdr, int rerror)
        }
 
        /* copy the options */
-       dst = (struct nmreq_option *)hdr->nr_options;
+       dst = (struct nmreq_option *)(uintptr_t)hdr->nr_options;
        while (src) {
                size_t optsz;
                uint64_t next;
@@ -2916,7 +2925,7 @@ nmreq_copyout(struct nmreq_header *hdr, int rerror)
                        rerror = error;
                        goto out;
                }
-                      
+
                /* copy the option body only if there was no error */
                if (!rerror && !src->nro_status) {
                        optsz = nmreq_opt_size_by_type(src->nro_reqtype);
@@ -2928,8 +2937,8 @@ nmreq_copyout(struct nmreq_header *hdr, int rerror)
                                }
                        }
                }
-               src = (struct nmreq_option *)next;
-               dst = (struct nmreq_option *)*ptrs;
+               src = (struct nmreq_option *)(uintptr_t)next;
+               dst = (struct nmreq_option *)(uintptr_t)*ptrs;
        }
 
 
@@ -2942,7 +2951,7 @@ out:
 struct nmreq_option *
 nmreq_findoption(struct nmreq_option *opt, uint16_t reqtype)
 {
-       for ( ; opt; opt = (struct nmreq_option *)opt->nro_next)
+       for ( ; opt; opt = (struct nmreq_option *)(uintptr_t)opt->nro_next)
                if (opt->nro_reqtype == reqtype)
                        return opt;
        return NULL;
@@ -2953,7 +2962,7 @@ nmreq_checkduplicate(struct nmreq_option *opt) {
        uint16_t type = opt->nro_reqtype;
        int dup = 0;
 
-       while ((opt = nmreq_findoption((struct nmreq_option *)opt->nro_next,
+       while ((opt = nmreq_findoption((struct nmreq_option 
*)(uintptr_t)opt->nro_next,
                        type))) {
                dup++;
                opt->nro_status = EINVAL;
@@ -2969,8 +2978,8 @@ nmreq_checkoptions(struct nmreq_header *hdr)
         * marked as not supported
         */
 
-       for (opt = (struct nmreq_option *)hdr->nr_options; opt;
-            opt = (struct nmreq_option *)opt->nro_next)
+       for (opt = (struct nmreq_option *)(uintptr_t)hdr->nr_options; opt;
+            opt = (struct nmreq_option *)(uintptr_t)opt->nro_next)
                if (opt->nro_status == EOPNOTSUPP)
                        return EOPNOTSUPP;
 
@@ -3643,9 +3652,9 @@ netmap_transmit(struct ifnet *ifp, struct mbuf *m)
         */
        mbq_lock(q);
 
-        busy = kring->nr_hwtail - kring->nr_hwcur;
-        if (busy < 0)
-                busy += kring->nkr_num_slots;
+       busy = kring->nr_hwtail - kring->nr_hwcur;
+       if (busy < 0)
+               busy += kring->nkr_num_slots;
        if (busy + mbq_len(q) >= kring->nkr_num_slots - 1) {
                RD(2, "%s full hwcur %d hwtail %d qlen %d", na->name,
                        kring->nr_hwcur, kring->nr_hwtail, mbq_len(q));

Modified: head/sys/dev/netmap/netmap_freebsd.c
==============================================================================
--- head/sys/dev/netmap/netmap_freebsd.c        Fri May 18 02:58:26 2018        
(r333777)
+++ head/sys/dev/netmap/netmap_freebsd.c        Fri May 18 03:38:17 2018        
(r333778)
@@ -138,13 +138,13 @@ nm_os_put_module(void)
 static void
 netmap_ifnet_arrival_handler(void *arg __unused, struct ifnet *ifp)
 {
-        netmap_undo_zombie(ifp);
+       netmap_undo_zombie(ifp);
 }
 
 static void
 netmap_ifnet_departure_handler(void *arg __unused, struct ifnet *ifp)
 {
-        netmap_make_zombie(ifp);
+       netmap_make_zombie(ifp);
 }
 
 static eventhandler_tag nm_ifnet_ah_tag;
@@ -153,33 +153,33 @@ static eventhandler_tag nm_ifnet_dh_tag;
 int
 nm_os_ifnet_init(void)
 {
-        nm_ifnet_ah_tag =
-                EVENTHANDLER_REGISTER(ifnet_arrival_event,
-                        netmap_ifnet_arrival_handler,
-                        NULL, EVENTHANDLER_PRI_ANY);
-        nm_ifnet_dh_tag =
-                EVENTHANDLER_REGISTER(ifnet_departure_event,
-                        netmap_ifnet_departure_handler,
-                        NULL, EVENTHANDLER_PRI_ANY);
-        return 0;
+       nm_ifnet_ah_tag =
+               EVENTHANDLER_REGISTER(ifnet_arrival_event,
+                               netmap_ifnet_arrival_handler,
+                               NULL, EVENTHANDLER_PRI_ANY);
+       nm_ifnet_dh_tag =
+               EVENTHANDLER_REGISTER(ifnet_departure_event,
+                               netmap_ifnet_departure_handler,
+                               NULL, EVENTHANDLER_PRI_ANY);
+       return 0;
 }
 
 void
 nm_os_ifnet_fini(void)
 {
-        EVENTHANDLER_DEREGISTER(ifnet_arrival_event,
-                nm_ifnet_ah_tag);
-        EVENTHANDLER_DEREGISTER(ifnet_departure_event,
-                nm_ifnet_dh_tag);
+       EVENTHANDLER_DEREGISTER(ifnet_arrival_event,
+                       nm_ifnet_ah_tag);
+       EVENTHANDLER_DEREGISTER(ifnet_departure_event,
+                       nm_ifnet_dh_tag);
 }
 
 unsigned
 nm_os_ifnet_mtu(struct ifnet *ifp)
 {
 #if __FreeBSD_version < 1100030
-       return ifp->if_data.ifi_mtu;
+       return ifp->if_data.ifi_mtu;
 #else /* __FreeBSD_version >= 1100030 */
-       return ifp->if_mtu;
+       return ifp->if_mtu;
 #endif
 }
 
@@ -625,14 +625,14 @@ nm_os_vi_detach(struct ifnet *ifp)
 struct nm_os_extmem {
        vm_object_t obj;
        vm_offset_t kva;
-        vm_offset_t size;
-       vm_pindex_t scan;
+       vm_offset_t size;
+       uintptr_t scan;
 };
 
 void
 nm_os_extmem_delete(struct nm_os_extmem *e)
 {
-       D("freeing %zx bytes", (size_t)e->size);
+       D("freeing %jx bytes", (uintmax_t)e->size);
        vm_map_remove(kernel_map, e->kva, e->kva + e->size);
        nm_os_free(e);
 }
@@ -701,7 +701,7 @@ nm_os_extmem_create(unsigned long p, struct nmreq_pool
                        VMFS_OPTIMAL_SPACE, VM_PROT_READ | VM_PROT_WRITE,
                        VM_PROT_READ | VM_PROT_WRITE, 0);
        if (rv != KERN_SUCCESS) {
-               D("vm_map_find(%zx) failed", (size_t)e->size);
+               D("vm_map_find(%jx) failed", (uintmax_t)e->size);
                goto out_rel;
        }
        rv = vm_map_wire(kernel_map, e->kva, e->kva + e->size,
@@ -942,7 +942,7 @@ struct netmap_vm_handle_t {
 
 static int
 netmap_dev_pager_ctor(void *handle, vm_ooffset_t size, vm_prot_t prot,
-    vm_ooffset_t foff, struct ucred *cred, u_short *color)
+               vm_ooffset_t foff, struct ucred *cred, u_short *color)
 {
        struct netmap_vm_handle_t *vmh = handle;
 
@@ -1519,7 +1519,7 @@ freebsd_netmap_poll(struct cdev *cdevi __unused, int e
 
 static int
 freebsd_netmap_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t data,
-        int ffla __unused, struct thread *td)
+               int ffla __unused, struct thread *td)
 {
        int error;
        struct netmap_priv_d *priv;

Modified: head/sys/dev/netmap/netmap_generic.c
==============================================================================
--- head/sys/dev/netmap/netmap_generic.c        Fri May 18 02:58:26 2018        
(r333777)
+++ head/sys/dev/netmap/netmap_generic.c        Fri May 18 03:38:17 2018        
(r333778)
@@ -235,14 +235,14 @@ nm_os_get_mbuf(struct ifnet *ifp, int len)
        for ((_k)=*(_karr), (_i) = 0; (_i) < (_n); (_i)++, (_k) = (_karr)[(_i)])
 
 #define for_each_tx_kring(_i, _k, _na) \
-            for_each_kring_n(_i, _k, (_na)->tx_rings, (_na)->num_tx_rings)
+               for_each_kring_n(_i, _k, (_na)->tx_rings, (_na)->num_tx_rings)
 #define for_each_tx_kring_h(_i, _k, _na) \
-            for_each_kring_n(_i, _k, (_na)->tx_rings, (_na)->num_tx_rings + 1)
+               for_each_kring_n(_i, _k, (_na)->tx_rings, (_na)->num_tx_rings + 
1)
 
 #define for_each_rx_kring(_i, _k, _na) \
-            for_each_kring_n(_i, _k, (_na)->rx_rings, (_na)->num_rx_rings)
+               for_each_kring_n(_i, _k, (_na)->rx_rings, (_na)->num_rx_rings)
 #define for_each_rx_kring_h(_i, _k, _na) \
-            for_each_kring_n(_i, _k, (_na)->rx_rings, (_na)->num_rx_rings + 1)
+               for_each_kring_n(_i, _k, (_na)->rx_rings, (_na)->num_rx_rings + 
1)
 
 
 /* ======================== PERFORMANCE STATISTICS =========================== 
*/
@@ -297,12 +297,12 @@ static struct rate_context rate_ctx;
 
 void generic_rate(int txp, int txs, int txi, int rxp, int rxs, int rxi)
 {
-    if (txp) rate_ctx.new.txpkt++;
-    if (txs) rate_ctx.new.txsync++;
-    if (txi) rate_ctx.new.txirq++;
-    if (rxp) rate_ctx.new.rxpkt++;
-    if (rxs) rate_ctx.new.rxsync++;
-    if (rxi) rate_ctx.new.rxirq++;
+       if (txp) rate_ctx.new.txpkt++;
+       if (txs) rate_ctx.new.txsync++;
+       if (txi) rate_ctx.new.txirq++;
+       if (rxp) rate_ctx.new.rxpkt++;
+       if (rxs) rate_ctx.new.rxsync++;
+       if (rxi) rate_ctx.new.rxirq++;
 }
 
 #else /* !RATE */
@@ -586,7 +586,7 @@ generic_mbuf_destructor(struct mbuf *m)
         * MBUF_TXQ(m) under our feet. If the match is not found
         * on 'r', we try to see if it belongs to some other ring.
         */
-        for (;;) {
+       for (;;) {
                bool match = false;
 
                kring = na->tx_rings[r];

Modified: head/sys/dev/netmap/netmap_kern.h
==============================================================================
--- head/sys/dev/netmap/netmap_kern.h   Fri May 18 02:58:26 2018        
(r333777)
+++ head/sys/dev/netmap/netmap_kern.h   Fri May 18 03:38:17 2018        
(r333778)
@@ -450,7 +450,7 @@ struct netmap_kring {
 
        /* the adapter the owns this kring */
        struct netmap_adapter *na;
-       
+
        /* the adapter that wants to be notified when this kring has
         * new slots avaialable. This is usually the same as the above,
         * but wrappers may let it point to themselves
@@ -1528,7 +1528,7 @@ int netmap_get_monitor_na(struct nmreq_header *hdr, st
 void netmap_monitor_stop(struct netmap_adapter *na);
 #else
 #define netmap_get_monitor_na(hdr, _2, _3, _4) \
-       (((struct nmreq_register *)hdr->nr_body)->nr_flags & (NR_MONITOR_TX | 
NR_MONITOR_RX) ? EOPNOTSUPP : 0)
+       (((struct nmreq_register *)(uintptr_t)hdr->nr_body)->nr_flags & 
(NR_MONITOR_TX | NR_MONITOR_RX) ? EOPNOTSUPP : 0)
 #endif
 
 #ifdef CONFIG_NET_NS
@@ -1823,7 +1823,7 @@ struct lut_entry {
 };
 #else /* linux & _WIN32 */
 /* dma-mapping in linux can assign a buffer a different address
- * depending on the device, so we need to have a separate 
+ * depending on the device, so we need to have a separate
  * physical-address look-up table for each na.
  * We can still share the vaddrs, though, therefore we split
  * the lut_entry structure.
@@ -2177,7 +2177,7 @@ nm_ptnetmap_host_on(struct netmap_adapter *na)
 }
 #else /* !WITH_PTNETMAP_HOST */
 #define netmap_get_pt_host_na(hdr, _2, _3, _4) \
-       (((struct nmreq_register *)hdr->nr_body)->nr_flags & (NR_PTNETMAP_HOST) 
? EOPNOTSUPP : 0)
+       (((struct nmreq_register *)(uintptr_t)hdr->nr_body)->nr_flags & 
(NR_PTNETMAP_HOST) ? EOPNOTSUPP : 0)
 #define ptnetmap_ctl(_1, _2, _3)   EINVAL
 #define nm_ptnetmap_host_on(_1)   EINVAL
 #endif /* !WITH_PTNETMAP_HOST */

Modified: head/sys/dev/netmap/netmap_legacy.c
==============================================================================
--- head/sys/dev/netmap/netmap_legacy.c Fri May 18 02:58:26 2018        
(r333777)
+++ head/sys/dev/netmap/netmap_legacy.c Fri May 18 03:38:17 2018        
(r333778)
@@ -132,8 +132,8 @@ nmreq_from_legacy(struct nmreq *nmr, u_long ioctl_cmd)
        /* First prepare the request header. */
        hdr->nr_version = NETMAP_API; /* new API */
        strncpy(hdr->nr_name, nmr->nr_name, sizeof(nmr->nr_name));
-       hdr->nr_options = (uint64_t)NULL;
-       hdr->nr_body = (uint64_t)NULL;
+       hdr->nr_options = (uintptr_t)NULL;
+       hdr->nr_body = (uintptr_t)NULL;
 
        switch (ioctl_cmd) {
        case NIOCREGIF: {
@@ -142,7 +142,7 @@ nmreq_from_legacy(struct nmreq *nmr, u_long ioctl_cmd)
                        /* Regular NIOCREGIF operation. */
                        struct nmreq_register *req = nm_os_malloc(sizeof(*req));
                        if (!req) { goto oom; }
-                       hdr->nr_body = (uint64_t)req;
+                       hdr->nr_body = (uintptr_t)req;
                        hdr->nr_reqtype = NETMAP_REQ_REGISTER;
                        if (nmreq_register_from_legacy(nmr, hdr, req)) {
                                goto oom;
@@ -152,7 +152,7 @@ nmreq_from_legacy(struct nmreq *nmr, u_long ioctl_cmd)
                case NETMAP_BDG_ATTACH: {
                        struct nmreq_vale_attach *req = 
nm_os_malloc(sizeof(*req));
                        if (!req) { goto oom; }
-                       hdr->nr_body = (uint64_t)req;
+                       hdr->nr_body = (uintptr_t)req;
                        hdr->nr_reqtype = NETMAP_REQ_VALE_ATTACH;
                        if (nmreq_register_from_legacy(nmr, hdr, &req->reg)) {
                                goto oom;
@@ -167,14 +167,14 @@ nmreq_from_legacy(struct nmreq *nmr, u_long ioctl_cmd)
                }
                case NETMAP_BDG_DETACH: {
                        hdr->nr_reqtype = NETMAP_REQ_VALE_DETACH;
-                       hdr->nr_body = (uint64_t)nm_os_malloc(sizeof(struct 
nmreq_vale_detach));
+                       hdr->nr_body = (uintptr_t)nm_os_malloc(sizeof(struct 
nmreq_vale_detach));
                        break;
                }
                case NETMAP_BDG_VNET_HDR:
                case NETMAP_VNET_HDR_GET: {
                        struct nmreq_port_hdr *req = nm_os_malloc(sizeof(*req));
                        if (!req) { goto oom; }
-                       hdr->nr_body = (uint64_t)req;
+                       hdr->nr_body = (uintptr_t)req;
                        hdr->nr_reqtype = (nmr->nr_cmd == NETMAP_BDG_VNET_HDR) ?
                                NETMAP_REQ_PORT_HDR_SET : 
NETMAP_REQ_PORT_HDR_GET;
                        req->nr_hdr_len = nmr->nr_arg1;
@@ -183,7 +183,7 @@ nmreq_from_legacy(struct nmreq *nmr, u_long ioctl_cmd)
                case NETMAP_BDG_NEWIF : {
                        struct nmreq_vale_newif *req = 
nm_os_malloc(sizeof(*req));
                        if (!req) { goto oom; }
-                       hdr->nr_body = (uint64_t)req;
+                       hdr->nr_body = (uintptr_t)req;
                        hdr->nr_reqtype = NETMAP_REQ_VALE_NEWIF;
                        req->nr_tx_slots = nmr->nr_tx_slots;
                        req->nr_rx_slots = nmr->nr_rx_slots;
@@ -200,7 +200,7 @@ nmreq_from_legacy(struct nmreq *nmr, u_long ioctl_cmd)
                case NETMAP_BDG_POLLING_OFF: {
                        struct nmreq_vale_polling *req = 
nm_os_malloc(sizeof(*req));
                        if (!req) { goto oom; }
-                       hdr->nr_body = (uint64_t)req;
+                       hdr->nr_body = (uintptr_t)req;
                        hdr->nr_reqtype = (nmr->nr_cmd == 
NETMAP_BDG_POLLING_ON) ?
                                NETMAP_REQ_VALE_POLLING_ENABLE :
                                NETMAP_REQ_VALE_POLLING_DISABLE;
@@ -232,7 +232,7 @@ nmreq_from_legacy(struct nmreq *nmr, u_long ioctl_cmd)
                if (nmr->nr_cmd == NETMAP_BDG_LIST) {
                        struct nmreq_vale_list *req = 
nm_os_malloc(sizeof(*req));
                        if (!req) { goto oom; }
-                       hdr->nr_body = (uint64_t)req;
+                       hdr->nr_body = (uintptr_t)req;
                        hdr->nr_reqtype = NETMAP_REQ_VALE_LIST;
                        req->nr_bridge_idx = nmr->nr_arg1;
                        req->nr_port_idx = nmr->nr_arg2;
@@ -240,7 +240,7 @@ nmreq_from_legacy(struct nmreq *nmr, u_long ioctl_cmd)
                        /* Regular NIOCGINFO. */
                        struct nmreq_port_info_get *req = 
nm_os_malloc(sizeof(*req));
                        if (!req) { goto oom; }
-                       hdr->nr_body = (uint64_t)req;
+                       hdr->nr_body = (uintptr_t)req;
                        hdr->nr_reqtype = NETMAP_REQ_PORT_INFO_GET;
                        req->nr_offset = nmr->nr_offset;
                        req->nr_memsize = nmr->nr_memsize;
@@ -258,7 +258,7 @@ nmreq_from_legacy(struct nmreq *nmr, u_long ioctl_cmd)
 oom:
        if (hdr) {
                if (hdr->nr_body) {
-                       nm_os_free((void *)hdr->nr_body);
+                       nm_os_free((void *)(uintptr_t)hdr->nr_body);
                }
                nm_os_free(hdr);
        }
@@ -293,13 +293,13 @@ nmreq_to_legacy(struct nmreq_header *hdr, struct nmreq
        switch (hdr->nr_reqtype) {
        case NETMAP_REQ_REGISTER: {
                struct nmreq_register *req =
-                       (struct nmreq_register *)hdr->nr_body;
+                       (struct nmreq_register *)(uintptr_t)hdr->nr_body;
                nmreq_register_to_legacy(req, nmr);
                break;
        }
        case NETMAP_REQ_PORT_INFO_GET: {
                struct nmreq_port_info_get *req =
-                       (struct nmreq_port_info_get *)hdr->nr_body;
+                       (struct nmreq_port_info_get *)(uintptr_t)hdr->nr_body;
                nmr->nr_offset = req->nr_offset;
                nmr->nr_memsize = req->nr_memsize;
                nmr->nr_tx_slots = req->nr_tx_slots;
@@ -311,7 +311,7 @@ nmreq_to_legacy(struct nmreq_header *hdr, struct nmreq
        }
        case NETMAP_REQ_VALE_ATTACH: {
                struct nmreq_vale_attach *req =
-                       (struct nmreq_vale_attach *)hdr->nr_body;
+                       (struct nmreq_vale_attach *)(uintptr_t)hdr->nr_body;
                nmreq_register_to_legacy(&req->reg, nmr);
                break;
        }
@@ -320,7 +320,7 @@ nmreq_to_legacy(struct nmreq_header *hdr, struct nmreq
        }
        case NETMAP_REQ_VALE_LIST: {
                struct nmreq_vale_list *req =
-                       (struct nmreq_vale_list *)hdr->nr_body;
+                       (struct nmreq_vale_list *)(uintptr_t)hdr->nr_body;
                strncpy(nmr->nr_name, hdr->nr_name, sizeof(nmr->nr_name));
                nmr->nr_arg1 = req->nr_bridge_idx;
                nmr->nr_arg2 = req->nr_port_idx;
@@ -329,13 +329,13 @@ nmreq_to_legacy(struct nmreq_header *hdr, struct nmreq
        case NETMAP_REQ_PORT_HDR_SET:
        case NETMAP_REQ_PORT_HDR_GET: {
                struct nmreq_port_hdr *req =
-                       (struct nmreq_port_hdr *)hdr->nr_body;
+                       (struct nmreq_port_hdr *)(uintptr_t)hdr->nr_body;
                nmr->nr_arg1 = req->nr_hdr_len;
                break;
        }
        case NETMAP_REQ_VALE_NEWIF: {
                struct nmreq_vale_newif *req =
-                       (struct nmreq_vale_newif *)hdr->nr_body;
+                       (struct nmreq_vale_newif *)(uintptr_t)hdr->nr_body;
                nmr->nr_tx_slots = req->nr_tx_slots;
                nmr->nr_rx_slots = req->nr_rx_slots;
                nmr->nr_tx_rings = req->nr_tx_rings;
@@ -375,7 +375,7 @@ netmap_ioctl_legacy(struct netmap_priv_d *priv, u_long
                        nmreq_to_legacy(hdr, nmr);
                }
                if (hdr->nr_body) {
-                       nm_os_free((void *)hdr->nr_body);
+                       nm_os_free((void *)(uintptr_t)hdr->nr_body);
                }
                nm_os_free(hdr);
                break;

Modified: head/sys/dev/netmap/netmap_mem2.c
==============================================================================
--- head/sys/dev/netmap/netmap_mem2.c   Fri May 18 02:58:26 2018        
(r333777)
+++ head/sys/dev/netmap/netmap_mem2.c   Fri May 18 03:38:17 2018        
(r333778)
@@ -673,10 +673,10 @@ nm_mem_assign_id_locked(struct netmap_mem_d *nmd)
 static int
 nm_mem_assign_id(struct netmap_mem_d *nmd)
 {
-        int ret;
+       int ret;
 
        NM_MTX_LOCK(nm_mem_list_lock);
-        ret = nm_mem_assign_id_locked(nmd);
+       ret = nm_mem_assign_id_locked(nmd);
        NM_MTX_UNLOCK(nm_mem_list_lock);
 
        return ret;
@@ -1143,7 +1143,7 @@ netmap_extra_alloc(struct netmap_adapter *na, uint32_t
 static void
 netmap_extra_free(struct netmap_adapter *na, uint32_t head)
 {
-        struct lut_entry *lut = na->na_lut.lut;
+       struct lut_entry *lut = na->na_lut.lut;
        struct netmap_mem_d *nmd = na->nm_mem;
        struct netmap_obj_pool *p = &nmd->pools[NETMAP_BUF_POOL];
        uint32_t i, cur, *buf;
@@ -1516,10 +1516,11 @@ netmap_mem_unmap(struct netmap_obj_pool *p, struct net
                return 0;
 
 #if defined(__FreeBSD__)
+       /* On FreeBSD mapping and unmapping is performed by the txsync
+        * and rxsync routine, packet by packet. */
        (void)i;
        (void)lim;
        (void)lut;
-       D("unsupported on FreeBSD");
 #elif defined(_WIN32)
        (void)i;
        (void)lim;
@@ -1551,10 +1552,11 @@ netmap_mem_map(struct netmap_obj_pool *p, struct netma
                return 0;
 
 #if defined(__FreeBSD__)
+       /* On FreeBSD mapping and unmapping is performed by the txsync
+        * and rxsync routine, packet by packet. */
        (void)i;
        (void)lim;
        (void)lut;
-       D("unsupported on FreeBSD");
 #elif defined(_WIN32)
        (void)i;
        (void)lim;
@@ -1572,7 +1574,7 @@ netmap_mem_map(struct netmap_obj_pool *p, struct netma
        if (lut->plut == NULL) {
                D("Failed to allocate physical lut for %s", na->name);
                return ENOMEM;
-        }
+       }
 
        for (i = 0; i < lim; i += p->_clustentries) {
                lut->plut[i].paddr = 0;
@@ -1644,7 +1646,7 @@ error:
  * allocator for private memory
  */
 static void *
-_netmap_mem_private_new(size_t size, struct netmap_obj_params *p, 
+_netmap_mem_private_new(size_t size, struct netmap_obj_params *p,
                struct netmap_mem_ops *ops, int *perr)
 {
        struct netmap_mem_d *d = NULL;
@@ -1722,16 +1724,16 @@ netmap_mem_private_new(u_int txr, u_int txd, u_int rxr
        if (p[NETMAP_RING_POOL].size < v)
                p[NETMAP_RING_POOL].size = v;
        /* each pipe endpoint needs two tx rings (1 normal + 1 host, fake)
-         * and two rx rings (again, 1 normal and 1 fake host)
-         */
+        * and two rx rings (again, 1 normal and 1 fake host)
+        */
        v = txr + rxr + 8 * npipes;
        if (p[NETMAP_RING_POOL].num < v)
                p[NETMAP_RING_POOL].num = v;
        /* for each pipe we only need the buffers for the 4 "real" rings.
-         * On the other end, the pipe ring dimension may be different from
-         * the parent port ring dimension. As a compromise, we allocate twice 
the
-         * space actually needed if the pipe rings were the same size as the 
parent rings
-         */
+        * On the other end, the pipe ring dimension may be different from
+        * the parent port ring dimension. As a compromise, we allocate twice 
the
+        * space actually needed if the pipe rings were the same size as the 
parent rings
+        */
        v = (4 * npipes + rxr) * rxd + (4 * npipes + txr) * txd + 2 + 
extra_bufs;
                /* the +2 is for the tx and rx fake buffers (indices 0 and 1) */
        if (p[NETMAP_BUF_POOL].num < v)
@@ -1942,7 +1944,11 @@ netmap_mem2_rings_create(struct netmap_adapter *na)
        return 0;
 
 cleanup:
-       netmap_free_rings(na);
+       /* we cannot actually cleanup here, since we don't own kring->users
+        * and kring->nr_klags & NKR_NEEDRING. The caller must decrement
+        * the first or zero-out the second, then call netmap_free_rings()
+        * to do the cleanup
+        */
 
        return ENOMEM;
 }
@@ -2155,7 +2161,7 @@ netmap_mem_ext_delete(struct netmap_mem_d *d)
 
        for (i = 0; i < NETMAP_POOLS_NR; i++) {
                struct netmap_obj_pool *p = &d->pools[i];
-               
+
                if (p->lut) {
                        nm_free_lut(p->lut, p->objtotal);
                        p->lut = NULL;
@@ -2215,7 +2221,7 @@ netmap_mem_ext_create(uint64_t usrptr, struct nmreq_po
                        pi->nr_if_pool_objtotal, pi->nr_if_pool_objsize,
                        pi->nr_ring_pool_objtotal, pi->nr_ring_pool_objsize,
                        pi->nr_buf_pool_objtotal, pi->nr_buf_pool_objsize);
-               
+
        os = nm_os_extmem_create(usrptr, pi, &error);
        if (os == NULL) {
                D("os extmem creation failed");
@@ -2238,7 +2244,7 @@ netmap_mem_ext_create(uint64_t usrptr, struct nmreq_po
                        &error);
        if (nme == NULL)
                goto out_unmap;
-                                       
+
        nr_pages = nm_os_extmem_nr_pages(os);
 
        /* from now on pages will be released by nme destructor;
@@ -2262,7 +2268,7 @@ netmap_mem_ext_create(uint64_t usrptr, struct nmreq_po
                        error = ENOMEM;
                        goto out_delete;
                }
-               
+
                p->bitmap_slots = (o->num + sizeof(uint32_t) - 1) / 
sizeof(uint32_t);
                p->invalid_bitmap = nm_os_malloc(sizeof(uint32_t) * 
p->bitmap_slots);
                if (p->invalid_bitmap == NULL) {
@@ -2515,11 +2521,11 @@ netmap_mem_pt_guest_finalize(struct netmap_mem_d *nmd)
        if (error)
                goto out;
 
-        /* Initialize the lut using the information contained in the
+       /* Initialize the lut using the information contained in the
         * ptnetmap memory device. */
-        bufsize = nm_os_pt_memdev_ioread(ptnmd->ptn_dev,
+       bufsize = nm_os_pt_memdev_ioread(ptnmd->ptn_dev,
                                         PTNET_MDEV_IO_BUF_POOL_OBJSZ);
-        nbuffers = nm_os_pt_memdev_ioread(ptnmd->ptn_dev,
+       nbuffers = nm_os_pt_memdev_ioread(ptnmd->ptn_dev,
                                         PTNET_MDEV_IO_BUF_POOL_OBJNUM);
 
        /* allocate the lut */
@@ -2740,7 +2746,7 @@ netmap_mem_pt_guest_create(nm_memid_t mem_id)
        ptnmd->host_mem_id = mem_id;
        ptnmd->pt_ifs = NULL;
 
-        /* Assign new id in the guest (We have the lock) */
+       /* Assign new id in the guest (We have the lock) */
        err = nm_mem_assign_id_locked(&ptnmd->up);
        if (err)
                goto error;

Modified: head/sys/dev/netmap/netmap_monitor.c
==============================================================================
--- head/sys/dev/netmap/netmap_monitor.c        Fri May 18 02:58:26 2018        
(r333777)
+++ head/sys/dev/netmap/netmap_monitor.c        Fri May 18 03:38:17 2018        
(r333778)
@@ -139,7 +139,7 @@ nm_is_zmon(struct netmap_adapter *na)
 static int
 netmap_monitor_txsync(struct netmap_kring *kring, int flags)
 {
-        RD(1, "%s %x", kring->name, flags);
+       RD(1, "%s %x", kring->name, flags);
        return EIO;
 }
 
@@ -152,10 +152,10 @@ netmap_monitor_txsync(struct netmap_kring *kring, int 
 static int
 netmap_monitor_rxsync(struct netmap_kring *kring, int flags)
 {
-        ND("%s %x", kring->name, flags);
+       ND("%s %x", kring->name, flags);
        kring->nr_hwcur = kring->rhead;
        mb();
-        return 0;
+       return 0;
 }
 
 /* nm_krings_create callbacks for monitors.
@@ -198,7 +198,7 @@ nm_monitor_alloc(struct netmap_kring *kring, u_int n)
                return 0;
 
        old_len = sizeof(struct netmap_kring *)*kring->max_monitors;
-        len = sizeof(struct netmap_kring *) * n;
+       len = sizeof(struct netmap_kring *) * n;
        nm = nm_os_realloc(kring->monitors, len, old_len);
        if (nm == NULL)
                return ENOMEM;
@@ -621,14 +621,14 @@ out_rxsync:
 static int
 netmap_zmon_parent_txsync(struct netmap_kring *kring, int flags)
 {
-        return netmap_zmon_parent_sync(kring, flags, NR_TX);

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to