From patchwork Mon Oct 16 12:00:05 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: 115904 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3597439qgn; Mon, 16 Oct 2017 05:02:24 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Scb0hMqrvcTuDrTgJLF+gRLkdULS4LBX2LZiiEwYib3iVUCFkuo7Mr4VF0NuZNW5VrJPT2 X-Received: by 10.107.232.3 with SMTP id f3mr11814413ioh.156.1508155344635; Mon, 16 Oct 2017 05:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508155344; cv=none; d=google.com; s=arc-20160816; b=DjLuIclR7pRevAW4a2RBdwylsAPO6m9cLrOaW6R4V9mhB/FS+VHO5FTEfdF4xFSfUA oOCy+n+jdggGy3sHjNpgut6+1Q+hjVqVf0tmop0XbVje/4inktEH07lspNzHldRlakXq kLJo/WuzhwgKOtfWJNj5c9zLgb8i5MLKjSQg6cE5qgzszLwZO1AFY3cwqEDADEkKMPYp mAczWQ0yDObtk7159Vibl1WbrnBB4VX2HnwdHje9vO/fxLMMsKJjQ8SG4OFTiqZmVVU+ 3RvW6NsARKwYTOhsjXeKe7dCopSYhqIbSd6uidA9hXBAeWeJkZ9FTsVC43WfOJuwfDR6 AuXg== 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=oVo3Hk2VDQ9UNmWFgcZIWzf1lS7+i4aFuuHHPbgtSOU=; b=w0y7dqvKF1OV5cqv7KRDgqZa/qXmMDE3ynLvManID7AC3pzIoWwhZuNpNqj/Kg7d/c AAUR1yoEnfPqdpUCS16smZX+1FOuedmxfJeJ06PnZngvWK6AyGeqO2k5yafzV4EcsD67 mFOA2UKMQoGhH+o2THIyUo3eBK6RT562rcD/Sb5sW5shSZYza7ZOVODi4ylSquusuyKp qghFxnz5gUuub78t/ru0OdH+tGcwkEHyKSJ/8YXs/FRGue9csUEqf+XtoGJJN7MpdIsA 4Ng0Og8otKgYsQsgiUIbundZxn2CVd09RovIWK5SWSLX76KLo46VI4umE+TRADeXD+tP S3RA== 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 d1si4848754itj.45.2017.10.16.05.02.24; Mon, 16 Oct 2017 05:02:24 -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 CE763609DB; Mon, 16 Oct 2017 12:02:23 +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 3F80560923; Mon, 16 Oct 2017 12:01:59 +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 B941E609EB; Mon, 16 Oct 2017 12:01:53 +0000 (UTC) Received: from forward106p.mail.yandex.net (forward106p.mail.yandex.net [77.88.28.109]) by lists.linaro.org (Postfix) with ESMTPS id 3E9B360609 for ; Mon, 16 Oct 2017 12:00:15 +0000 (UTC) Received: from mxback1o.mail.yandex.net (mxback1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1b]) by forward106p.mail.yandex.net (Yandex) with ESMTP id E309D2D81F53 for ; Mon, 16 Oct 2017 15:00:13 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback1o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 9TKw4DHvvW-0DFWBxrU; Mon, 16 Oct 2017 15:00:13 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id KcD5G1a8yg-0D1KJlWV; Mon, 16 Oct 2017 15:00:13 +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: Mon, 16 Oct 2017 15:00:05 +0300 Message-Id: <1508155207-5041-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508155207-5041-1-git-send-email-odpbot@yandex.ru> References: <1508155207-5041-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 232 Subject: [lng-odp] [PATCH API-NEXT v1 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: afeda4d14bb6f449cb269680cdbd56b26726eedf ** Merge commit sha: 8726d6c7a814c3380aacd18250194eae85ababb3 **/ 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 Mon Oct 16 12:00:06 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: 115906 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3600216qgn; Mon, 16 Oct 2017 05:04:30 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC0THLgZBgyomAmXgM93csILyTpf3Hg/Gyl78yB1yrcJmjCtGvVgNF2aNqG8bxCYfj0Obku X-Received: by 10.55.75.15 with SMTP id y15mr12145007qka.321.1508155470085; Mon, 16 Oct 2017 05:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508155470; cv=none; d=google.com; s=arc-20160816; b=i6Q1GmVULh4UQIWcIAb5MdBZVSquKBCYSpcFi2Co4kU3CS7KSYJMbvkGGFXPpJU02E D4+kcT807LR+M4dhNi5BS/INWBN5zY9uupKZEPWibOi14z/wCJjNN+vrIzMajXwBkmqr RTUoev+e+wL+jYTSasrXaudoWX5nUsBeBu0MZcPB0oowjG7MTSO91OBheNniy8C6KPmH MhvGOVvu8874OsdTI8OrZCDlab20Yi29KgVzK+j89zy3I1iIQvpBxbcaS/jb4fIVHLce ijD0DYi/XUxnxDokxMkPFw7gxzHvYj4Q3+oV2FH4u8BE1YVqlMhKDrcUF6gcBZIlicRA 1fOg== 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=CypDXDar0G6ojw8M7+BngNHe/2yMS+9UVlCLRw6DacY=; b=kKEmG7/ryUl60/kqP48eXqGBxqqdRFaU3+gaK6rmWyGPWUtcfe9738ow2slnCFr45U kQPY4THa6Wu9LXXzb5Tepw2p/eQOGWf0v2wYDhbEcWGqRvHr+UD8Pl+UZFRTt3HacZKR bcBcJpoZWl3Svj0aJhqK2Km2PXdLO+ekiecU8Lf05FOx1X0NZNk3jgf1khjaD/yvwmOb M01AkpP31I85Wk1R2UxtMhdMwn5PKOHWrfgGte26k9QpQ1Gbn5oBgatVSv/xCynNtfN2 fcUrQBDVa6zrMDs8uE0NV903rojlA6CfSuRvPr2BafFUiUYouhfAi2tmQxfKtbiyIuEe K5rw== 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 q203si6060742qke.319.2017.10.16.05.04.29; Mon, 16 Oct 2017 05:04:30 -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 B492860B50; Mon, 16 Oct 2017 12:04: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 59BC360AC8; Mon, 16 Oct 2017 12:02:40 +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 D8E89609DB; Mon, 16 Oct 2017 12:02:13 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id 3FE0260A4F for ; Mon, 16 Oct 2017 12:00:16 +0000 (UTC) Received: from mxback8g.mail.yandex.net (mxback8g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:169]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 68B62218214C for ; Mon, 16 Oct 2017 15:00:14 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback8g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id waW2mH0ntd-0Er0iCRA; Mon, 16 Oct 2017 15:00:14 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id KcD5G1a8yg-0D18xsJl; Mon, 16 Oct 2017 15:00:14 +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: Mon, 16 Oct 2017 15:00:06 +0300 Message-Id: <1508155207-5041-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508155207-5041-1-git-send-email-odpbot@yandex.ru> References: <1508155207-5041-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 232 Subject: [lng-odp] [PATCH API-NEXT v1 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: afeda4d14bb6f449cb269680cdbd56b26726eedf ** Merge commit sha: 8726d6c7a814c3380aacd18250194eae85ababb3 **/ 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 Mon Oct 16 12:00:07 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: 115905 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3598608qgn; Mon, 16 Oct 2017 05:03:15 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB8IvB+oa8l42Fa2pk2Afj2QUcophKg1kjjHhq3XLiXApt2uH22b0VC/Xh62p1Dm0yvESLM X-Received: by 10.107.3.193 with SMTP id e62mr12493457ioi.88.1508155395458; Mon, 16 Oct 2017 05:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508155395; cv=none; d=google.com; s=arc-20160816; b=aOeI+Zd8YyjWD/9hEZjWtXYy8GgioHeowqbzhe4eW0BxRE0dC2kepywmg17pCn8p5t XYiaQs8UR4V+zAUT9KEnSUNm3rjpB7He9ZYT2pjbhBSdT0C+PRS7fhhW73LwlCoN1TKh jCTGaoqKBlr6cWYZsKbFxWkRgY0r+D1Z3lqAVqSMBWDVpewQTXvyC+DN/OZH2we2HW8k a2wW44QL37PH+T4qO51m8tBcJfTe3+eMZz0kT7vyM39wv6S9V1+4uyrRWyluxjyUTyLs WGroU4YOAdngrbjQauxXJ+EqeEHeuXK5j11SBxLZ/DVJpHBd8pFfzYA48QZEfYO0Zgxm er5A== 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=eneTyJxLPSdvYsahgU5B1pnqAtJn9vs3ueXmP5aWBPk=; b=oyOL0bsCfu0N96fr71aJpxo5edwMa1rtAc3TA6TMORuzI6lVrV4h4NLs4mFIyEcDfs w45kDcggjThggBQsUV3Un0ongER9A8333WXEg4JC6HtP1HYoFxStczJYQ+0fDtJn4nw2 VBqlnkSvzSoSA/kM/X6jmLcjiIwCjSG+Cu3jAh49FWr7q9fEYPSgJAFBTltZEz5Odl1F QPGgAMXd2IwKoZOBC63h7n6ddlmtoQ/dE5LuAE1q4aVs+j45ev1RH20NljEY5f9Qou3Q hCFOWM4ynV7t/MrlHf0D9gRJ0YvelworJZMOY9jv3JOM0fz5cpuhyD4HPXFyX8/+huRv Vx4w== 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 p10si1981612iti.94.2017.10.16.05.03.15; Mon, 16 Oct 2017 05:03:15 -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 066CE60ABA; Mon, 16 Oct 2017 12:03:15 +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 96109608B6; Mon, 16 Oct 2017 12:02:23 +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 73198609DB; Mon, 16 Oct 2017 12:02:11 +0000 (UTC) Received: from forward105p.mail.yandex.net (forward105p.mail.yandex.net [77.88.28.108]) by lists.linaro.org (Postfix) with ESMTPS id 56FB160A51 for ; Mon, 16 Oct 2017 12:00:16 +0000 (UTC) Received: from mxback2g.mail.yandex.net (mxback2g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:163]) by forward105p.mail.yandex.net (Yandex) with ESMTP id E33AB4080FC6 for ; Mon, 16 Oct 2017 15:00:14 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback2g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id awfZ0xW0yB-0E5uh8UK; Mon, 16 Oct 2017 15:00:14 +0300 Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id KcD5G1a8yg-0E1W9sTZ; Mon, 16 Oct 2017 15:00:14 +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: Mon, 16 Oct 2017 15:00:07 +0300 Message-Id: <1508155207-5041-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1508155207-5041-1-git-send-email-odpbot@yandex.ru> References: <1508155207-5041-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 232 Subject: [lng-odp] [PATCH API-NEXT v1 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: afeda4d14bb6f449cb269680cdbd56b26726eedf ** Merge commit sha: 8726d6c7a814c3380aacd18250194eae85ababb3 **/ platform/linux-generic/include/odp_packet_socket.h | 5 +++++ platform/linux-generic/pktio/socket.c | 25 ++++++++++++++++++++++ platform/linux-generic/pktio/tap.c | 13 ++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/include/odp_packet_socket.h b/platform/linux-generic/include/odp_packet_socket.h index 0e61f6f0c..a05629ba5 100644 --- a/platform/linux-generic/include/odp_packet_socket.h +++ b/platform/linux-generic/include/odp_packet_socket.h @@ -99,6 +99,11 @@ ethaddrs_equal(unsigned char mac_a[], unsigned char mac_b[]) int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]); /** + * Write the MAC address for a packet socket + */ +int mac_addr_set_fd(int fd, const char *name, const unsigned char mac_dst[]); + +/** * Read the MTU from a packet socket */ uint32_t mtu_get_fd(int fd, const char *name); diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 0a80035f5..447b02b20 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -125,6 +125,31 @@ int mac_addr_get_fd(int fd, const char *name, unsigned char mac_dst[]) return 0; } +/** + * ODP_PACKET_TAP: + */ +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; +} + /* * ODP_PACKET_SOCKET_MMSG: * ODP_PACKET_SOCKET_MMAP: diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index 2fda0b814..841631d9b 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -412,6 +412,16 @@ static int tap_link_status(pktio_entry_t *pktio_entry) pktio_entry->s.name + 4); } +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_capability(pktio_entry_t *pktio_entry ODP_UNUSED, odp_pktio_capability_t *capa) { @@ -420,6 +430,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 +454,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,