From patchwork Tue Oct 10 09:00:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 115366 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp3280501edb; Tue, 10 Oct 2017 02:03:29 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAvznVQvMnFFfV6IMVp2hX+RNungNk/AJ7DOl2A7lNkVRl2DncFsD5j/FXy/Fo591viUpea X-Received: by 10.200.47.5 with SMTP id j5mr18931709qta.133.1507626209611; Tue, 10 Oct 2017 02:03:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507626209; cv=none; d=google.com; s=arc-20160816; b=Axh9fQUjByDhF7Yuz6qHob0RUnPauYWgZvLkFsIyO1ALapQX51EvDXZaooNW6oq7Vg 4Kjg8iOrVWXPxd+C42KhxYxW9bPTfZZfZt+eGf52jdt1SZC8P/dFONd96/c6Con5yYaB eFiky3p73lLjB+hM1ammANm23CIlDYbpIpdoAqiRUma4biscD83eN64dzwdgVPwa03Zc bkYyVE8xJQs7Hw4nLzkyKjCXktmY0adaWKujK5FPUesq8si1a5qbWOighaYvlbW8pF9x swinhWdhvVR7DFeM6l9LqRU1zjnNPJbA4H0/qPfgoQipZP6IkS8nSMytpSZFDQoQArmv thdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=WTV1dLMmBajWePNkngziy3thaz26ryIB60sNfpIY4jo=; b=YyToZSFLl37H6zyRB/QtkHC9jjGLegbCpOGT0WZFIHE3KTw4QS9hnZkqJOhobJVMqC wOmRuRzdBK6BzbcNjdlF+NpVw+Vg1ZFO4uU72UzU6OH/OB10Jjwp5zU37Fd3jF9Z6bZj qMiwG8nSxVP8W6hYHLrD1pMcd90PcclyrSalpMBo9s+I5PTk0uqwzbaP/6ePfkE4wyJd Y0ZRrMyWHPzDoruV+0IaerCG5njgmaaLBJL+owBKmYN9n/oUGKYvaTSW+6Mv0GyMp+6I wUmJEsMWl9h/OUGqZXWMbzZb7z6LQ25MHOn+7xuivA2rqEa4fKdv53B05eHJltgmuSli WgNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g4si3770645qkf.99.2017.10.10.02.03.29; Tue, 10 Oct 2017 02:03:29 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 54C1B60C3C; Tue, 10 Oct 2017 09:03:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 4D26060C42; Tue, 10 Oct 2017 09:01:02 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id B888F60BFE; Tue, 10 Oct 2017 09:00:48 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id 4E0EB60BF1 for ; Tue, 10 Oct 2017 09:00:41 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward101o.mail.yandex.net (Yandex) with ESMTP id AF8CC1342C20 for ; Tue, 10 Oct 2017 12:00:39 +0300 (MSK) Received: from smtp1o.mail.yandex.net (smtp1o.mail.yandex.net [2a02:6b8:0:1a2d::25]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id oJHXIqVjaR-0dDGU7uK; Tue, 10 Oct 2017 12:00:39 +0300 Received: by smtp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id drzNSBeNeN-0dRGCBpc; Tue, 10 Oct 2017 12:00:39 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 10 Oct 2017 12:00:10 +0300 Message-Id: <1507626011-15870-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1507626011-15870-1-git-send-email-odpbot@yandex.ru> References: <1507626011-15870-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 203 Subject: [lng-odp] [PATCH API-NEXT v5 2/3] linux-gen: pktio: implement MAC address set function X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Bogdan Pricope Add implement of MAC address set API. It calls packet IO specific MAC address set function. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 203 (bogdanPricope:set_mac_pr) ** https://github.com/Linaro/odp/pull/203 ** Patch: https://github.com/Linaro/odp/pull/203.patch ** Base sha: bf803098eb1518dfb9e719071256fe22700b8c72 ** Merge commit sha: 9741b2bb193f1cb28f8dd4bf382bc598e1dbd5ef **/ .../linux-generic/include/odp_packet_io_internal.h | 1 + platform/linux-generic/odp_packet_io.c | 36 ++++++++++++++++++++++ platform/linux-generic/pktio/dpdk.c | 1 + platform/linux-generic/pktio/ipc.c | 1 + platform/linux-generic/pktio/loop.c | 1 + platform/linux-generic/pktio/netmap.c | 1 + platform/linux-generic/pktio/pcap.c | 1 + platform/linux-generic/pktio/socket.c | 1 + platform/linux-generic/pktio/socket_mmap.c | 1 + platform/linux-generic/pktio/tap.c | 1 + 10 files changed, 45 insertions(+) diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 1a4e345f5..41a1be108 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -210,6 +210,7 @@ typedef struct pktio_if_ops { int (*promisc_mode_set)(pktio_entry_t *pktio_entry, int enable); int (*promisc_mode_get)(pktio_entry_t *pktio_entry); int (*mac_get)(pktio_entry_t *pktio_entry, void *mac_addr); + int (*mac_set)(pktio_entry_t *pktio_entry, const void *mac_addr); int (*link_status)(pktio_entry_t *pktio_entry); int (*capability)(pktio_entry_t *pktio_entry, odp_pktio_capability_t *capa); diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 64ec1f670..f81eb792f 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -895,6 +895,42 @@ int odp_pktio_mac_addr(odp_pktio_t hdl, void *mac_addr, int addr_size) return ret; } +int odp_pktio_mac_addr_set(odp_pktio_t hdl, const void *mac_addr, int addr_size) +{ + pktio_entry_t *entry; + int ret = -1; + + if (addr_size < ETH_ALEN) { + /* Input buffer too small */ + return -1; + } + + entry = get_pktio_entry(hdl); + if (entry == NULL) { + ODP_DBG("pktio entry %d does not exist\n", hdl); + return -1; + } + + lock_entry(entry); + + if (odp_unlikely(is_free(entry))) { + unlock_entry(entry); + ODP_DBG("already freed pktio\n"); + return -1; + } + + if (entry->s.state == PKTIO_STATE_STARTED) { + unlock_entry(entry); + return -1; + } + + if (entry->s.ops->mac_set) + ret = entry->s.ops->mac_set(entry, mac_addr); + + unlock_entry(entry); + return ret; +} + int odp_pktio_link_status(odp_pktio_t hdl) { pktio_entry_t *entry; diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 26ca0d6b4..45153af82 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -1542,6 +1542,7 @@ const pktio_if_ops_t dpdk_pktio_ops = { .promisc_mode_set = dpdk_promisc_mode_set, .promisc_mode_get = dpdk_promisc_mode_get, .mac_get = dpdk_mac_addr_get, + .mac_set = NULL, .capability = dpdk_capability, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index a7f346ae5..c8880ae93 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -790,6 +790,7 @@ const pktio_if_ops_t ipc_pktio_ops = { .promisc_mode_set = NULL, .promisc_mode_get = NULL, .mac_get = ipc_mac_addr_get, + .mac_set = NULL, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, .config = NULL diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index 428b6cebd..eba6d3b03 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -265,6 +265,7 @@ const pktio_if_ops_t loopback_pktio_ops = { .promisc_mode_set = loopback_promisc_mode_set, .promisc_mode_get = loopback_promisc_mode_get, .mac_get = loopback_mac_addr_get, + .mac_set = NULL, .link_status = loopback_link_status, .capability = loopback_capability, .pktin_ts_res = NULL, diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 4d771fcb4..9ee412f0a 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -962,6 +962,7 @@ const pktio_if_ops_t netmap_pktio_ops = { .promisc_mode_set = netmap_promisc_mode_set, .promisc_mode_get = netmap_promisc_mode_get, .mac_get = netmap_mac_addr_get, + .mac_set = NULL, .capability = netmap_capability, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index 783b85a9c..596bf6f28 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -440,6 +440,7 @@ const pktio_if_ops_t pcap_pktio_ops = { .promisc_mode_set = pcapif_promisc_mode_set, .promisc_mode_get = pcapif_promisc_mode_get, .mac_get = pcapif_mac_addr_get, + .mac_set = NULL, .capability = pcapif_capability, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 5841e2448..0a80035f5 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -873,6 +873,7 @@ const pktio_if_ops_t sock_mmsg_pktio_ops = { .promisc_mode_set = sock_promisc_mode_set, .promisc_mode_get = sock_promisc_mode_get, .mac_get = sock_mac_addr_get, + .mac_set = NULL, .link_status = sock_link_status, .capability = sock_capability, .pktin_ts_res = NULL, diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index f71180238..67c5b2067 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -730,6 +730,7 @@ const pktio_if_ops_t sock_mmap_pktio_ops = { .promisc_mode_set = sock_mmap_promisc_mode_set, .promisc_mode_get = sock_mmap_promisc_mode_get, .mac_get = sock_mmap_mac_addr_get, + .mac_set = NULL, .link_status = sock_mmap_link_status, .capability = sock_mmap_capability, .pktin_ts_res = NULL, diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index 917db006e..ed4479445 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -391,6 +391,7 @@ const pktio_if_ops_t tap_pktio_ops = { .promisc_mode_set = tap_promisc_mode_set, .promisc_mode_get = tap_promisc_mode_get, .mac_get = tap_mac_addr_get, + .mac_set = NULL, .capability = tap_capability, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL,