Message ID | 1413214043-4864-3-git-send-email-ciprian.barbu@linaro.org |
---|---|
State | New |
Headers | show |
Will it be better to skip that patch and apply previous on top of current odp.git? Maxim. On 10/13/2014 07:27 PM, Ciprian Barbu wrote: > Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org> > --- > configure.ac | 21 - > platform/linux-generic/Makefile.am | 5 - > .../linux-generic/include/api/odp_pktio_netmap.h | 39 -- > .../linux-generic/include/api/odp_pktio_types.h | 12 - > .../linux-generic/include/odp_packet_io_internal.h | 6 - > platform/linux-generic/include/odp_packet_netmap.h | 67 --- > platform/linux-generic/odp_packet_io.c | 44 -- > platform/linux-generic/odp_packet_netmap.c | 453 --------------------- > 8 files changed, 647 deletions(-) > delete mode 100644 platform/linux-generic/include/api/odp_pktio_netmap.h > delete mode 100644 platform/linux-generic/include/odp_packet_netmap.h > delete mode 100644 platform/linux-generic/odp_packet_netmap.c > > diff --git a/configure.ac b/configure.ac > index 220f89a..4401bde 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -63,27 +63,6 @@ AC_SUBST(SDK_INSTALL_PATH) > AM_CONDITIONAL([SDK_INSTALL_PATH_], [test "x${SDK_INSTALL_PATH_}" = "x1"]) > > ########################################################################## > -# Enable/disable netmap support > -########################################################################## > -AC_ARG_ENABLE([netmap], > - [ --enable-netmap Enable/disable netmap], > - [if test x$enableval = xyes; then > - netmap_support=yes > - ODP_CFLAGS="$ODP_CFLAGS -DODP_HAVE_NETMAP=1" > - fi]) > - > -AC_ARG_WITH([netmap-path], > -AC_HELP_STRING([--with-netmap-path=DIR Path to netmap libs and headers], > - [(or in the default path if not specified).]), > -[NETMAP_PATH=$withval netmap_support=yes > -AM_CFLAGS="$AM_CFLAGS -I$NETMAP_PATH/sys" > -ODP_CFLAGS="$ODP_CFLAGS -DODP_HAVE_NETMAP=1" > -],[ AC_MSG_WARN([Netmap not found - continuing without netmap support]) > -]) > - > -AM_CONDITIONAL([ODP_NETMAP_ENABLED], [test x$netmap_support = xyes ]) > - > -########################################################################## > # Enable/disable ODP_DEBUG_PRINT > ########################################################################## > ODP_DEBUG=1 > diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am > index 25c82ea..bf6cd10 100644 > --- a/platform/linux-generic/Makefile.am > +++ b/platform/linux-generic/Makefile.am > @@ -37,7 +37,6 @@ include_HEADERS = \ > $(top_srcdir)/platform/linux-generic/include/api/odp_timer.h \ > $(top_srcdir)/platform/linux-generic/include/api/odp_version.h \ > $(top_srcdir)/platform/linux-generic/include/api/odp_pktio_types.h \ > - $(top_srcdir)/platform/linux-generic/include/api/odp_pktio_netmap.h \ > $(top_srcdir)/platform/linux-generic/include/api/odp_pktio_socket.h > > subdirheadersdir = $(includedir)/helper > @@ -74,7 +73,3 @@ __LIB__libodp_la_SOURCES = \ > odp_time.c \ > odp_timer.c > > -if ODP_NETMAP_ENABLED > -__LIB__libodp_la_SOURCES += \ > - odp_packet_netmap.c > -endif > diff --git a/platform/linux-generic/include/api/odp_pktio_netmap.h b/platform/linux-generic/include/api/odp_pktio_netmap.h > deleted file mode 100644 > index 294a13d..0000000 > --- a/platform/linux-generic/include/api/odp_pktio_netmap.h > +++ /dev/null > @@ -1,39 +0,0 @@ > - > -/* Copyright (c) 2013, Linaro Limited > - * All rights reserved. > - * > - * SPDX-License-Identifier: BSD-3-Clause > - */ > - > -/** > - * @file > - * > - * ODP packet input/output netmap > - */ > - > -#ifndef ODP_PKTIO_NETMAP_H > -#define ODP_PKTIO_NETMAP_H > - > -#ifdef __cplusplus > -extern "C" { > -#endif > - > -#include <odp_pktio_types.h> > - > -#define ODP_NETMAP_MODE_HW 0 /**< Netmap mode in hardware */ > -#define ODP_NETMAP_MODE_SW 1 /**< Netmap mode in software */ > - > -/** > - * Netmap parameters > - */ > -typedef struct { > - odp_pktio_type_t type; /**< Packet IO type */ > - int netmap_mode; /**< Netmap Mode */ > - uint16_t ringid; /**< Ring identifiers */ > -} netmap_params_t; > - > -#ifdef __cplusplus > -} > -#endif > - > -#endif > diff --git a/platform/linux-generic/include/api/odp_pktio_types.h b/platform/linux-generic/include/api/odp_pktio_types.h > index 54ce459..ab8e3da 100644 > --- a/platform/linux-generic/include/api/odp_pktio_types.h > +++ b/platform/linux-generic/include/api/odp_pktio_types.h > @@ -17,11 +17,6 @@ > extern "C" { > #endif > > -/* We should ensure that future enum values will never overlap, otherwise > - * applications that want netmap suport might get in trouble if the odp lib > - * was not built with netmap support and there are more types define below > - */ > - > /** > * Packet IO types > */ > @@ -29,13 +24,9 @@ typedef enum { > ODP_PKTIO_TYPE_SOCKET_BASIC = 0x1, > ODP_PKTIO_TYPE_SOCKET_MMSG, > ODP_PKTIO_TYPE_SOCKET_MMAP, > - ODP_PKTIO_TYPE_NETMAP, > } odp_pktio_type_t; > > #include <odp_pktio_socket.h> > -#ifdef ODP_HAVE_NETMAP > -#include <odp_pktio_netmap.h> > -#endif > > /** > * Packet IO parameters > @@ -43,9 +34,6 @@ typedef enum { > typedef union odp_pktio_params_t { > odp_pktio_type_t type; /**< Packet IO type */ > socket_params_t sock_params; /**< Socket parameter */ > -#ifdef ODP_HAVE_NETMAP > - netmap_params_t nm_params; > -#endif > } odp_pktio_params_t; > > #ifdef __cplusplus > diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h > index 881cc5f..7ba72df 100644 > --- a/platform/linux-generic/include/odp_packet_io_internal.h > +++ b/platform/linux-generic/include/odp_packet_io_internal.h > @@ -20,9 +20,6 @@ extern "C" { > > #include <odp_spinlock.h> > #include <odp_packet_socket.h> > -#ifdef ODP_HAVE_NETMAP > -#include <odp_packet_netmap.h> > -#endif > > struct pktio_entry { > odp_spinlock_t lock; /**< entry spinlock */ > @@ -32,9 +29,6 @@ struct pktio_entry { > odp_pktio_params_t params; /**< pktio parameters */ > pkt_sock_t pkt_sock; /**< using socket API for IO */ > pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap API for IO */ > -#ifdef ODP_HAVE_NETMAP > - pkt_netmap_t pkt_nm; /**< using netmap API for IO */ > -#endif > }; > > typedef union { > diff --git a/platform/linux-generic/include/odp_packet_netmap.h b/platform/linux-generic/include/odp_packet_netmap.h > deleted file mode 100644 > index 1ab50d0..0000000 > --- a/platform/linux-generic/include/odp_packet_netmap.h > +++ /dev/null > @@ -1,67 +0,0 @@ > -/* Copyright (c) 2013, Linaro Limited > - * All rights reserved. > - * > - * SPDX-License-Identifier: BSD-3-Clause > - */ > - > -#ifndef ODP_PACKET_NETMAP_H > -#define ODP_PACKET_NETMAP_H > - > -#include <stdint.h> > - > -#include <net/if.h> > -#include <net/netmap.h> > -#include <net/netmap_user.h> > - > -#include <odp_align.h> > -#include <odp_debug.h> > -#include <odp_buffer_pool.h> > -#include <odp_packet.h> > - > -#include <odp_pktio_netmap.h> > - > -#define ODP_NETMAP_MODE_HW 0 > -#define ODP_NETMAP_MODE_SW 1 > - > -#define NETMAP_BLOCKING_IO > - > -/** 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' */ > - int netmap_mode; > - 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 */ > - uint32_t if_flags; > - char ifname[32]; > -} pkt_netmap_t; > - > -/** > - * Configure an interface to work in netmap mode > - */ > -int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const char *netdev, > - odp_buffer_pool_t pool, netmap_params_t *nm_params); > - > -/** > - * Switch interface from netmap mode to normal mode > - */ > -int close_pkt_netmap(pkt_netmap_t * const pkt_nm); > - > -/** > - * Receive packets using netmap > - */ > -int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], > - unsigned len); > - > -/** > - * Send packets using netmap > - */ > -int send_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], > - unsigned len); > -#endif > diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c > index 06d8935..6ef87df 100644 > --- a/platform/linux-generic/odp_packet_io.c > +++ b/platform/linux-generic/odp_packet_io.c > @@ -13,9 +13,6 @@ > #include <odp_spinlock.h> > #include <odp_shared_memory.h> > #include <odp_packet_socket.h> > -#ifdef ODP_HAVE_NETMAP > -#include <odp_packet_netmap.h> > -#endif > #include <odp_hints.h> > #include <odp_config.h> > #include <odp_queue_internal.h> > @@ -23,9 +20,6 @@ > #include <odp_debug.h> > > #include <odp_pktio_socket.h> > -#ifdef ODP_HAVE_NETMAP > -#include <odp_pktio_netmap.h> > -#endif > > #include <string.h> > > @@ -127,11 +121,6 @@ static void init_pktio_entry(pktio_entry_t *entry, odp_pktio_params_t *params) > memset(&entry->s.pkt_sock_mmap, 0, > sizeof(entry->s.pkt_sock_mmap)); > break; > -#ifdef ODP_HAVE_NETMAP > - case ODP_PKTIO_TYPE_NETMAP: > - memset(&entry->s.pkt_nm, 0, sizeof(entry->s.pkt_nm)); > - break; > -#endif > default: > ODP_ERR("Packet I/O type not supported. Please recompile\n"); > break; > @@ -192,11 +181,6 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, > case ODP_PKTIO_TYPE_SOCKET_MMAP: > ODP_DBG("Allocating socket pktio\n"); > break; > -#ifdef ODP_HAVE_NETMAP > - case ODP_PKTIO_TYPE_NETMAP: > - ODP_DBG("Allocating netmap pktio\n"); > - break; > -#endif > default: > ODP_ERR("Invalid pktio type: %02x\n", params->type); > return ODP_PKTIO_INVALID; > @@ -230,18 +214,6 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, > id = ODP_PKTIO_INVALID; > } > break; > -#ifdef ODP_HAVE_NETMAP > - case ODP_PKTIO_TYPE_NETMAP: > - > - res = setup_pkt_netmap(&pktio_entry->s.pkt_nm, dev, > - pool, ¶ms->nm_params); > - if (res == -1) { > - close_pkt_netmap(&pktio_entry->s.pkt_nm); > - free_pktio_entry(id); > - id = ODP_PKTIO_INVALID; > - } > - break; > -#endif > default: > free_pktio_entry(id); > id = ODP_PKTIO_INVALID; > @@ -272,11 +244,6 @@ int odp_pktio_close(odp_pktio_t id) > case ODP_PKTIO_TYPE_SOCKET_MMAP: > res = close_pkt_sock_mmap(&entry->s.pkt_sock_mmap); > break; > -#ifdef ODP_HAVE_NETMAP > - case ODP_PKTIO_TYPE_NETMAP: > - res = close_pkt_netmap(&entry->s.pkt_nm); > - break; > -#endif > default: > break; > res |= free_pktio_entry(id); > @@ -323,11 +290,6 @@ int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) > pkts = recv_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap, > pkt_table, len); > break; > -#ifdef ODP_HAVE_NETMAP > - case ODP_PKTIO_TYPE_NETMAP: > - pkts = recv_pkt_netmap(&pktio_entry->s.pkt_nm, pkt_table, len); > - break; > -#endif > default: > pkts = -1; > break; > @@ -365,12 +327,6 @@ int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) > pkts = send_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap, > pkt_table, len); > break; > -#ifdef ODP_HAVE_NETMAP > - case ODP_PKTIO_TYPE_NETMAP: > - pkts = send_pkt_netmap(&pktio_entry->s.pkt_nm, > - pkt_table, len); > - break; > -#endif > default: > pkts = -1; > } > diff --git a/platform/linux-generic/odp_packet_netmap.c b/platform/linux-generic/odp_packet_netmap.c > deleted file mode 100644 > index 524492d..0000000 > --- a/platform/linux-generic/odp_packet_netmap.c > +++ /dev/null > @@ -1,453 +0,0 @@ > -/* Copyright (c) 2013, Linaro Limited > - * Copyright (c) 2013, Nokia Solutions and Networks > - * All rights reserved. > - * > - * SPDX-License-Identifier: BSD-3-Clause > - */ > - > -/* > - * NETMAP I/O code inspired by the pkt-gen example application in netmap by: > - * Copyright (C) 2011-2014 Matteo Landi, Luigi Rizzo. All rights reserved. > - * Copyright (C) 2013-2014 Universita` di Pisa. All rights reserved. > - */ > - > -#define _GNU_SOURCE > -#include <stdio.h> > -#include <errno.h> > -#include <sys/types.h> > -#include <sys/stat.h> > -#include <sys/ioctl.h> > -#include <sys/mman.h> > -#include <poll.h> > -#include <unistd.h> > -#include <fcntl.h> > -#include <string.h> > -#include <stdlib.h> > - > -#include <linux/ethtool.h> > -#include <linux/sockios.h> > - > -#include <odp_packet_internal.h> > -#include <odp_hints.h> > -#include <odp_thread.h> > - > -#include <odph_eth.h> > -#include <odph_ip.h> > -#include <odph_packet.h> > - > -#define NETMAP_WITH_LIBS > -#include <odp_packet_netmap.h> > - > -/** Eth buffer start offset from u32-aligned address to make sure the following > - * header (e.g. IP) starts at a 32-bit aligned address. > - */ > -#define ETHBUF_OFFSET (ODP_ALIGN_ROUNDUP(ODPH_ETHHDR_LEN, sizeof(uint32_t)) \ > - - ODPH_ETHHDR_LEN) > - > -/** Round up buffer address to get a properly aliged eth buffer, i.e. aligned > - * so that the next header always starts at a 32bit aligned address. > - */ > -#define ETHBUF_ALIGN(buf_ptr) ((uint8_t *)ODP_ALIGN_ROUNDUP_PTR((buf_ptr), \ > - sizeof(uint32_t)) + ETHBUF_OFFSET) > - > -#define ETH_PROMISC 1 /* TODO: maybe this should be exported to the user */ > -#define WAITLINK_TMO 2 > -#define POLL_TMO 50 > - > -static int nm_do_ioctl(pkt_netmap_t * const pkt_nm, unsigned long cmd, > - int subcmd) > -{ > - struct ethtool_value eval; > - struct ifreq ifr; > - int error; > - int fd; > - > - fd = socket(AF_INET, SOCK_DGRAM, 0); > - if (fd < 0) { > - ODP_ERR("Error: cannot get device control socket\n"); > - return -1; > - } > - > - memset(&ifr, 0, sizeof(ifr)); > - strncpy(ifr.ifr_name, pkt_nm->ifname, sizeof(ifr.ifr_name)); > - > - switch (cmd) { > - case SIOCSIFFLAGS: > - ifr.ifr_flags = pkt_nm->if_flags & 0xffff; > - break; > - case SIOCETHTOOL: > - eval.cmd = subcmd; > - eval.data = 0; > - ifr.ifr_data = (caddr_t)&eval; > - break; > - default: > - break; > - } > - error = ioctl(fd, cmd, &ifr); > - if (error) > - goto done; > - > - switch (cmd) { > - case SIOCGIFFLAGS: > - pkt_nm->if_flags = (ifr.ifr_flags << 16) | > - (0xffff & ifr.ifr_flags); > - ODP_DBG("flags are 0x%x\n", pkt_nm->if_flags); > - break; > - default: > - break; > - } > -done: > - close(fd); > - if (error) > - ODP_ERR("ioctl err %d %lu: %s\n", error, cmd, strerror(errno)); > - > - return error; > -} > - > -int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const char *netdev, > - odp_buffer_pool_t pool, netmap_params_t *nm_params) > -{ > - char qname[ODP_QUEUE_NAME_LEN]; > - char ifname[32]; > - odp_packet_t pkt; > - odp_buffer_t token; > - uint8_t *pkt_buf; > - uint16_t ringid; > - uint8_t *l2_hdr; > - int ret; > - > - if (pool == ODP_BUFFER_POOL_INVALID) > - return -1; > - pkt_nm->pool = pool; > - > - pkt = odph_packet_alloc(pool); > - if (!odph_packet_is_valid(pkt)) > - return -1; > - > - pkt_buf = odp_packet_buf_addr(pkt); > - l2_hdr = ETHBUF_ALIGN(pkt_buf); > - /* Store eth buffer offset for buffers from this pool */ > - pkt_nm->frame_offset = (uintptr_t)l2_hdr - (uintptr_t)pkt_buf; > - /* pkt buffer size */ > - pkt_nm->buf_size = odph_packet_buf_size(pkt); > - /* max frame len taking into account the l2-offset */ > - pkt_nm->max_frame_len = pkt_nm->buf_size - pkt_nm->frame_offset; > - /* save netmap_mode for later use */ > - pkt_nm->netmap_mode = nm_params->netmap_mode; > - > - odph_packet_free(pkt); > - > - if (nm_params->netmap_mode == ODP_NETMAP_MODE_SW) > - ringid = NETMAP_SW_RING; > - else > - ringid = nm_params->ringid; > - > - strncpy(pkt_nm->ifname, netdev, sizeof(pkt_nm->ifname)); > - snprintf(ifname, sizeof(ifname), "netmap:%s", netdev); > - pkt_nm->nm_desc = nm_open(ifname, NULL, ringid, 0); > - > - if (pkt_nm->nm_desc == NULL) { > - ODP_ERR("Error opening nm interface: %s\n", strerror(errno)); > - return -1; > - } > - > - ODP_DBG("thread %d mode %s mmap addr %p\n", > - odp_thread_id(), > - nm_params->netmap_mode == ODP_NETMAP_MODE_SW ? "SW" : "HW", > - pkt_nm->nm_desc->mem); > - > - if (nm_params->netmap_mode == ODP_NETMAP_MODE_SW) { > - pkt_nm->begin = pkt_nm->nm_desc->req.nr_rx_rings; > - pkt_nm->end = pkt_nm->begin + 1; > - pkt_nm->rxring = NETMAP_RXRING(pkt_nm->nm_desc->nifp, > - pkt_nm->nm_desc->req.nr_rx_rings); > - pkt_nm->txring = NETMAP_TXRING(pkt_nm->nm_desc->nifp, > - pkt_nm->nm_desc->req.nr_tx_rings); > - } else if (nm_params->ringid & NETMAP_HW_RING) { > - pkt_nm->begin = nm_params->ringid & NETMAP_RING_MASK; > - pkt_nm->end = pkt_nm->begin + 1; > - pkt_nm->rxring = NETMAP_RXRING(pkt_nm->nm_desc->nifp, > - pkt_nm->begin); > - pkt_nm->txring = NETMAP_TXRING(pkt_nm->nm_desc->nifp, > - pkt_nm->begin); > - } else { > - 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); > - } > - > - /* Set TX checksumming if hardware rings */ > - if (nm_params->netmap_mode == ODP_NETMAP_MODE_HW) { > - ret = nm_do_ioctl(pkt_nm, SIOCGIFFLAGS, 0); > - if (ret) > - return ret; > - if ((pkt_nm->if_flags & IFF_UP) == 0) { > - ODP_DBG("%s is down, bringing up...\n", pkt_nm->ifname); > - pkt_nm->if_flags |= IFF_UP; > - } > - if (ETH_PROMISC) { > - pkt_nm->if_flags |= IFF_PROMISC; > - nm_do_ioctl(pkt_nm, SIOCSIFFLAGS, 0); > - } > - ret = nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_SGSO); > - if (ret) > - ODP_DBG("ETHTOOL_SGSO not supported\n"); > - > - ret = nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_STSO); > - if (ret) > - ODP_DBG("ETHTOOL_STSO not supported\n"); > - /* TODO: This seems to cause the app to not receive frames > - * first time it is launched after netmap driver is inserted. > - * Should be investigated further. > - */ > - /* > - nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_SRXCSUM); > - */ > - ret = nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_STXCSUM); > - if (ret) > - ODP_DBG("ETHTOOL_STXCSUM not supported\n"); > - } > - > - /* Set up the TX access queue */ > - snprintf(qname, sizeof(qname), "%s:%s-pktio_tx_access", netdev, > - nm_params->netmap_mode == ODP_NETMAP_MODE_SW ? "SW" : "HW"); > - pkt_nm->tx_access = odp_queue_create(qname, ODP_QUEUE_TYPE_POLL, NULL); > - if (pkt_nm->tx_access == ODP_QUEUE_INVALID) { > - ODP_ERR("Error: pktio queue creation failed\n"); > - return -1; > - } > - token = odp_buffer_alloc(pool); > - if (!odp_buffer_is_valid(token)) { > - ODP_ERR("Error: token creation failed\n"); > - return -1; > - } > - > - odp_queue_enq(pkt_nm->tx_access, token); > - > - ODP_DBG("Wait for link to come up\n"); > - sleep(WAITLINK_TMO); > - ODP_DBG("Done\n"); > - > - return 0; > -} > - > -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; > - } > - > - return 0; > -} > - > -int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], > - unsigned len) > -{ > - struct netmap_ring *rxring = pkt_nm->rxring; > - int fd; > - unsigned nb_rx = 0; > - uint32_t limit, rx; > - uint32_t ringid = pkt_nm->begin; > - odp_packet_t pkt = ODP_PACKET_INVALID; > -#ifdef NETMAP_BLOCKING_IO > - struct pollfd fds[1]; > - int ret; > -#endif > - > - fd = pkt_nm->nm_desc->fd; > -#ifdef NETMAP_BLOCKING_IO > - fds[0].fd = fd; > - fds[0].events = POLLIN; > -#endif > - > - while (nb_rx < len) { > -#ifdef NETMAP_BLOCKING_IO > - ret = poll(&fds[0], 1, POLL_TMO); > - if (ret <= 0 || (fds[0].revents & POLLERR)) > - break; > -#else > - ioctl(fd, NIOCRXSYNC, NULL); > -#endif > - > - /* Find first ring not empty */ > - while (nm_ring_empty(rxring)) { > - ringid++; > - > - /* Return to scheduler if no more data to meet the > - requested amount (len) */ > - if (ringid == pkt_nm->end) { > - ODP_DBG("No more data on the wire\n"); > - break; > - } > - > - rxring = NETMAP_RXRING(pkt_nm->nm_desc->nifp, ringid); > - } > - > - limit = len - nb_rx; > - if (nm_ring_space(rxring) < limit) > - limit = nm_ring_space(rxring); > - > - ODP_DBG("receiving %d frames out of %u\n", limit, len); > - > - for (rx = 0; rx < limit; rx++) { > - struct netmap_slot *rslot; > - char *p; > - uint16_t frame_len; > - uint8_t *pkt_buf; > - uint8_t *l2_hdr; > - uint32_t cur; > - > - if (odp_likely(pkt == ODP_PACKET_INVALID)) { > - pkt = odph_packet_alloc(pkt_nm->pool); > - if (odp_unlikely(pkt == ODP_PACKET_INVALID)) > - break; > - } > - > - cur = rxring->cur; > - rslot = &rxring->slot[cur]; > - p = NETMAP_BUF(rxring, rslot->buf_idx); > - frame_len = rslot->len; > - > - rxring->head = nm_ring_next(rxring, cur); > - rxring->cur = rxring->head; > - > - pkt_buf = odp_packet_buf_addr(pkt); > - l2_hdr = pkt_buf + pkt_nm->frame_offset; > - > - if (frame_len > pkt_nm->max_frame_len) { > - ODP_ERR("RX: frame too big %u %lu!\n", > - frame_len, pkt_nm->max_frame_len); > - /* drop the frame, reuse pkt next interation */ > - continue; > - } > - if (odp_unlikely(frame_len < ODPH_ETH_LEN_MIN)) { > - if (odp_unlikely(pkt_nm->netmap_mode != > - ODP_NETMAP_MODE_SW)) { > - ODP_ERR("RX: Frame truncated: %u\n", > - (unsigned)frame_len); > - continue; > - } > - memset(l2_hdr + frame_len, 0, > - ODPH_ETH_LEN_MIN - frame_len); > - frame_len = ODPH_ETH_LEN_MIN; > - } > - > - /* For now copy the data in the mbuf, > - worry about zero-copy later */ > - memcpy(l2_hdr, p, frame_len); > - > - /* Initialize, parse and set packet header data */ > - odp_packet_init(pkt); > - odp_packet_parse(pkt, frame_len, pkt_nm->frame_offset); > - > - pkt_table[nb_rx] = pkt; > - pkt = ODP_PACKET_INVALID; > - nb_rx++; > - } > - > - if (odp_unlikely(pkt == ODP_PACKET_INVALID)) > - break; > - } > - > - if (odp_unlikely(pkt != ODP_PACKET_INVALID)) > - odp_buffer_free((odp_buffer_t) pkt); > - > - if (nb_rx) > - ODP_DBG("<=== rcvd %03u frames from netmap adapter\n", nb_rx); > - > - return nb_rx; > -} > - > -int send_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], > - unsigned len) > -{ > - struct netmap_ring *txring = pkt_nm->txring; > - int fd; > - unsigned nb_tx = 0; > - uint32_t limit, tx; > - uint32_t ringid = pkt_nm->begin; > - odp_packet_t pkt; > - odp_buffer_t token; > - > -#ifdef NETMAP_BLOCKING_IO > - struct pollfd fds[2]; > - int ret; > -#endif > - > - fd = pkt_nm->nm_desc->fd; > -#ifdef NETMAP_BLOCKING_IO > - fds[0].fd = fd; > - fds[0].events = POLLOUT; > -#endif > - > - token = odp_queue_deq(pkt_nm->tx_access); > - > - while (nb_tx < len) { > -#ifdef NETMAP_BLOCKING_IO > - ret = poll(&fds[0], 1, POLL_TMO); > - if (ret <= 0 || (fds[0].revents & POLLERR)) > - break; > -#else > - ioctl(fd, NIOCTXSYNC, NULL); > -#endif > - > - /* Find first ring not empty */ > - while (nm_ring_empty(txring)) { > - ringid++; > - > - /* Return to scheduler if no more space to meet the > - requested amount (len) */ > - if (ringid == pkt_nm->end) { > - ODP_DBG("No more space in TX rings\n"); > - break; > - } > - > - txring = NETMAP_TXRING(pkt_nm->nm_desc->nifp, ringid); > - } > - > - limit = len - nb_tx; > - if (nm_ring_space(txring) < limit) > - limit = nm_ring_space(txring); > - > - ODP_DBG("Sending %d packets out of %d to netmap %p %u\n", > - limit, len, txring, txring->cur); > - > - for (tx = 0; tx < limit; tx++) { > - struct netmap_slot *tslot; > - size_t frame_len; > - uint32_t cur; > - uint8_t *frame; > - void *txbuf; > - > - cur = txring->cur; > - tslot = &txring->slot[cur]; > - txbuf = NETMAP_BUF(txring, tslot->buf_idx); > - > - pkt = pkt_table[nb_tx]; > - frame = odp_packet_start(pkt); > - frame_len = odp_packet_get_len(pkt); > - > - memcpy(txbuf, frame, frame_len); > - tslot->len = frame_len; > - txring->head = nm_ring_next(txring, cur); > - txring->cur = txring->head; > - nb_tx++; > - } > - } > - > - odp_queue_enq(pkt_nm->tx_access, token); > - > -#ifndef NETMAP_BLOCKING_IO > - ioctl(fd, NIOCTXSYNC, NULL); > -#endif > - > - if (nb_tx) > - ODP_DBG("===> sent %03u frames to netmap adapter\n", nb_tx); > - > - for (tx = 0; tx < len; tx++) > - odph_packet_free(pkt_table[tx]); > - > - return nb_tx; > -}
diff --git a/configure.ac b/configure.ac index 220f89a..4401bde 100644 --- a/configure.ac +++ b/configure.ac @@ -63,27 +63,6 @@ AC_SUBST(SDK_INSTALL_PATH) AM_CONDITIONAL([SDK_INSTALL_PATH_], [test "x${SDK_INSTALL_PATH_}" = "x1"]) ########################################################################## -# Enable/disable netmap support -########################################################################## -AC_ARG_ENABLE([netmap], - [ --enable-netmap Enable/disable netmap], - [if test x$enableval = xyes; then - netmap_support=yes - ODP_CFLAGS="$ODP_CFLAGS -DODP_HAVE_NETMAP=1" - fi]) - -AC_ARG_WITH([netmap-path], -AC_HELP_STRING([--with-netmap-path=DIR Path to netmap libs and headers], - [(or in the default path if not specified).]), -[NETMAP_PATH=$withval netmap_support=yes -AM_CFLAGS="$AM_CFLAGS -I$NETMAP_PATH/sys" -ODP_CFLAGS="$ODP_CFLAGS -DODP_HAVE_NETMAP=1" -],[ AC_MSG_WARN([Netmap not found - continuing without netmap support]) -]) - -AM_CONDITIONAL([ODP_NETMAP_ENABLED], [test x$netmap_support = xyes ]) - -########################################################################## # Enable/disable ODP_DEBUG_PRINT ########################################################################## ODP_DEBUG=1 diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 25c82ea..bf6cd10 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -37,7 +37,6 @@ include_HEADERS = \ $(top_srcdir)/platform/linux-generic/include/api/odp_timer.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_version.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_pktio_types.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_pktio_netmap.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_pktio_socket.h subdirheadersdir = $(includedir)/helper @@ -74,7 +73,3 @@ __LIB__libodp_la_SOURCES = \ odp_time.c \ odp_timer.c -if ODP_NETMAP_ENABLED -__LIB__libodp_la_SOURCES += \ - odp_packet_netmap.c -endif diff --git a/platform/linux-generic/include/api/odp_pktio_netmap.h b/platform/linux-generic/include/api/odp_pktio_netmap.h deleted file mode 100644 index 294a13d..0000000 --- a/platform/linux-generic/include/api/odp_pktio_netmap.h +++ /dev/null @@ -1,39 +0,0 @@ - -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP packet input/output netmap - */ - -#ifndef ODP_PKTIO_NETMAP_H -#define ODP_PKTIO_NETMAP_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp_pktio_types.h> - -#define ODP_NETMAP_MODE_HW 0 /**< Netmap mode in hardware */ -#define ODP_NETMAP_MODE_SW 1 /**< Netmap mode in software */ - -/** - * Netmap parameters - */ -typedef struct { - odp_pktio_type_t type; /**< Packet IO type */ - int netmap_mode; /**< Netmap Mode */ - uint16_t ringid; /**< Ring identifiers */ -} netmap_params_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/api/odp_pktio_types.h b/platform/linux-generic/include/api/odp_pktio_types.h index 54ce459..ab8e3da 100644 --- a/platform/linux-generic/include/api/odp_pktio_types.h +++ b/platform/linux-generic/include/api/odp_pktio_types.h @@ -17,11 +17,6 @@ extern "C" { #endif -/* We should ensure that future enum values will never overlap, otherwise - * applications that want netmap suport might get in trouble if the odp lib - * was not built with netmap support and there are more types define below - */ - /** * Packet IO types */ @@ -29,13 +24,9 @@ typedef enum { ODP_PKTIO_TYPE_SOCKET_BASIC = 0x1, ODP_PKTIO_TYPE_SOCKET_MMSG, ODP_PKTIO_TYPE_SOCKET_MMAP, - ODP_PKTIO_TYPE_NETMAP, } odp_pktio_type_t; #include <odp_pktio_socket.h> -#ifdef ODP_HAVE_NETMAP -#include <odp_pktio_netmap.h> -#endif /** * Packet IO parameters @@ -43,9 +34,6 @@ typedef enum { typedef union odp_pktio_params_t { odp_pktio_type_t type; /**< Packet IO type */ socket_params_t sock_params; /**< Socket parameter */ -#ifdef ODP_HAVE_NETMAP - netmap_params_t nm_params; -#endif } odp_pktio_params_t; #ifdef __cplusplus diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 881cc5f..7ba72df 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -20,9 +20,6 @@ extern "C" { #include <odp_spinlock.h> #include <odp_packet_socket.h> -#ifdef ODP_HAVE_NETMAP -#include <odp_packet_netmap.h> -#endif struct pktio_entry { odp_spinlock_t lock; /**< entry spinlock */ @@ -32,9 +29,6 @@ struct pktio_entry { odp_pktio_params_t params; /**< pktio parameters */ pkt_sock_t pkt_sock; /**< using socket API for IO */ pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap API for IO */ -#ifdef ODP_HAVE_NETMAP - pkt_netmap_t pkt_nm; /**< using netmap API for IO */ -#endif }; typedef union { diff --git a/platform/linux-generic/include/odp_packet_netmap.h b/platform/linux-generic/include/odp_packet_netmap.h deleted file mode 100644 index 1ab50d0..0000000 --- a/platform/linux-generic/include/odp_packet_netmap.h +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef ODP_PACKET_NETMAP_H -#define ODP_PACKET_NETMAP_H - -#include <stdint.h> - -#include <net/if.h> -#include <net/netmap.h> -#include <net/netmap_user.h> - -#include <odp_align.h> -#include <odp_debug.h> -#include <odp_buffer_pool.h> -#include <odp_packet.h> - -#include <odp_pktio_netmap.h> - -#define ODP_NETMAP_MODE_HW 0 -#define ODP_NETMAP_MODE_SW 1 - -#define NETMAP_BLOCKING_IO - -/** 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' */ - int netmap_mode; - 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 */ - uint32_t if_flags; - char ifname[32]; -} pkt_netmap_t; - -/** - * Configure an interface to work in netmap mode - */ -int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const char *netdev, - odp_buffer_pool_t pool, netmap_params_t *nm_params); - -/** - * Switch interface from netmap mode to normal mode - */ -int close_pkt_netmap(pkt_netmap_t * const pkt_nm); - -/** - * Receive packets using netmap - */ -int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], - unsigned len); - -/** - * Send packets using netmap - */ -int send_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], - unsigned len); -#endif diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 06d8935..6ef87df 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -13,9 +13,6 @@ #include <odp_spinlock.h> #include <odp_shared_memory.h> #include <odp_packet_socket.h> -#ifdef ODP_HAVE_NETMAP -#include <odp_packet_netmap.h> -#endif #include <odp_hints.h> #include <odp_config.h> #include <odp_queue_internal.h> @@ -23,9 +20,6 @@ #include <odp_debug.h> #include <odp_pktio_socket.h> -#ifdef ODP_HAVE_NETMAP -#include <odp_pktio_netmap.h> -#endif #include <string.h> @@ -127,11 +121,6 @@ static void init_pktio_entry(pktio_entry_t *entry, odp_pktio_params_t *params) memset(&entry->s.pkt_sock_mmap, 0, sizeof(entry->s.pkt_sock_mmap)); break; -#ifdef ODP_HAVE_NETMAP - case ODP_PKTIO_TYPE_NETMAP: - memset(&entry->s.pkt_nm, 0, sizeof(entry->s.pkt_nm)); - break; -#endif default: ODP_ERR("Packet I/O type not supported. Please recompile\n"); break; @@ -192,11 +181,6 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, case ODP_PKTIO_TYPE_SOCKET_MMAP: ODP_DBG("Allocating socket pktio\n"); break; -#ifdef ODP_HAVE_NETMAP - case ODP_PKTIO_TYPE_NETMAP: - ODP_DBG("Allocating netmap pktio\n"); - break; -#endif default: ODP_ERR("Invalid pktio type: %02x\n", params->type); return ODP_PKTIO_INVALID; @@ -230,18 +214,6 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, id = ODP_PKTIO_INVALID; } break; -#ifdef ODP_HAVE_NETMAP - case ODP_PKTIO_TYPE_NETMAP: - - res = setup_pkt_netmap(&pktio_entry->s.pkt_nm, dev, - pool, ¶ms->nm_params); - if (res == -1) { - close_pkt_netmap(&pktio_entry->s.pkt_nm); - free_pktio_entry(id); - id = ODP_PKTIO_INVALID; - } - break; -#endif default: free_pktio_entry(id); id = ODP_PKTIO_INVALID; @@ -272,11 +244,6 @@ int odp_pktio_close(odp_pktio_t id) case ODP_PKTIO_TYPE_SOCKET_MMAP: res = close_pkt_sock_mmap(&entry->s.pkt_sock_mmap); break; -#ifdef ODP_HAVE_NETMAP - case ODP_PKTIO_TYPE_NETMAP: - res = close_pkt_netmap(&entry->s.pkt_nm); - break; -#endif default: break; res |= free_pktio_entry(id); @@ -323,11 +290,6 @@ int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) pkts = recv_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap, pkt_table, len); break; -#ifdef ODP_HAVE_NETMAP - case ODP_PKTIO_TYPE_NETMAP: - pkts = recv_pkt_netmap(&pktio_entry->s.pkt_nm, pkt_table, len); - break; -#endif default: pkts = -1; break; @@ -365,12 +327,6 @@ int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) pkts = send_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap, pkt_table, len); break; -#ifdef ODP_HAVE_NETMAP - case ODP_PKTIO_TYPE_NETMAP: - pkts = send_pkt_netmap(&pktio_entry->s.pkt_nm, - pkt_table, len); - break; -#endif default: pkts = -1; } diff --git a/platform/linux-generic/odp_packet_netmap.c b/platform/linux-generic/odp_packet_netmap.c deleted file mode 100644 index 524492d..0000000 --- a/platform/linux-generic/odp_packet_netmap.c +++ /dev/null @@ -1,453 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * Copyright (c) 2013, Nokia Solutions and Networks - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * NETMAP I/O code inspired by the pkt-gen example application in netmap by: - * Copyright (C) 2011-2014 Matteo Landi, Luigi Rizzo. All rights reserved. - * Copyright (C) 2013-2014 Universita` di Pisa. All rights reserved. - */ - -#define _GNU_SOURCE -#include <stdio.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <sys/ioctl.h> -#include <sys/mman.h> -#include <poll.h> -#include <unistd.h> -#include <fcntl.h> -#include <string.h> -#include <stdlib.h> - -#include <linux/ethtool.h> -#include <linux/sockios.h> - -#include <odp_packet_internal.h> -#include <odp_hints.h> -#include <odp_thread.h> - -#include <odph_eth.h> -#include <odph_ip.h> -#include <odph_packet.h> - -#define NETMAP_WITH_LIBS -#include <odp_packet_netmap.h> - -/** Eth buffer start offset from u32-aligned address to make sure the following - * header (e.g. IP) starts at a 32-bit aligned address. - */ -#define ETHBUF_OFFSET (ODP_ALIGN_ROUNDUP(ODPH_ETHHDR_LEN, sizeof(uint32_t)) \ - - ODPH_ETHHDR_LEN) - -/** Round up buffer address to get a properly aliged eth buffer, i.e. aligned - * so that the next header always starts at a 32bit aligned address. - */ -#define ETHBUF_ALIGN(buf_ptr) ((uint8_t *)ODP_ALIGN_ROUNDUP_PTR((buf_ptr), \ - sizeof(uint32_t)) + ETHBUF_OFFSET) - -#define ETH_PROMISC 1 /* TODO: maybe this should be exported to the user */ -#define WAITLINK_TMO 2 -#define POLL_TMO 50 - -static int nm_do_ioctl(pkt_netmap_t * const pkt_nm, unsigned long cmd, - int subcmd) -{ - struct ethtool_value eval; - struct ifreq ifr; - int error; - int fd; - - fd = socket(AF_INET, SOCK_DGRAM, 0); - if (fd < 0) { - ODP_ERR("Error: cannot get device control socket\n"); - return -1; - } - - memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, pkt_nm->ifname, sizeof(ifr.ifr_name)); - - switch (cmd) { - case SIOCSIFFLAGS: - ifr.ifr_flags = pkt_nm->if_flags & 0xffff; - break; - case SIOCETHTOOL: - eval.cmd = subcmd; - eval.data = 0; - ifr.ifr_data = (caddr_t)&eval; - break; - default: - break; - } - error = ioctl(fd, cmd, &ifr); - if (error) - goto done; - - switch (cmd) { - case SIOCGIFFLAGS: - pkt_nm->if_flags = (ifr.ifr_flags << 16) | - (0xffff & ifr.ifr_flags); - ODP_DBG("flags are 0x%x\n", pkt_nm->if_flags); - break; - default: - break; - } -done: - close(fd); - if (error) - ODP_ERR("ioctl err %d %lu: %s\n", error, cmd, strerror(errno)); - - return error; -} - -int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const char *netdev, - odp_buffer_pool_t pool, netmap_params_t *nm_params) -{ - char qname[ODP_QUEUE_NAME_LEN]; - char ifname[32]; - odp_packet_t pkt; - odp_buffer_t token; - uint8_t *pkt_buf; - uint16_t ringid; - uint8_t *l2_hdr; - int ret; - - if (pool == ODP_BUFFER_POOL_INVALID) - return -1; - pkt_nm->pool = pool; - - pkt = odph_packet_alloc(pool); - if (!odph_packet_is_valid(pkt)) - return -1; - - pkt_buf = odp_packet_buf_addr(pkt); - l2_hdr = ETHBUF_ALIGN(pkt_buf); - /* Store eth buffer offset for buffers from this pool */ - pkt_nm->frame_offset = (uintptr_t)l2_hdr - (uintptr_t)pkt_buf; - /* pkt buffer size */ - pkt_nm->buf_size = odph_packet_buf_size(pkt); - /* max frame len taking into account the l2-offset */ - pkt_nm->max_frame_len = pkt_nm->buf_size - pkt_nm->frame_offset; - /* save netmap_mode for later use */ - pkt_nm->netmap_mode = nm_params->netmap_mode; - - odph_packet_free(pkt); - - if (nm_params->netmap_mode == ODP_NETMAP_MODE_SW) - ringid = NETMAP_SW_RING; - else - ringid = nm_params->ringid; - - strncpy(pkt_nm->ifname, netdev, sizeof(pkt_nm->ifname)); - snprintf(ifname, sizeof(ifname), "netmap:%s", netdev); - pkt_nm->nm_desc = nm_open(ifname, NULL, ringid, 0); - - if (pkt_nm->nm_desc == NULL) { - ODP_ERR("Error opening nm interface: %s\n", strerror(errno)); - return -1; - } - - ODP_DBG("thread %d mode %s mmap addr %p\n", - odp_thread_id(), - nm_params->netmap_mode == ODP_NETMAP_MODE_SW ? "SW" : "HW", - pkt_nm->nm_desc->mem); - - if (nm_params->netmap_mode == ODP_NETMAP_MODE_SW) { - pkt_nm->begin = pkt_nm->nm_desc->req.nr_rx_rings; - pkt_nm->end = pkt_nm->begin + 1; - pkt_nm->rxring = NETMAP_RXRING(pkt_nm->nm_desc->nifp, - pkt_nm->nm_desc->req.nr_rx_rings); - pkt_nm->txring = NETMAP_TXRING(pkt_nm->nm_desc->nifp, - pkt_nm->nm_desc->req.nr_tx_rings); - } else if (nm_params->ringid & NETMAP_HW_RING) { - pkt_nm->begin = nm_params->ringid & NETMAP_RING_MASK; - pkt_nm->end = pkt_nm->begin + 1; - pkt_nm->rxring = NETMAP_RXRING(pkt_nm->nm_desc->nifp, - pkt_nm->begin); - pkt_nm->txring = NETMAP_TXRING(pkt_nm->nm_desc->nifp, - pkt_nm->begin); - } else { - 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); - } - - /* Set TX checksumming if hardware rings */ - if (nm_params->netmap_mode == ODP_NETMAP_MODE_HW) { - ret = nm_do_ioctl(pkt_nm, SIOCGIFFLAGS, 0); - if (ret) - return ret; - if ((pkt_nm->if_flags & IFF_UP) == 0) { - ODP_DBG("%s is down, bringing up...\n", pkt_nm->ifname); - pkt_nm->if_flags |= IFF_UP; - } - if (ETH_PROMISC) { - pkt_nm->if_flags |= IFF_PROMISC; - nm_do_ioctl(pkt_nm, SIOCSIFFLAGS, 0); - } - ret = nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_SGSO); - if (ret) - ODP_DBG("ETHTOOL_SGSO not supported\n"); - - ret = nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_STSO); - if (ret) - ODP_DBG("ETHTOOL_STSO not supported\n"); - /* TODO: This seems to cause the app to not receive frames - * first time it is launched after netmap driver is inserted. - * Should be investigated further. - */ - /* - nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_SRXCSUM); - */ - ret = nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_STXCSUM); - if (ret) - ODP_DBG("ETHTOOL_STXCSUM not supported\n"); - } - - /* Set up the TX access queue */ - snprintf(qname, sizeof(qname), "%s:%s-pktio_tx_access", netdev, - nm_params->netmap_mode == ODP_NETMAP_MODE_SW ? "SW" : "HW"); - pkt_nm->tx_access = odp_queue_create(qname, ODP_QUEUE_TYPE_POLL, NULL); - if (pkt_nm->tx_access == ODP_QUEUE_INVALID) { - ODP_ERR("Error: pktio queue creation failed\n"); - return -1; - } - token = odp_buffer_alloc(pool); - if (!odp_buffer_is_valid(token)) { - ODP_ERR("Error: token creation failed\n"); - return -1; - } - - odp_queue_enq(pkt_nm->tx_access, token); - - ODP_DBG("Wait for link to come up\n"); - sleep(WAITLINK_TMO); - ODP_DBG("Done\n"); - - return 0; -} - -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; - } - - return 0; -} - -int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], - unsigned len) -{ - struct netmap_ring *rxring = pkt_nm->rxring; - int fd; - unsigned nb_rx = 0; - uint32_t limit, rx; - uint32_t ringid = pkt_nm->begin; - odp_packet_t pkt = ODP_PACKET_INVALID; -#ifdef NETMAP_BLOCKING_IO - struct pollfd fds[1]; - int ret; -#endif - - fd = pkt_nm->nm_desc->fd; -#ifdef NETMAP_BLOCKING_IO - fds[0].fd = fd; - fds[0].events = POLLIN; -#endif - - while (nb_rx < len) { -#ifdef NETMAP_BLOCKING_IO - ret = poll(&fds[0], 1, POLL_TMO); - if (ret <= 0 || (fds[0].revents & POLLERR)) - break; -#else - ioctl(fd, NIOCRXSYNC, NULL); -#endif - - /* Find first ring not empty */ - while (nm_ring_empty(rxring)) { - ringid++; - - /* Return to scheduler if no more data to meet the - requested amount (len) */ - if (ringid == pkt_nm->end) { - ODP_DBG("No more data on the wire\n"); - break; - } - - rxring = NETMAP_RXRING(pkt_nm->nm_desc->nifp, ringid); - } - - limit = len - nb_rx; - if (nm_ring_space(rxring) < limit) - limit = nm_ring_space(rxring); - - ODP_DBG("receiving %d frames out of %u\n", limit, len); - - for (rx = 0; rx < limit; rx++) { - struct netmap_slot *rslot; - char *p; - uint16_t frame_len; - uint8_t *pkt_buf; - uint8_t *l2_hdr; - uint32_t cur; - - if (odp_likely(pkt == ODP_PACKET_INVALID)) { - pkt = odph_packet_alloc(pkt_nm->pool); - if (odp_unlikely(pkt == ODP_PACKET_INVALID)) - break; - } - - cur = rxring->cur; - rslot = &rxring->slot[cur]; - p = NETMAP_BUF(rxring, rslot->buf_idx); - frame_len = rslot->len; - - rxring->head = nm_ring_next(rxring, cur); - rxring->cur = rxring->head; - - pkt_buf = odp_packet_buf_addr(pkt); - l2_hdr = pkt_buf + pkt_nm->frame_offset; - - if (frame_len > pkt_nm->max_frame_len) { - ODP_ERR("RX: frame too big %u %lu!\n", - frame_len, pkt_nm->max_frame_len); - /* drop the frame, reuse pkt next interation */ - continue; - } - if (odp_unlikely(frame_len < ODPH_ETH_LEN_MIN)) { - if (odp_unlikely(pkt_nm->netmap_mode != - ODP_NETMAP_MODE_SW)) { - ODP_ERR("RX: Frame truncated: %u\n", - (unsigned)frame_len); - continue; - } - memset(l2_hdr + frame_len, 0, - ODPH_ETH_LEN_MIN - frame_len); - frame_len = ODPH_ETH_LEN_MIN; - } - - /* For now copy the data in the mbuf, - worry about zero-copy later */ - memcpy(l2_hdr, p, frame_len); - - /* Initialize, parse and set packet header data */ - odp_packet_init(pkt); - odp_packet_parse(pkt, frame_len, pkt_nm->frame_offset); - - pkt_table[nb_rx] = pkt; - pkt = ODP_PACKET_INVALID; - nb_rx++; - } - - if (odp_unlikely(pkt == ODP_PACKET_INVALID)) - break; - } - - if (odp_unlikely(pkt != ODP_PACKET_INVALID)) - odp_buffer_free((odp_buffer_t) pkt); - - if (nb_rx) - ODP_DBG("<=== rcvd %03u frames from netmap adapter\n", nb_rx); - - return nb_rx; -} - -int send_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], - unsigned len) -{ - struct netmap_ring *txring = pkt_nm->txring; - int fd; - unsigned nb_tx = 0; - uint32_t limit, tx; - uint32_t ringid = pkt_nm->begin; - odp_packet_t pkt; - odp_buffer_t token; - -#ifdef NETMAP_BLOCKING_IO - struct pollfd fds[2]; - int ret; -#endif - - fd = pkt_nm->nm_desc->fd; -#ifdef NETMAP_BLOCKING_IO - fds[0].fd = fd; - fds[0].events = POLLOUT; -#endif - - token = odp_queue_deq(pkt_nm->tx_access); - - while (nb_tx < len) { -#ifdef NETMAP_BLOCKING_IO - ret = poll(&fds[0], 1, POLL_TMO); - if (ret <= 0 || (fds[0].revents & POLLERR)) - break; -#else - ioctl(fd, NIOCTXSYNC, NULL); -#endif - - /* Find first ring not empty */ - while (nm_ring_empty(txring)) { - ringid++; - - /* Return to scheduler if no more space to meet the - requested amount (len) */ - if (ringid == pkt_nm->end) { - ODP_DBG("No more space in TX rings\n"); - break; - } - - txring = NETMAP_TXRING(pkt_nm->nm_desc->nifp, ringid); - } - - limit = len - nb_tx; - if (nm_ring_space(txring) < limit) - limit = nm_ring_space(txring); - - ODP_DBG("Sending %d packets out of %d to netmap %p %u\n", - limit, len, txring, txring->cur); - - for (tx = 0; tx < limit; tx++) { - struct netmap_slot *tslot; - size_t frame_len; - uint32_t cur; - uint8_t *frame; - void *txbuf; - - cur = txring->cur; - tslot = &txring->slot[cur]; - txbuf = NETMAP_BUF(txring, tslot->buf_idx); - - pkt = pkt_table[nb_tx]; - frame = odp_packet_start(pkt); - frame_len = odp_packet_get_len(pkt); - - memcpy(txbuf, frame, frame_len); - tslot->len = frame_len; - txring->head = nm_ring_next(txring, cur); - txring->cur = txring->head; - nb_tx++; - } - } - - odp_queue_enq(pkt_nm->tx_access, token); - -#ifndef NETMAP_BLOCKING_IO - ioctl(fd, NIOCTXSYNC, NULL); -#endif - - if (nb_tx) - ODP_DBG("===> sent %03u frames to netmap adapter\n", nb_tx); - - for (tx = 0; tx < len; tx++) - odph_packet_free(pkt_table[tx]); - - return nb_tx; -}
Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org> --- configure.ac | 21 - platform/linux-generic/Makefile.am | 5 - .../linux-generic/include/api/odp_pktio_netmap.h | 39 -- .../linux-generic/include/api/odp_pktio_types.h | 12 - .../linux-generic/include/odp_packet_io_internal.h | 6 - platform/linux-generic/include/odp_packet_netmap.h | 67 --- platform/linux-generic/odp_packet_io.c | 44 -- platform/linux-generic/odp_packet_netmap.c | 453 --------------------- 8 files changed, 647 deletions(-) delete mode 100644 platform/linux-generic/include/api/odp_pktio_netmap.h delete mode 100644 platform/linux-generic/include/odp_packet_netmap.h delete mode 100644 platform/linux-generic/odp_packet_netmap.c