From patchwork Tue Dec 9 17:44:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 42066 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 96C74244AC for ; Tue, 9 Dec 2014 17:45:29 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf1121922eek.1 for ; Tue, 09 Dec 2014 09:45:28 -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=YUX6x0X7IpDDWzV6nV9BI+dTOf6h7F/3q1glScKwymU=; b=m2vH+Ap6lMD3jB+jicd5l5LNt5T0M5ceo90wuHlCxi+5jzQbygRi+qsBdYS3FMCTFW LjdZWdCVDlBp/OY6M0UMJJQKvGD7RsaGpkUzYIS1QrxWTjYeeC9c7s61KUfargZkbE/P bVUHVWbNsxwFrA0ImKXNHSoUPVFmXBvFQ1liOBGGZL9qVPy0wQAczaCUE2jm/whrpVWV cxTfQAAhBP+MTnlfNDmieC2JfY7472vcMTRmuOBgvEwrwXP6LBNGIKXgQf8Hu2147TpV 3YSrpX9ueQ+clG/gA3waIHT8tWKvksw0XAsftNA7pufOBb25I7lZKg9dauP3CFpCJ6KJ DoTw== X-Gm-Message-State: ALoCoQlsW6RIMVDxR7yIHe02pFgDgvVIE5smITh7dBpcP+G/j80HCq4zos1f4JDTuZYWO6Gt6S1X X-Received: by 10.152.8.67 with SMTP id p3mr1642175laa.4.1418147128702; Tue, 09 Dec 2014 09:45:28 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.234.228 with SMTP id uh4ls69473lac.108.gmail; Tue, 09 Dec 2014 09:45:28 -0800 (PST) X-Received: by 10.152.1.131 with SMTP id 3mr22991539lam.89.1418147128419; Tue, 09 Dec 2014 09:45:28 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id mj8si2014475lbc.70.2014.12.09.09.45.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 09:45:28 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ms9so969993lab.10 for ; Tue, 09 Dec 2014 09:45:28 -0800 (PST) X-Received: by 10.112.138.137 with SMTP id qq9mr22945173lbb.80.1418147128302; Tue, 09 Dec 2014 09:45:28 -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 ew9csp786929lbc; Tue, 9 Dec 2014 09:45:27 -0800 (PST) X-Received: by 10.140.93.164 with SMTP id d33mr7481654qge.37.1418147126692; Tue, 09 Dec 2014 09:45:26 -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 u4si1870990qak.104.2014.12.09.09.45.25 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Dec 2014 09:45:26 -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 1XyOqi-0005U6-5k; Tue, 09 Dec 2014 17:45:24 +0000 Received: from mail-lb0-f177.google.com ([209.85.217.177]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XyOqQ-0005Pr-Iu for lng-odp@lists.linaro.org; Tue, 09 Dec 2014 17:45:06 +0000 Received: by mail-lb0-f177.google.com with SMTP id b6so924112lbj.36 for ; Tue, 09 Dec 2014 09:45:01 -0800 (PST) X-Received: by 10.112.134.134 with SMTP id pk6mr23411613lbb.14.1418147101014; Tue, 09 Dec 2014 09:45:01 -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.44.59 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 09:45:00 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Tue, 9 Dec 2014 20:44:47 +0300 Message-Id: <1418147090-29055-4-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 3/6] API: pktio: mac addr get function 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.51 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 Define API to get MAC address for specific packet i/o and implement linux-generic version. Signed-off-by: Maxim Uvarov Reviewed-by: Petri Savolainen Reviewed-by: Victor Kamensky Reviewed-by: Ciprian Barbu --- platform/linux-generic/include/api/odp_packet_io.h | 12 +++++++ platform/linux-generic/odp_packet_io.c | 42 ++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/platform/linux-generic/include/api/odp_packet_io.h b/platform/linux-generic/include/api/odp_packet_io.h index 742ea59..63c047c 100644 --- a/platform/linux-generic/include/api/odp_packet_io.h +++ b/platform/linux-generic/include/api/odp_packet_io.h @@ -175,6 +175,18 @@ int odp_pktio_promisc_mode_set(odp_pktio_t id, odp_bool_t enable); int odp_pktio_promisc_mode(odp_pktio_t id); /** + * Get the default MAC address of a packet IO interface. + * + * @param id ODP packet IO handle. + * @param[out] mac_addr Storage for MAC address of the packet IO interface. + * @param addr_size Storage size for the address + * + * @retval Number of bytes written on success, 0 on failure. + */ +size_t odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr, + size_t addr_size); + +/** * @} */ diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 43cf641..541072b 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -21,6 +21,7 @@ #include #include +#include typedef struct { pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES]; @@ -650,3 +651,44 @@ int odp_pktio_promisc_mode(odp_pktio_t id) else return 0; } + +size_t odp_pktio_mac_addr(odp_pktio_t id, void *mac_addr, + size_t addr_size) +{ + pktio_entry_t *entry; + + if (addr_size < ETH_ALEN) + return 0; + + entry = get_entry(id); + if (entry == NULL) { + ODP_DBG("pktio entry %d does not exist\n", id); + return 0; + } + + lock_entry(entry); + + if (odp_unlikely(is_free(entry))) { + unlock_entry(entry); + ODP_DBG("already freed pktio\n"); + return -1; + } + + switch (entry->s.type) { + case ODP_PKTIO_TYPE_SOCKET_BASIC: + case ODP_PKTIO_TYPE_SOCKET_MMSG: + memcpy(mac_addr, entry->s.pkt_sock.if_mac, + ETH_ALEN); + break; + case ODP_PKTIO_TYPE_SOCKET_MMAP: + memcpy(mac_addr, entry->s.pkt_sock_mmap.if_mac, + ETH_ALEN); + break; + default: + ODP_ABORT("Wrong socket type %d\n", entry->s.type); + } + + unlock_entry(entry); + + return ETH_ALEN; +}