On 11 November 2014 12:35, Ciprian Barbu <[email protected]> wrote:
> Signed-off-by: Ciprian Barbu <[email protected]>

Reviewed-by: Mike Holmes <[email protected]>

> ---
>  platform/linux-netmap/README                      | 23 ++++++++++-------
>  platform/linux-netmap/include/odp_packet_netmap.h | 20 +++++++--------
>  platform/linux-netmap/odp_packet_netmap.c         | 30 
> +++++++++++------------
>  3 files changed, 39 insertions(+), 34 deletions(-)
>
> diff --git a/platform/linux-netmap/README b/platform/linux-netmap/README
> index abcb187..3718072 100644
> --- a/platform/linux-netmap/README
> +++ b/platform/linux-netmap/README
> @@ -25,20 +25,18 @@ at runtime.
>  2.1 Building netmap
>  --------------------
>
> -Netmap is currently hosted on https://code.google.com/p/netmap/ but
> -ODP only works at this point with netmap API version 10 so you will need
> -a specific revision of netmap.
> +Netmap is currently hosted on https://code.google.com/p/netmap/
>
>      git clone https://code.google.com/p/netmap/
>      cd netmap
> -    git reset --hard 1f462ef
> +    git co v11.1
>
>  Netmap consists of a core kernel module (netmap_lin.ko) and optional modified
>  device drivers.
>
>  Netmap builds as an out-of-tree kernel module, you need matching kernel 
> sources
>  to compile it. General build instructions can be found in the packet README:
> -http://code.google.com/p/netmap/source/browse/README
> +https://code.google.com/p/netmap/source/browse/LINUX/README
>
>  2.1.1 Building netmap on Ubuntu with stock kernel
>
> @@ -56,12 +54,14 @@ You will need to locate it and extract it to a convenient 
> place.
>  Now compile netmap:
>
>      cd LINUX
> -    make SRC=<path_to_kernel_source>
> +    ./configure --kernel-sources=<path_to_kernel_src>
> +    make
>
>  2.1.2 Building netmap for kernel built from sources
>
>      cd LINUX
> -    make KSRC=<path_to_kernel_source>
> +    ./configure --kernel-dir=<path_to_kernel_tree>
> +    make
>
>  2.2 Building ODP
>  ----------------
> @@ -69,13 +69,18 @@ Now compile netmap:
>  The default platform is linux-netmap, if you want linux-generic you need to
>  specify it to configure --with-platform.
>
> +ODP works with the latest release version of netmap, which is currently at 
> API
> +version 11.1. There is one problem though, the default CFLAGS that ODP is 
> built
> +with contains -Werror=cast-qual. A temporary workaround is be to disable this
> +flag using -Wno-cast-qual.
> +
>  The --with-sdk-install-path can be used to point to the netmap sources.
>
>      ./bootstrap
>
> -    ./configure
> +    ./configure CFLAGS='-Wno-cast-qual'
>  or
> -    ./configure --with-sdk-install-path=<netmap>
> +    ./configure --with-sdk-install-path=<netmap> CFLAGS='-Wno-cast-qual'
>
>  To configure ODP for linux-generic:
>      ./configure --with-platform=linux-generic
> diff --git a/platform/linux-netmap/include/odp_packet_netmap.h 
> b/platform/linux-netmap/include/odp_packet_netmap.h
> index b4c523f..78b2379 100644
> --- a/platform/linux-netmap/include/odp_packet_netmap.h
> +++ b/platform/linux-netmap/include/odp_packet_netmap.h
> @@ -26,17 +26,17 @@
>  /** Packet socket using netmap mmaped rings for both Rx and Tx */
>  typedef struct {
>         odp_buffer_pool_t pool;
> -       size_t max_frame_len; /**< max frame len = buf_size - sizeof(pkt_hdr) 
> */
> -       size_t frame_offset; /**< frame start offset from start of pkt buf */
> -       size_t buf_size; /**< size of buffer payload in 'pool' */
> -       struct nm_desc_t *nm_desc;
> -       uint32_t begin;
> -       uint32_t end;
> -       struct netmap_ring *rxring;
> -       struct netmap_ring *txring;
> -       odp_queue_t tx_access; /* Used for exclusive access to send packets */
> +       size_t max_frame_len;   /**< buf_size - sizeof(pkt_hdr) */
> +       size_t frame_offset;    /**< Frame start offset from start of pkt buf 
> */
> +       size_t buf_size;        /**< Size of buffer payload in 'pool' */
> +       struct nm_desc *desc;   /**< Netmap meta-data for the device */
> +       uint32_t begin;         /**< First ring to poll */
> +       uint32_t end;           /**< Last ring to poll */
> +       struct netmap_ring *rxring; /**< First rx ring */
> +       struct netmap_ring *txring; /**< First tx ring */
> +       odp_queue_t tx_access;  /** Used for exclusive access to send packets 
> */
>         uint32_t if_flags;
> -       char ifname[32];
> +       char ifname[IFNAMSIZ];
>  } pkt_netmap_t;
>
>  /**
> diff --git a/platform/linux-netmap/odp_packet_netmap.c 
> b/platform/linux-netmap/odp_packet_netmap.c
> index 6243040..ec4e0ea 100644
> --- a/platform/linux-netmap/odp_packet_netmap.c
> +++ b/platform/linux-netmap/odp_packet_netmap.c
> @@ -107,7 +107,7 @@ done:
>  int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const char *netdev,
>                      odp_buffer_pool_t pool)
>  {
> -       char ifname[32];
> +       char ifname[IFNAMSIZ];
>         odp_packet_t pkt;
>         uint8_t *pkt_buf;
>         uint8_t *l2_hdr;
> @@ -132,23 +132,23 @@ int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const 
> char *netdev,
>
>         odph_packet_free(pkt);
>
> -       strncpy(pkt_nm->ifname, netdev, sizeof(pkt_nm->ifname));
> +       snprintf(pkt_nm->ifname, sizeof(pkt_nm->ifname), "%s", netdev);
>         snprintf(ifname, sizeof(ifname), "netmap:%s", netdev);
> -       pkt_nm->nm_desc = nm_open(ifname, NULL, 0, 0);
> +       pkt_nm->desc = nm_open(ifname, NULL, 0, 0);
>
> -       if (pkt_nm->nm_desc == NULL) {
> +       if (pkt_nm->desc == NULL) {
>                 ODP_ERR("Error opening nm interface: %s\n", strerror(errno));
>                 return -1;
>         }
>
>         ODP_DBG("thread %d mmap addr %p\n",
>                 odp_thread_id(),
> -               pkt_nm->nm_desc->mem);
> +               pkt_nm->desc->mem);
>
>         pkt_nm->begin  = 0;
> -       pkt_nm->end    = pkt_nm->nm_desc->req.nr_rx_rings;
> -       pkt_nm->rxring = NETMAP_RXRING(pkt_nm->nm_desc->nifp, 0);
> -       pkt_nm->txring = NETMAP_TXRING(pkt_nm->nm_desc->nifp, 0);
> +       pkt_nm->end    = pkt_nm->desc->req.nr_rx_rings;
> +       pkt_nm->rxring = NETMAP_RXRING(pkt_nm->desc->nifp, 0);
> +       pkt_nm->txring = NETMAP_TXRING(pkt_nm->desc->nifp, 0);
>
>         ret = nm_do_ioctl(pkt_nm, SIOCGIFFLAGS, 0);
>         if (ret)
> @@ -188,9 +188,9 @@ int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const 
> char *netdev,
>
>  int close_pkt_netmap(pkt_netmap_t * const pkt_nm)
>  {
> -       if (pkt_nm->nm_desc != NULL) {
> -               nm_close(pkt_nm->nm_desc);
> -               pkt_nm->nm_desc = NULL;
> +       if (pkt_nm->desc != NULL) {
> +               nm_close(pkt_nm->desc);
> +               pkt_nm->desc = NULL;
>         }
>
>         return 0;
> @@ -210,7 +210,7 @@ int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, 
> odp_packet_t pkt_table[],
>         int ret;
>  #endif
>
> -       fd = pkt_nm->nm_desc->fd;
> +       fd = pkt_nm->desc->fd;
>  #ifdef NETMAP_BLOCKING_IO
>         fds[0].fd = fd;
>         fds[0].events = POLLIN;
> @@ -236,7 +236,7 @@ int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, 
> odp_packet_t pkt_table[],
>                                 break;
>                         }
>
> -                       rxring = NETMAP_RXRING(pkt_nm->nm_desc->nifp, ringid);
> +                       rxring = NETMAP_RXRING(pkt_nm->desc->nifp, ringid);
>                 }
>
>                 limit = len - nb_rx;
> @@ -323,7 +323,7 @@ int send_pkt_netmap(pkt_netmap_t * const pkt_nm, 
> odp_packet_t pkt_table[],
>         int ret;
>  #endif
>
> -       fd = pkt_nm->nm_desc->fd;
> +       fd = pkt_nm->desc->fd;
>  #ifdef NETMAP_BLOCKING_IO
>         fds[0].fd = fd;
>         fds[0].events = POLLOUT;
> @@ -349,7 +349,7 @@ int send_pkt_netmap(pkt_netmap_t * const pkt_nm, 
> odp_packet_t pkt_table[],
>                                 break;
>                         }
>
> -                       txring = NETMAP_TXRING(pkt_nm->nm_desc->nifp, ringid);
> +                       txring = NETMAP_TXRING(pkt_nm->desc->nifp, ringid);
>                 }
>
>                 limit = len - nb_tx;
> --
> 1.8.3.2
>
>
> _______________________________________________
> lng-odp mailing list
> [email protected]
> http://lists.linaro.org/mailman/listinfo/lng-odp



-- 
Mike Holmes
Linaro  Sr Technical Manager
LNG - ODP

_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to