From patchwork Tue Nov 11 17:35:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 40602 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BAD62206A5 for ; Tue, 11 Nov 2014 17:36:31 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf5744010lbj.11 for ; Tue, 11 Nov 2014 09:36:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=aOSYq2Gtpy6lpFwOqwUxiuaY2uy6f9ldUnRjG0xmm+w=; b=jXsgC/gEd7mD6QU9unWsZX3k842xkkPsI5TgXxbMMY7csn38BnjtPHikQXfYZ0A85k W/lqx2KUGJOhgNS+NTon6GLl3UCLrHwkN7IXy9ODilxA41WE6d97vHJ80QEISENQp8od 8n/mHVuyY6aINx3PYicmo0e89D+CVyyzNyNF4ONPAjBPGcECBRplu2k565dsbDImhRAC TLw3WSo61g9Z3jaCBp+q5B1zrir4tpI3FLjTdliyHVhoYJWUhMXNadmuPjb8l1FxmdSC +1HlLyLaR5ggEXJnV3bcapDPU18Kq414WJfst311zWd1ufTXY303tJT/EkVAshbYdBnx 2BYQ== X-Gm-Message-State: ALoCoQk3czL7i9U6/t9wXlBKqXDpyz9liu3Ei1ZpA32hF0EnqqLZqDheOqp9zJk9Mevaf6IrovHB X-Received: by 10.112.151.38 with SMTP id un6mr2917729lbb.0.1415727390687; Tue, 11 Nov 2014 09:36:30 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.68 with SMTP id p4ls614266laa.52.gmail; Tue, 11 Nov 2014 09:36:30 -0800 (PST) X-Received: by 10.152.9.225 with SMTP id d1mr11663189lab.38.1415727390363; Tue, 11 Nov 2014 09:36:30 -0800 (PST) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id jl10si32129809lbc.96.2014.11.11.09.36.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 09:36:30 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gm9so9843134lab.19 for ; Tue, 11 Nov 2014 09:36:30 -0800 (PST) X-Received: by 10.152.120.199 with SMTP id le7mr36786846lab.67.1415727390082; Tue, 11 Nov 2014 09:36:30 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp295849lbc; Tue, 11 Nov 2014 09:36:29 -0800 (PST) X-Received: by 10.224.136.130 with SMTP id r2mr54455800qat.80.1415727388554; Tue, 11 Nov 2014 09:36:28 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id k4si1937828qan.97.2014.11.11.09.36.25 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 11 Nov 2014 09:36:28 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XoFMf-0004BF-3G; Tue, 11 Nov 2014 17:36:25 +0000 Received: from mail-lb0-f179.google.com ([209.85.217.179]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XoFMT-0004Ae-GE for lng-odp@lists.linaro.org; Tue, 11 Nov 2014 17:36:13 +0000 Received: by mail-lb0-f179.google.com with SMTP id l4so7948609lbv.24 for ; Tue, 11 Nov 2014 09:36:08 -0800 (PST) X-Received: by 10.112.166.101 with SMTP id zf5mr38510804lbb.42.1415727367966; Tue, 11 Nov 2014 09:36:07 -0800 (PST) Received: from cipriantemp.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id ql6sm6122819lbb.31.2014.11.11.09.36.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 09:36:07 -0800 (PST) From: Ciprian Barbu To: lng-odp@lists.linaro.org Date: Tue, 11 Nov 2014 19:35:56 +0200 Message-Id: <1415727359-22406-2-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1415727359-22406-1-git-send-email-ciprian.barbu@linaro.org> References: <1415727359-22406-1-git-send-email-ciprian.barbu@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH NETMAP 1/4] Update to netmap_v11.1 X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ciprian.barbu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Ciprian Barbu Reviewed-by: Mike Holmes --- 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= + ./configure --kernel-sources= + make 2.1.2 Building netmap for kernel built from sources cd LINUX - make KSRC= + ./configure --kernel-dir= + 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= + ./configure --with-sdk-install-path= 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;