From patchwork Thu Oct 19 08: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: 116339 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp204930qgn; Thu, 19 Oct 2017 01:01:08 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SJ8l6YgVFYybqUFfm4rEqpggtA4J+4TzDX+Z5Ndhpa1jlwpXer3K6XkXbJ4hCU9mFEhOHF X-Received: by 10.55.209.27 with SMTP id s27mr892496qki.4.1508400068548; Thu, 19 Oct 2017 01:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508400068; cv=none; d=google.com; s=arc-20160816; b=SGkm+BtmEyZONFqkj6f7YEiK3lYNP5ytWbMV3PrY/wGjQAJwxRNkpSoFEYOtrNb/Je O56a5B7T3e+iBAOzfSBTJiGgmO8ighIXsq+/wbgyaTRy1fSflam7Z76fu/8mhaoj6Zs8 ytEV39Cwcem7lFbzrApIBhyCsYjhMLHoOpJYqUolqX4DGljTjnD8uYF+r8dEX3tQImN6 gS3wpYEPZ55c1JMleoMI1sicym2vQYPfwlN8qCY/le/frwYigXCP9gMzhcLI2/zvwIow WD35TsTz7EXRItFjs3Jd3gk0VMz/w4a+IUyA6Sw8Ct2KKgNJ3EpK1iB3LfolYD5Rd4sZ qsgg== 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=e3MRbXF0fK6dWKZq3pjQxXi2BQOvod0AARjIf7FSWWI=; b=Fg0LzXl01XJzeuqB5BfZC4DOS+C/WHb90ZXb3utS2jdaR48cMJE+P7Jhcatnaaulqc DlpUY7Ha2TKAj5kvZBLB2hDgxcU4EaMuC2cOR3vHhNq0cHBHrmCiYCFdU4ESk/Jwu/N1 Beu2IMRBpr0+QG+VNYeiCXwqGh7HNprGVD7Ev2TYjgtLBbAHWm8/ppqs6lRp7hjc5o9b sxlgQTbn7MWHpc4OUAhCBTKR3d5w/Y9xke4q7mRG7xD+pidE+Wz90zh9i/X2Zw5La3r7 71LWJWmFxDfMXbJv3iPJXzymTCK90ZLcrIsCQE7ZHmOgbR/ocIhV3psTLc1rV+yrApSJ b1Gw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id l192si4973728qke.459.2017.10.19.01.01.07; Thu, 19 Oct 2017 01:01:08 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 B402F62AD8; Thu, 19 Oct 2017 08:01:07 +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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 B8E576291E; Thu, 19 Oct 2017 08:00:52 +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 7EDE962AC4; Thu, 19 Oct 2017 08:00:38 +0000 (UTC) Received: from forward106o.mail.yandex.net (forward106o.mail.yandex.net [37.140.190.187]) by lists.linaro.org (Postfix) with ESMTPS id 82E6E62AE4 for ; Thu, 19 Oct 2017 08:00:18 +0000 (UTC) Received: from mxback7o.mail.yandex.net (mxback7o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::21]) by forward106o.mail.yandex.net (Yandex) with ESMTP id CBD71784429 for ; Thu, 19 Oct 2017 11:00:16 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback7o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id GrxiUKIShs-0GJiVjaS; Thu, 19 Oct 2017 11:00:16 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OmTGLJNgIE-0GcicFiu; Thu, 19 Oct 2017 11:00:16 +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: Thu, 19 Oct 2017 11:00:10 +0300 Message-Id: <1508400012-1278-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508400012-1278-1-git-send-email-odpbot@yandex.ru> References: <1508400012-1278-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 232 Subject: [lng-odp] [PATCH API-NEXT v2 1/3] linux-gen: pktio: tap: implement start/stop operations 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 Implement start/stop tap pktio operations. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 232 (bogdanPricope:tap_set_mac_pr) ** https://github.com/Linaro/odp/pull/232 ** Patch: https://github.com/Linaro/odp/pull/232.patch ** Base sha: edca8cd1e55898826f79383b689c2c4bd2c28b3a ** Merge commit sha: 89f18d929052add128b4252f5b17907b9a354ccb **/ platform/linux-generic/pktio/tap.c | 72 +++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 13 deletions(-) diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index ed4479445..8ddd757d9 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -134,8 +134,30 @@ static int tap_pktio_open(odp_pktio_t id ODP_UNUSED, goto sock_err; } - /* Up interface by default. */ - if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0) { + tap->fd = fd; + tap->skfd = skfd; + tap->mtu = mtu; + tap->pool = pool; + return 0; +sock_err: + close(skfd); +tap_err: + close(fd); + ODP_ERR("Tap device alloc failed.\n"); + return -1; +} + +static int tap_pktio_start(pktio_entry_t *pktio_entry) +{ + struct ifreq ifr; + pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + + odp_memset(&ifr, 0, sizeof(ifr)); + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", + (char *)pktio_entry->s.name + 4); + + /* Up interface by default. */ + if (ioctl(tap->skfd, SIOCGIFFLAGS, &ifr) < 0) { __odp_errno = errno; ODP_ERR("ioctl(SIOCGIFFLAGS) failed: %s\n", strerror(errno)); goto sock_err; @@ -144,22 +166,46 @@ static int tap_pktio_open(odp_pktio_t id ODP_UNUSED, ifr.ifr_flags |= IFF_UP; ifr.ifr_flags |= IFF_RUNNING; - if (ioctl(skfd, SIOCSIFFLAGS, &ifr) < 0) { + if (ioctl(tap->skfd, SIOCSIFFLAGS, &ifr) < 0) { __odp_errno = errno; ODP_ERR("failed to come up: %s\n", strerror(errno)); goto sock_err; } - tap->fd = fd; - tap->skfd = skfd; - tap->mtu = mtu; - tap->pool = pool; return 0; sock_err: - close(skfd); -tap_err: - close(fd); - ODP_ERR("Tap device alloc failed.\n"); + ODP_ERR("Tap device open failed.\n"); + return -1; +} + +static int tap_pktio_stop(pktio_entry_t *pktio_entry) +{ + struct ifreq ifr; + pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + + odp_memset(&ifr, 0, sizeof(ifr)); + snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", + (char *)pktio_entry->s.name + 4); + + /* Up interface by default. */ + if (ioctl(tap->skfd, SIOCGIFFLAGS, &ifr) < 0) { + __odp_errno = errno; + ODP_ERR("ioctl(SIOCGIFFLAGS) failed: %s\n", strerror(errno)); + goto sock_err; + } + + ifr.ifr_flags &= ~IFF_UP; + ifr.ifr_flags &= ~IFF_RUNNING; + + if (ioctl(tap->skfd, SIOCSIFFLAGS, &ifr) < 0) { + __odp_errno = errno; + ODP_ERR("failed to come up: %s\n", strerror(errno)); + goto sock_err; + } + + return 0; +sock_err: + ODP_ERR("Tap device open failed.\n"); return -1; } @@ -383,8 +429,8 @@ const pktio_if_ops_t tap_pktio_ops = { .term = NULL, .open = tap_pktio_open, .close = tap_pktio_close, - .start = NULL, - .stop = NULL, + .start = tap_pktio_start, + .stop = tap_pktio_stop, .recv = tap_pktio_recv, .send = tap_pktio_send, .mtu_get = tap_mtu_get, From patchwork Thu Oct 19 08:00:11 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: 116340 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp206685qgn; Thu, 19 Oct 2017 01:03:00 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Rt4EMyEVsWu0PudV5perx4J9dK0NHHzpcNZhqi3ZCGXZKiTG6PjPb6A9ddc/Ca1Kc3ctP6 X-Received: by 10.36.13.210 with SMTP id 201mr1360297itx.95.1508400180335; Thu, 19 Oct 2017 01:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508400180; cv=none; d=google.com; s=arc-20160816; b=WPvOO+4VxXnztV1XZjQPb2QazOlD4ZtuCMmarl1+pwFPxDwN4G0+sNGnGmyTresaPH tIPNsDoavZZYD5L0zBVeEwEP2pBTCZGs0gHt9XjTznaEK/0F9/ZcFknR3o4salveNgWI 3XyC3BDBN/wcr5BtjcGiZFghMTBEMNoa3P62ord/vFZHXD/J/yynlfCHJLeaKEk/JidA 633RF8mybxbZ9WKVZwmoeXCs949Y9Dt5VxIAdhwUiwhsQW1ztEn5seBNI6xCiPpGMN5c wOvkqknxWOVnwFzF40Oe5A1i81x1KsszQreeOlrWI7P9r7mjtNBtcxACOStDrWL5U0Pr tPFg== 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=UjMi0mpYxiLmoQGKGRSeI+f3/ZCLFFKGM45c8b+QOac=; b=htAak71pyXDypmNpAwL2eJ/JkYPGuLtKxpJDE+Q6Gn6PqJXnAB6flJ9gSqu2vsnKBz 3AT8A1dmNkDYqRxUrTS60ZCodwxrNqJdv/mwUk319FqIboO2XiH0JKXDOr1+rjr3XKSC odq/jlukkELGPufouCi6yw0kos4gRaR3mdTqP07JZpPddyLBoyDJR0/RTA6Wkd9bXjMf Q5afEZb3jNXbnJna9+cEtKjxtXHNWQPGXOXC4CgxNpEbWVGEAWDM8XRrxJ9LBfLRFthI FCghy+EMf403tQyaZGzcpXDqtS0OqTSG0q+FAAHYMa+wNX6LCphb/mKkhYjEYiewUTuc SE+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id u65si805578itg.111.2017.10.19.01.03.00; Thu, 19 Oct 2017 01:03:00 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 D4F3962DEB; Thu, 19 Oct 2017 08:02:59 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 4C59461042; Thu, 19 Oct 2017 08:01:06 +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 4B0E1629F1; Thu, 19 Oct 2017 08:00:42 +0000 (UTC) Received: from forward103j.mail.yandex.net (forward103j.mail.yandex.net [5.45.198.246]) by lists.linaro.org (Postfix) with ESMTPS id E419061103 for ; Thu, 19 Oct 2017 08:00:19 +0000 (UTC) Received: from mxback11g.mail.yandex.net (mxback11g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:90]) by forward103j.mail.yandex.net (Yandex) with ESMTP id 6390734C307E for ; Thu, 19 Oct 2017 11:00:17 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback11g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id D51wc4eYAd-0HNePnqu; Thu, 19 Oct 2017 11:00:17 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OmTGLJNgIE-0GcWFPRq; Thu, 19 Oct 2017 11:00:16 +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: Thu, 19 Oct 2017 11:00:11 +0300 Message-Id: <1508400012-1278-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508400012-1278-1-git-send-email-odpbot@yandex.ru> References: <1508400012-1278-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 232 Subject: [lng-odp] [PATCH API-NEXT v2 2/3] linux-gen: pktio: tap: implement link status operation 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 Implement link status tap pktio operation. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 232 (bogdanPricope:tap_set_mac_pr) ** https://github.com/Linaro/odp/pull/232 ** Patch: https://github.com/Linaro/odp/pull/232.patch ** Base sha: edca8cd1e55898826f79383b689c2c4bd2c28b3a ** Merge commit sha: 89f18d929052add128b4252f5b17907b9a354ccb **/ platform/linux-generic/pktio/tap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index 8ddd757d9..2fda0b814 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -406,6 +406,12 @@ static int tap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) return ETH_ALEN; } +static int tap_link_status(pktio_entry_t *pktio_entry) +{ + return link_status_fd(pktio_entry->s.pkt_tap.skfd, + pktio_entry->s.name + 4); +} + static int tap_capability(pktio_entry_t *pktio_entry ODP_UNUSED, odp_pktio_capability_t *capa) { @@ -438,6 +444,7 @@ const pktio_if_ops_t tap_pktio_ops = { .promisc_mode_get = tap_promisc_mode_get, .mac_get = tap_mac_addr_get, .mac_set = NULL, + .link_status = tap_link_status, .capability = tap_capability, .pktin_ts_res = NULL, .pktin_ts_from_ns = NULL, From patchwork Thu Oct 19 08:00:12 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: 116341 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp207591qgn; Thu, 19 Oct 2017 01:04:04 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TDVCcxThh59GQ50f25LXUHp5TWMgTtR8x9GhcH1r6gtXpmAMwnP6F5KFXNR4Vp0gV8ooam X-Received: by 10.200.1.136 with SMTP id x8mr951741qtf.259.1508400244333; Thu, 19 Oct 2017 01:04:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508400244; cv=none; d=google.com; s=arc-20160816; b=sr5AHdwEiqTihGDqPii5iXzQg7YX+hRbM6mJwHAUwHLTVCAO1uNDJCoCF5YFqcmn2X 9ZrwX7Oi6Y4znymLbQ28EWxSeJmICAdpyRHMF/KlXSL/d0T06Xep5eUJJGw1r0TYxyut vAx2igMTXHFLvYIQkGaM9/P9kT20UMWy+Rsci56xWOuJ1UETgDirCwu4QmruLQaGH4cr twRyCCDvUTFqaR5aJMcbMtDjcw/rFwI8s+AYMq4iOrVl7V4Se6dtBcAE98vpk3tGx9zN WYn9IdEFHnW9OwhCgDf0ZO8MmYhJlJEPTP5s38YO+1Y6eJ10TEjcJxv723Uaq4RcPCnJ Carg== 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=3dOjy8A7TzZUjXJevhHTCgqMTbGFSHxkv8vRagwHbDo=; b=lEzCvti0HOsnPt8FKRTNNKCgjDuvyhFfK8AUP7OM0GJ3JhbJD+u5tgl8DNrApjMBOh 0TMp0UKc6YJqECSwfmVPw635eI3Y5RTiOGVT5IL/N46ROuvL+E0T1seyZEP8oebQj7hV rPoAQm2jjqw58j2Y5NMgPLL4RSHvhAcALBAwoTXJQ6FghYggHYVN52Wg2Ov9DqC+Xv29 2AOkFmBjY6/4h3JDpDimRvTGFFQJ6Ycf7yqkB1dTRW7YL/skIbCixeuQSXnyaoV+rp7w DdiUPU5rwlsoKuK9Mby5ehE4jd34tzrKc7s2v9WMCo1rQ3co8P5Th70U/Wn8ckFt30Ba jS1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id b29si1045174qtk.59.2017.10.19.01.04.04; Thu, 19 Oct 2017 01:04:04 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 00D5D62EA0; Thu, 19 Oct 2017 08:04:03 +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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 8427A62AE4; Thu, 19 Oct 2017 08:01:10 +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 D3C73629F1; Thu, 19 Oct 2017 08:00:43 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id 846D66291E for ; Thu, 19 Oct 2017 08:00:19 +0000 (UTC) Received: from mxback20j.mail.yandex.net (mxback20j.mail.yandex.net [IPv6:2a02:6b8:0:1619::114]) by forward102j.mail.yandex.net (Yandex) with ESMTP id E92265605147 for ; Thu, 19 Oct 2017 11:00:17 +0300 (MSK) Received: from smtp1j.mail.yandex.net (smtp1j.mail.yandex.net [2a02:6b8:0:801::ab]) by mxback20j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id vlNZnYfdqY-0HM4AKOr; Thu, 19 Oct 2017 11:00:17 +0300 Received: by smtp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id OmTGLJNgIE-0HcWjwp7; Thu, 19 Oct 2017 11:00:17 +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: Thu, 19 Oct 2017 11:00:12 +0300 Message-Id: <1508400012-1278-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508400012-1278-1-git-send-email-odpbot@yandex.ru> References: <1508400012-1278-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 232 Subject: [lng-odp] [PATCH API-NEXT v2 3/3] linux-gen: pktio: tap: implement MAC address set operation 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 Implement MAC address set function and set corresponding capability flag. Signed-off-by: Bogdan Pricope --- /** Email created from pull request 232 (bogdanPricope:tap_set_mac_pr) ** https://github.com/Linaro/odp/pull/232 ** Patch: https://github.com/Linaro/odp/pull/232.patch ** Base sha: edca8cd1e55898826f79383b689c2c4bd2c28b3a ** Merge commit sha: 89f18d929052add128b4252f5b17907b9a354ccb **/ platform/linux-generic/pktio/tap.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index 2fda0b814..d8b78f3f8 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -59,6 +59,29 @@ static int gen_random_mac(unsigned char *mac) return 0; } +static int mac_addr_set_fd(int fd, const char *name, + const unsigned char mac_dst[]) +{ + struct ifreq ethreq; + int ret; + + memset(ðreq, 0, sizeof(ethreq)); + snprintf(ethreq.ifr_name, IF_NAMESIZE, "%s", name); + + ethreq.ifr_hwaddr.sa_family = AF_UNIX; + memcpy(ethreq.ifr_hwaddr.sa_data, mac_dst, ETH_ALEN); + + ret = ioctl(fd, SIOCSIFHWADDR, ðreq); + if (ret != 0) { + __odp_errno = errno; + ODP_ERR("ioctl(SIOCSIFHWADDR): %s: \"%s\".\n", strerror(errno), + ethreq.ifr_name); + return -1; + } + + return 0; +} + static int tap_pktio_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, const char *devname, odp_pool_t pool) @@ -406,6 +429,16 @@ static int tap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) return ETH_ALEN; } +static int tap_mac_addr_set(pktio_entry_t *pktio_entry, const void *mac_addr) +{ + pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + + memcpy(tap->if_mac, mac_addr, ETH_ALEN); + + return mac_addr_set_fd(tap->fd, (char *)pktio_entry->s.name + 4, + tap->if_mac); +} + static int tap_link_status(pktio_entry_t *pktio_entry) { return link_status_fd(pktio_entry->s.pkt_tap.skfd, @@ -420,6 +453,7 @@ static int tap_capability(pktio_entry_t *pktio_entry ODP_UNUSED, capa->max_input_queues = 1; capa->max_output_queues = 1; capa->set_op.op.promisc_mode = 1; + capa->set_op.op.mac_addr = 1; odp_pktio_config_init(&capa->config); capa->config.pktin.bit.ts_all = 1; @@ -443,7 +477,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, + .mac_set = tap_mac_addr_set, .link_status = tap_link_status, .capability = tap_capability, .pktin_ts_res = NULL,