From patchwork Wed Aug 19 13:18:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52547 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id D5AA322DB1 for ; Wed, 19 Aug 2015 13:20:55 +0000 (UTC) Received: by wicul11 with SMTP id ul11sf2625177wic.1 for ; Wed, 19 Aug 2015 06:20:55 -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=A/VExPvyuy9blGEKxvvXpuScUsuEUmXbUI69scuUdprTO+6xsx0kLp8oUA4ZAJ+pa9 YPmWzdYYNtXpGOZu0RfMed9+KHJhoT3l+2HTj1E+gJ1Wf8EcuRLbPjgDc7+mCP6ezr79 AWN8FPXNMTxq4oHwz9nb26PsqI/LivnOyqKIdwVeog9liHqYTxaKe0AUMw6Vqp087oLW E+oNTsNM897JTzvQaRG/57SDj8j6PbucBefzOvVpmr2xDcAVg6h3JJXYLonJ5bLO/nD1 UZbtW+3G3HMfe3DVKcr71bz3DREPP5WZBeDe/k4qpK/hLTkacdKOnOa2OjAhKSpc2cwL FqNw== X-Gm-Message-State: ALoCoQmSgJnkwPv18rBBMKrONQXGXd4KUJ/VYimfD5pt1gvhJTfMKuGKe1b2YWt9xvrM/+HbTbSt X-Received: by 10.194.71.39 with SMTP id r7mr3245663wju.0.1439990455130; Wed, 19 Aug 2015 06:20:55 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.103 with SMTP id l7ls26888laf.35.gmail; Wed, 19 Aug 2015 06:20:54 -0700 (PDT) X-Received: by 10.152.43.194 with SMTP id y2mr4658242lal.29.1439990454956; Wed, 19 Aug 2015 06:20:54 -0700 (PDT) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id dd5si482870lad.159.2015.08.19.06.20.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Aug 2015 06:20:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by lbbpu9 with SMTP id pu9so3028939lbb.3 for ; Wed, 19 Aug 2015 06:20:54 -0700 (PDT) X-Received: by 10.112.219.70 with SMTP id pm6mr11010484lbc.41.1439990454847; Wed, 19 Aug 2015 06:20:54 -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 yc8csp370815lbb; Wed, 19 Aug 2015 06:20:53 -0700 (PDT) X-Received: by 10.55.43.25 with SMTP id r25mr22451401qkh.77.1439990452826; Wed, 19 Aug 2015 06:20:52 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id k70si1031593qhc.26.2015.08.19.06.20.51; Wed, 19 Aug 2015 06:20:52 -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 D0DE661F6E; Wed, 19 Aug 2015 13:20:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252.ec2.internal 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 ip-10-142-244-252.ec2.internal (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 65AA561F94; Wed, 19 Aug 2015 13:19: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 8DA2061F65; Wed, 19 Aug 2015 13:19:45 +0000 (UTC) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by lists.linaro.org (Postfix) with ESMTPS id 4320961F69 for ; Wed, 19 Aug 2015 13:19:21 +0000 (UTC) Received: by wicne3 with SMTP id ne3so120542981wic.0 for ; Wed, 19 Aug 2015 06:19:20 -0700 (PDT) X-Received: by 10.194.240.6 with SMTP id vw6mr24613767wjc.1.1439990360507; Wed, 19 Aug 2015 06:19:20 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id h9sm1039322wjx.20.2015.08.19.06.19.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 19 Aug 2015 06:19:20 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 19 Aug 2015 16:18:58 +0300 Message-Id: <1439990341-12037-5-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439990341-12037-1-git-send-email-maxim.uvarov@linaro.org> References: <1439990341-12037-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCHv3 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.170 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,