From patchwork Tue Jan 13 17:36:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 43076 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 13B9426CFB for ; Tue, 13 Jan 2015 17:37:08 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id hs14sf2461461lab.1 for ; Tue, 13 Jan 2015 09:37:06 -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: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=0WD8mlSE2ownjLqsp9xc6eC40Nl/DCxKAVmo9BJAlfQ=; b=dC7PL3zgx3na4VvBPS2EdP4UD4z8MZtVE4lS9fwB1I74GR7Qf4/p51d5FG7NbCBVNR 8ZMsu7MCCe03N+76U63XWUxUQhRYe6tYW4YiPADKXv/0ZmKfCd8aOIW9MyVLm2fDWbl3 wHVlL3m3H1XZq6QE2FLMLf9LpBpc0kmoE+of6j/9VZKJ5j9FWOqehH4VyP5xxJSS8E5A Kk1tyRVWLcSOgBzuf3cclPDwC2O0g4rht2YAliB5+LDULzuKiJoAUX53VzXi/Z+iC9kB xMI0P+rpzCd0neYcga1RGaizTajLCyQLKlC58OIfaZK0PsTrtuMEZc7ewVf2pJMcDgPE UNpw== X-Gm-Message-State: ALoCoQlCtCkGqanBLeWup++NHkUOrDB8TZW0tijWfXEIv2reKZC3m4SwUtjpQUH2ZfFmVqG9oQpg X-Received: by 10.180.228.38 with SMTP id sf6mr3037448wic.5.1421170626612; Tue, 13 Jan 2015 09:37:06 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.170.202 with SMTP id ao10ls25664lac.59.gmail; Tue, 13 Jan 2015 09:37:06 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr43757149lal.29.1421170626380; Tue, 13 Jan 2015 09:37:06 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id ld3si3454762lac.115.2015.01.13.09.37.06 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 09:37:06 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id pn19so3884434lab.9 for ; Tue, 13 Jan 2015 09:37:06 -0800 (PST) X-Received: by 10.112.104.4 with SMTP id ga4mr43429197lbb.24.1421170626252; Tue, 13 Jan 2015 09:37:06 -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.9.200 with SMTP id c8csp1451780lbb; Tue, 13 Jan 2015 09:37:05 -0800 (PST) X-Received: by 10.224.13.65 with SMTP id b1mr51264687qaa.12.1421170624694; Tue, 13 Jan 2015 09:37:04 -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 s18si27714866qam.4.2015.01.13.09.37.03 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 13 Jan 2015 09:37:04 -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 1YB5Om-0003PY-Vc; Tue, 13 Jan 2015 17:37:00 +0000 Received: from mail-lb0-f169.google.com ([209.85.217.169]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YB5Og-0003Oo-RT for lng-odp@lists.linaro.org; Tue, 13 Jan 2015 17:36:55 +0000 Received: by mail-lb0-f169.google.com with SMTP id p9so3841281lbv.0 for ; Tue, 13 Jan 2015 09:36:49 -0800 (PST) X-Received: by 10.152.5.132 with SMTP id s4mr43554797las.39.1421170608957; Tue, 13 Jan 2015 09:36:48 -0800 (PST) Received: from localhost.localdomain (broadband-46-188-125-104.2com.net. [46.188.125.104]) by mx.google.com with ESMTPSA id zp3sm5141919lbb.45.2015.01.13.09.36.47 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 09:36:47 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 13 Jan 2015 20:36:29 +0300 Message-Id: <1421170589-6362-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: patch Subject: [lng-odp] [PATCHv3] api: implement odp_pktio_name 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.215.50 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 Introduced odp_pktio_name() function to translate pktio id to readable name provided to odp_pktio_open(). Needed mostly for debug messages. Signed-off-by: Maxim Uvarov --- v3: add test and extend description. v2: doxygen fix platform/linux-generic/include/api/odp_packet_io.h | 13 +++++++++++++ platform/linux-generic/odp_packet_io.c | 11 +++++++++++ test/validation/odp_pktio.c | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/platform/linux-generic/include/api/odp_packet_io.h b/platform/linux-generic/include/api/odp_packet_io.h index 0c34f29..c0ced4f 100644 --- a/platform/linux-generic/include/api/odp_packet_io.h +++ b/platform/linux-generic/include/api/odp_packet_io.h @@ -169,6 +169,19 @@ size_t odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr, size_t addr_size); /** + * Packet IO interface name + * + * Return the interface name from a pktio handle. This is the + * name that was passed to the odp_pktio_open() call. + * + * @param id ODP Packet IO handle. + * + * @retval Pointer to the interface name. + * @retval NULL if packet handle is invalid. + */ +const char *odp_pktio_name(odp_pktio_t id); + +/** * @} */ diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index cd109d2..7b08edf 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -746,3 +746,14 @@ size_t odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr, return ETH_ALEN; } + +const char *odp_pktio_name(odp_pktio_t id) +{ + pktio_entry_t *entry; + + entry = get_pktio_entry(id); + if (entry == NULL) + return NULL; + + return entry->s.name; +} diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c index d1eb0d5..dcbdee2 100644 --- a/test/validation/odp_pktio.c +++ b/test/validation/odp_pktio.c @@ -472,6 +472,24 @@ static void test_odp_pktio_mac(void) return; } +static void test_odp_pktio_name(void) +{ + odp_pktio_t pktio; + const char *name; + int ret; + + pktio = create_pktio(iface_name[0]); + name = odp_pktio_name(pktio); + + ret = strcmp(iface_name[0], name); + CU_ASSERT(0 == ret); + + ret = odp_pktio_close(pktio); + CU_ASSERT(0 == ret); + + return; +} + static void test_odp_pktio_open(void) { odp_pktio_t pktio; @@ -582,6 +600,7 @@ CU_TestInfo pktio_tests[] = { {"pktio mtu", test_odp_pktio_mtu}, {"pktio promisc mode", test_odp_pktio_promisc}, {"pktio mac", test_odp_pktio_mac}, + {"pktio name", test_odp_pktio_name}, CU_TEST_INFO_NULL };