From patchwork Mon Mar 2 18:46:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 45303 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9F415214B5 for ; Mon, 2 Mar 2015 18:47:48 +0000 (UTC) Received: by lbiv13 with SMTP id v13sf8301631lbi.1 for ; Mon, 02 Mar 2015 10:47:47 -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:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=keHPS7ld1xuA4GAUhzvQmWWDdzFtBU8pHJZkm8H86kQ=; b=dyb5Dx+Nc3+tAc8bulFvoO+sQza9qc9x02hBWqV1XOCFT3jrR5jzS/n8N6wgm0OsVi v6z3i0TmiH80wJ3LPFasDlIoP1I2B7mSRnPoaPVUEFe7GRUFJmR3/K/DfNjxQUK7xB4u Ai7tSaMrm7mQfM1NWHaTnhOy4ChRVZTmc6LelThY0ztVijwi6HRFLOosJW19iXEc/n/C d8bmpZDj5PMTRMPAhpTP7PorBy1Te0XVwXWbXu/blPvCqaYMorDiP3GVRjBnpb1kuhcH Qax6HsMFk90D7IMMwKMHiwBi9j+MCFHSYUCg5dXm7YP9ueEqrA/wMO0ZfzsBPQkQhnT3 tfHg== X-Gm-Message-State: ALoCoQl+V5VNyhmKLcXAdkVsuDaI0jIowCmlEmHQnN6sqpANepmZU72eyucJnGCOEmqbL/PIlBBE X-Received: by 10.112.77.101 with SMTP id r5mr4109124lbw.4.1425322067611; Mon, 02 Mar 2015 10:47:47 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.135 with SMTP id t7ls452259lag.45.gmail; Mon, 02 Mar 2015 10:47:47 -0800 (PST) X-Received: by 10.152.22.200 with SMTP id g8mr23245080laf.96.1425322067459; Mon, 02 Mar 2015 10:47:47 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id ai6si9530956lbc.7.2015.03.02.10.47.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Mar 2015 10:47:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by lbdu10 with SMTP id u10so32067105lbd.7 for ; Mon, 02 Mar 2015 10:47:47 -0800 (PST) X-Received: by 10.152.22.67 with SMTP id b3mr25122374laf.117.1425322067363; Mon, 02 Mar 2015 10:47:47 -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.35.133 with SMTP id h5csp90058lbj; Mon, 2 Mar 2015 10:47:46 -0800 (PST) X-Received: by 10.140.48.133 with SMTP id o5mr52278233qga.8.1425322066026; Mon, 02 Mar 2015 10:47:46 -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 m1si5630791qcf.22.2015.03.02.10.47.43 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Mar 2015 10:47:46 -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 1YSVNU-0008Dv-9C; Mon, 02 Mar 2015 18:47:40 +0000 Received: from mail-la0-f41.google.com ([209.85.215.41]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YSVN6-00089p-2a for lng-odp@lists.linaro.org; Mon, 02 Mar 2015 18:47:16 +0000 Received: by labgf13 with SMTP id gf13so7787093lab.10 for ; Mon, 02 Mar 2015 10:47:09 -0800 (PST) X-Received: by 10.152.120.134 with SMTP id lc6mr5782725lab.72.1425322029825; Mon, 02 Mar 2015 10:47:09 -0800 (PST) Received: from cipriantemp.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id i13sm2696725lab.38.2015.03.02.10.47.08 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Mar 2015 10:47:08 -0800 (PST) From: Ciprian Barbu To: lng-odp@lists.linaro.org Date: Mon, 2 Mar 2015 20:46:49 +0200 Message-Id: <1425322017-14636-5-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1425322017-14636-1-git-send-email-ciprian.barbu@linaro.org> References: <1425322017-14636-1-git-send-email-ciprian.barbu@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH NETMAP 04/12] linux-netmap: pktio: cosmetic changes 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.217.176 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 --- platform/linux-netmap/include/odp_packet_netmap.h | 10 ++-- platform/linux-netmap/odp_packet_netmap.c | 64 +++++++++++------------ 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/platform/linux-netmap/include/odp_packet_netmap.h b/platform/linux-netmap/include/odp_packet_netmap.h index 22f89f0..161b968 100644 --- a/platform/linux-netmap/include/odp_packet_netmap.h +++ b/platform/linux-netmap/include/odp_packet_netmap.h @@ -27,15 +27,15 @@ /** 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 *nm_desc; + size_t max_frame_len; /* buf_size - sizeof(pkt_hdr) */ + size_t frame_offset; /* 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; uint32_t end; struct netmap_ring *rxring; struct netmap_ring *txring; - odp_queue_t tx_access; /* Used for exclusive access to send packets */ + odp_queue_t tx_access; /* exclusive access to send packets */ uint32_t if_flags; char ifname[32]; } pkt_netmap_t; diff --git a/platform/linux-netmap/odp_packet_netmap.c b/platform/linux-netmap/odp_packet_netmap.c index 47a15cb..6d5228d 100644 --- a/platform/linux-netmap/odp_packet_netmap.c +++ b/platform/linux-netmap/odp_packet_netmap.c @@ -91,7 +91,9 @@ static int nm_do_ioctl(pkt_netmap_t * const pkt_nm, unsigned long 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); + ODP_DBG("[%04d] flags are 0x%x\n", + odp_thread_id(), + pkt_nm->if_flags); break; default: break; @@ -107,7 +109,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; @@ -134,27 +136,29 @@ int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const char *netdev, strncpy(pkt_nm->ifname, netdev, sizeof(pkt_nm->ifname)); snprintf(ifname, sizeof(ifname), "netmap:%s", netdev); - pkt_nm->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_DBG("[%04d] 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) return ret; if ((pkt_nm->if_flags & IFF_UP) == 0) { - ODP_DBG("%s is down, bringing up...\n", pkt_nm->ifname); + ODP_DBG("[%04d] %s is down, bringing up...\n", + odp_thread_id(), + pkt_nm->ifname); pkt_nm->if_flags |= IFF_UP; } if (ETH_PROMISC) { @@ -163,11 +167,13 @@ int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const char *netdev, } ret = nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_SGSO); if (ret) - ODP_DBG("ETHTOOL_SGSO not supported\n"); + ODP_DBG("[%04d] ETHTOOL_SGSO not supported\n", + odp_thread_id()); ret = nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_STSO); if (ret) - ODP_DBG("ETHTOOL_STSO not supported\n"); + ODP_DBG("[%04d] ETHTOOL_STSO not supported\n", + odp_thread_id()); /* 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. @@ -177,20 +183,23 @@ int setup_pkt_netmap(pkt_netmap_t * const pkt_nm, const char *netdev, */ ret = nm_do_ioctl(pkt_nm, SIOCETHTOOL, ETHTOOL_STXCSUM); if (ret) - ODP_DBG("ETHTOOL_STXCSUM not supported\n"); + ODP_DBG("[%04d] ETHTOOL_STXCSUM not supported\n", + odp_thread_id()); - ODP_DBG("Wait for link to come up\n"); + ODP_DBG("[%04d] Wait for link to come up\n", + odp_thread_id()); sleep(WAITLINK_TMO); - ODP_DBG("Done\n"); + ODP_DBG("[%04d] Done\n", + odp_thread_id()); 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; + if (pkt_nm->desc != NULL) { + nm_close(pkt_nm->desc); + pkt_nm->desc = NULL; } return 0; @@ -210,7 +219,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 +245,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); } if (ringid == pkt_nm->end) @@ -246,8 +255,6 @@ int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], 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; @@ -305,9 +312,6 @@ int recv_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], 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; } @@ -326,7 +330,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; @@ -352,7 +356,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); } if (ringid == pkt_nm->end) @@ -362,9 +366,6 @@ int send_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], 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; @@ -392,9 +393,6 @@ int send_pkt_netmap(pkt_netmap_t * const pkt_nm, odp_packet_t pkt_table[], 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]);