From patchwork Wed Aug 26 15:49:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52735 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 patches.linaro.org (Postfix) with ESMTPS id 27E0922E9E for ; Wed, 26 Aug 2015 15:52:04 +0000 (UTC) Received: by labia3 with SMTP id ia3sf40461060lab.3 for ; Wed, 26 Aug 2015 08:52:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to: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=NsNiU+d3wLtxDhWCEwGLPdrb9wV1zsa6dopG42LZVzU=; b=Z7a5XAgJLMmpvyFPheIO9UD18+eL6cREh9md3gUf89At6X6lJtID+KHBGvNaGgNPjK EvKZ0v+qMjPaPmfKwfawhsOlDiUzNjWimxOVdHKPkWpPy7UuAnlt1OtQr5zppvS39aRJ g7SuarWJgxiQ8xzya+Z26XBviiDR3jHv9l67REDSQ+iZLDGDgrzn4kZcMtxMaLpg7y2W ch6dzbSRDEf/3FtZtKjuthoG3YJDIJqzrKcup3lnnYVPRnIt+jgcaTvULLH9sEcjdob7 btIEsJsH5o25VoKQfrbYLa6bVQhf4/XMVlufcm5nCrd7np6XWZ/iK1ZcCZBFUtFFGxf7 LxGg== X-Gm-Message-State: ALoCoQndvTlkryYL83J5GcON6zci0so24dt26IEaET+azrLsVu3lAp0kzgNBQz7rXJ3/3O4ZL3BT X-Received: by 10.180.79.66 with SMTP id h2mr1092858wix.3.1440604323084; Wed, 26 Aug 2015 08:52:03 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.198.236 with SMTP id jf12ls381556lac.89.gmail; Wed, 26 Aug 2015 08:52:02 -0700 (PDT) X-Received: by 10.152.21.166 with SMTP id w6mr31022007lae.20.1440604322896; Wed, 26 Aug 2015 08:52:02 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id w7si14730947lal.27.2015.08.26.08.52.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2015 08:52:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbtg9 with SMTP id tg9so123168489lbb.1 for ; Wed, 26 Aug 2015 08:52:02 -0700 (PDT) X-Received: by 10.152.170.230 with SMTP id ap6mr31728452lac.73.1440604322783; Wed, 26 Aug 2015 08:52:02 -0700 (PDT) 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.162.200 with SMTP id yc8csp4010714lbb; Wed, 26 Aug 2015 08:52:00 -0700 (PDT) X-Received: by 10.107.152.139 with SMTP id a133mr4709880ioe.145.1440604320382; Wed, 26 Aug 2015 08:52:00 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e3si12410250ioe.161.2015.08.26.08.51.59; Wed, 26 Aug 2015 08:52:00 -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; Received: by lists.linaro.org (Postfix, from userid 109) id 32AC16207B; Wed, 26 Aug 2015 15:51: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=-2.6 required=5.0 tests=BAYES_00, 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 89B6C6208F; Wed, 26 Aug 2015 15:49:48 +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 08FAA62077; Wed, 26 Aug 2015 15:49:23 +0000 (UTC) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com [209.85.215.48]) by lists.linaro.org (Postfix) with ESMTPS id D667E62034 for ; Wed, 26 Aug 2015 15:49:17 +0000 (UTC) Received: by labia3 with SMTP id ia3so57809411lab.3 for ; Wed, 26 Aug 2015 08:49:16 -0700 (PDT) X-Received: by 10.152.30.73 with SMTP id q9mr31998558lah.31.1440604156774; Wed, 26 Aug 2015 08:49:16 -0700 (PDT) Received: from localhost.localdomain (ppp91-76-161-180.pppoe.mtu-net.ru. [91.76.161.180]) by smtp.gmail.com with ESMTPSA id w3sm6870916lag.13.2015.08.26.08.49.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 26 Aug 2015 08:49:16 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 26 Aug 2015 18:49:04 +0300 Message-Id: <1440604147-24703-5-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440604147-24703-1-git-send-email-maxim.uvarov@linaro.org> References: <1440604147-24703-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv5 4/7] linux-generic: socket mmap: implement pktio_start and pktio_stop X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 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" 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.217.169 as permitted sender) smtp.mailfrom=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 Signed-off-by: Maxim Uvarov --- platform/linux-generic/pktio/socket_mmap.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index 7d42678..2e55672 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -486,6 +486,7 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, goto error; } + pktio_entry->s.state = STATE_START; return 0; error: @@ -497,6 +498,12 @@ static int sock_mmap_recv(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], unsigned len) { pkt_sock_mmap_t *const pkt_sock = &pktio_entry->s.pkt_sock_mmap; + + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + return pkt_mmap_v2_rx(pkt_sock->rx_ring.sock, &pkt_sock->rx_ring, pkt_table, len, pkt_sock->pool, pkt_sock->if_mac); @@ -506,6 +513,12 @@ static int sock_mmap_send(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], unsigned len) { pkt_sock_mmap_t *const pkt_sock = &pktio_entry->s.pkt_sock_mmap; + + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + return pkt_mmap_v2_tx(pkt_sock->tx_ring.sock, &pkt_sock->tx_ring, pkt_table, len); } @@ -535,11 +548,25 @@ static int sock_mmap_promisc_mode_get(pktio_entry_t *pktio_entry) pktio_entry->s.name); } +static int sock_mmap_start(pktio_entry_t *pktio_entry) +{ + pktio_entry->s.state = STATE_START; + return 0; +} + +static int sock_mmap_stop(pktio_entry_t *pktio_entry) +{ + pktio_entry->s.state = STATE_STOP; + return 0; +} + const pktio_if_ops_t sock_mmap_pktio_ops = { .init = NULL, .term = NULL, .open = sock_mmap_open, .close = sock_mmap_close, + .start = sock_mmap_start, + .stop = sock_mmap_stop, .recv = sock_mmap_recv, .send = sock_mmap_send, .mtu_get = sock_mmap_mtu_get,