From patchwork Tue Dec 9 17:44:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 42067 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D777D244AC for ; Tue, 9 Dec 2014 17:45:34 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id l18sf819541wgh.6 for ; Tue, 09 Dec 2014 09:45:34 -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=1mjA7kPAkNtKxGszvLY6CYfUGez3XDRnAJp4tr9/Zm4=; b=gwGesZiMOzoNiGHvll6OQu8vkfvnJuXPKRJqyXvUj44PEK8ij6GpKu9c/cD80MmZQ/ dbmr1p6BXHIxmLAT4YE+3Vjl0+pY4OMp6E7I2WjJweoeaGJjH/OPGK643oYwlHixn2pW oeoOo/WQdXYjn5ujuTAOhCD695TPzDMfw2j2L29jM+mjAvR0V5dFj6Ux5l2e/KPve6wM Xg6jrlGhy154b167hKGQjGJazHxGM7ZqPElVt1r3hclfcK37AXc80UTpHT+SH05XcyC3 D21pJ068tuFOuIjUxJwPNku3tnH//UHa9ACIfWVKexIoibYX8sx9TRlFki9UTARl8FHS Jg6g== X-Gm-Message-State: ALoCoQmT05TNMPshj/U/l3pNYQsbpFQ0X1o2Ldw/kSHd9b+Hor2DsrVmDHOmeGy7UPxKL9hiZT9y X-Received: by 10.152.10.233 with SMTP id l9mr7492093lab.0.1418147134043; Tue, 09 Dec 2014 09:45:34 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.202 with SMTP id e10ls61536lae.86.gmail; Tue, 09 Dec 2014 09:45:33 -0800 (PST) X-Received: by 10.112.151.104 with SMTP id up8mr22599291lbb.21.1418147133822; Tue, 09 Dec 2014 09:45:33 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id wg10si1972070lbb.118.2014.12.09.09.45.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 09:45:33 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id f15so972572lbj.41 for ; Tue, 09 Dec 2014 09:45:33 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr22699178lbc.23.1418147133726; Tue, 09 Dec 2014 09:45:33 -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 ew9csp786936lbc; Tue, 9 Dec 2014 09:45:32 -0800 (PST) X-Received: by 10.229.105.196 with SMTP id u4mr7879299qco.27.1418147131738; Tue, 09 Dec 2014 09:45:31 -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 t102si1846423qgd.127.2014.12.09.09.45.30 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Dec 2014 09:45:31 -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 1XyOqn-0005Ui-F1; Tue, 09 Dec 2014 17:45:29 +0000 Received: from mail-la0-f44.google.com ([209.85.215.44]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XyOqS-0005QN-0a for lng-odp@lists.linaro.org; Tue, 09 Dec 2014 17:45:08 +0000 Received: by mail-la0-f44.google.com with SMTP id gd6so959617lab.31 for ; Tue, 09 Dec 2014 09:45:02 -0800 (PST) X-Received: by 10.112.135.229 with SMTP id pv5mr22934458lbb.52.1418147102490; Tue, 09 Dec 2014 09:45:02 -0800 (PST) Received: from localhost.localdomain (ppp91-76-163-205.pppoe.mtu-net.ru. [91.76.163.205]) by mx.google.com with ESMTPSA id m9sm10385laa.28.2014.12.09.09.45.01 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 09:45:01 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 9 Dec 2014 20:44:48 +0300 Message-Id: <1418147090-29055-5-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 In-Reply-To: <1418147090-29055-1-git-send-email-maxim.uvarov@linaro.org> References: <1418147090-29055-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv8 4/6] linux-generic: odp_pktio_open loop support 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: maxim.uvarov@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.182 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 Implement pktio device loop device suitable for testing. Note: sometimes lo0 can not be used in case if you need change / get mac, promisc, mtu for specific device. Environment variable is added to bind loop to specific device, example: export ODP_PKTIO_LOOPDEV=eth0 Signed-off-by: Maxim Uvarov Reviewed-by: Ciprian Barbu --- platform/linux-generic/odp_packet_io.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 541072b..3b7869f 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -22,6 +22,7 @@ #include #include #include +#include typedef struct { pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES]; @@ -160,6 +161,37 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool) pktio_entry_t *pktio_entry; int res; int fanout = 1; + char loop[IFNAMSIZ] = {0}; + char *loop_hint; + + if (strlen(dev) >= IFNAMSIZ) { + /* ioctl names limitation */ + ODP_ERR("pktio name %s is too big, limit is %d bytes\n", + dev, IFNAMSIZ); + return ODP_PKTIO_INVALID; + } + + if (!strcmp(dev, "loop")) { + /* If hint with ODP_PKTIO_LOOPDEV is provided, use hint, + * if not try to find usable device. + */ + loop_hint = getenv("ODP_PKTIO_LOOPDEV"); + if (!loop_hint || (strlen(loop_hint) == 0)) { + ODP_ERR("Set loop with ODP_PKTIO_LOOPDEV=ethX\n"); + return ODP_PKTIO_INVALID; + } + + if (strlen(loop_hint) >= IFNAMSIZ) { + ODP_ERR("pktio name %s is too big, limit is %d bytes\n", + loop_hint, IFNAMSIZ); + return ODP_PKTIO_INVALID; + } + + memset(loop, 0, IFNAMSIZ); + memcpy(loop, loop_hint, strlen(loop_hint)); + dev = loop; + ODP_DBG("pktio using %s as loopback device\n", loop_hint); + } id = alloc_lock_pktio_entry(); if (id == ODP_PKTIO_INVALID) {