From patchwork Fri Aug 14 11:03:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 52430 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id E747D2031F for ; Fri, 14 Aug 2015 11:06:18 +0000 (UTC) Received: by lbsm2 with SMTP id m2sf25782524lbs.1 for ; Fri, 14 Aug 2015 04:06:17 -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=ZPM+9e0Ezyk6Q/2kRNIufc0ppwRBb2g9G5DnJ1X+UU0=; b=fTCS0hVxrnlVqmc2d+bOUMlOJWMZASGzWcU344+P1IUanhtLXSNDMaBOyPYuiwfLqp T7a44imHoElawbPDqf2Zzs9iswdUDI74rznGGoLcHCBU3N1op0h+B14IXA9fjF0W3H4D jL4r444fb2TuSvn/hPIJZ6Tl4LQM9mKpzKbLmflvzWkABktEfOSTXi3ZT7pl+LXqYbeF 1eLDnceqYsYiwGt/pL9zqASjZ8+kVPPDxlL1h30yNCH7ww2ho2UNyqcYMHZUOmKenkSQ PlZgbR9NKI9s2TEal6KI6zAplbf8z4AID96Vk8DRqDIqxYUL2r+3apVvLf72VfzMw+sb Qjdw== X-Gm-Message-State: ALoCoQm0obkYDr7fTnmGynWQj5gkC2bXJ4JTuZCIDJqgmZExLm8DubFAEO39B7Hd8pKbGxw8VQmH X-Received: by 10.180.96.226 with SMTP id dv2mr813289wib.2.1439550377889; Fri, 14 Aug 2015 04:06:17 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.164 with SMTP id az4ls382888lab.81.gmail; Fri, 14 Aug 2015 04:06:17 -0700 (PDT) X-Received: by 10.152.43.77 with SMTP id u13mr42247318lal.96.1439550377725; Fri, 14 Aug 2015 04:06:17 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id pk4si5765681lbb.17.2015.08.14.04.06.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Aug 2015 04:06:17 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by lalv9 with SMTP id v9so41789124lal.0 for ; Fri, 14 Aug 2015 04:06:17 -0700 (PDT) X-Received: by 10.152.5.228 with SMTP id v4mr42714121lav.36.1439550377246; Fri, 14 Aug 2015 04:06:17 -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.7.198 with SMTP id l6csp1532637lba; Fri, 14 Aug 2015 04:06:16 -0700 (PDT) X-Received: by 10.50.66.197 with SMTP id h5mr1898514igt.82.1439550375505; Fri, 14 Aug 2015 04:06:15 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 140si3531191ioe.178.2015.08.14.04.06.14; Fri, 14 Aug 2015 04:06:15 -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 64C9961E6B; Fri, 14 Aug 2015 11:06:14 +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 7D7DB61EE1; Fri, 14 Aug 2015 11:04:21 +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 4C98A61EE6; Fri, 14 Aug 2015 11:04:18 +0000 (UTC) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by lists.linaro.org (Postfix) with ESMTPS id 2C36461E81 for ; Fri, 14 Aug 2015 11:03:24 +0000 (UTC) Received: by wibhh20 with SMTP id hh20so16784901wib.0 for ; Fri, 14 Aug 2015 04:03:23 -0700 (PDT) X-Received: by 10.180.87.71 with SMTP id v7mr5770726wiz.74.1439550203368; Fri, 14 Aug 2015 04:03:23 -0700 (PDT) Received: from localhost.localdomain ([87.120.178.39]) by smtp.gmail.com with ESMTPSA id c11sm2538630wib.1.2015.08.14.04.03.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Aug 2015 04:03:22 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 14 Aug 2015 14:03:02 +0300 Message-Id: <1439550184-28383-6-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1439550184-28383-1-git-send-email-maxim.uvarov@linaro.org> References: <1439550184-28383-1-git-send-email-maxim.uvarov@linaro.org> X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2 5/7] linux-generic: socket: 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.215.41 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.c | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 55c3594..7db9747 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -248,6 +248,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, goto error; } + pktio_entry->s.state = STATE_START; return 0; error: @@ -296,6 +297,11 @@ static int sock_basic_recv(pktio_entry_t *pktio_entry, uint8_t *pkt_buf; int nb_rx = 0; + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + /* recvfrom: * If the address argument is not a null pointer * and the protocol does not provide the source address of @@ -355,6 +361,11 @@ static int sock_basic_send(pktio_entry_t *pktio_entry, unsigned nb_tx; int ret; + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + sockfd = pkt_sock->sockfd; flags = MSG_DONTWAIT; i = 0; @@ -400,6 +411,11 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int recv_msgs; int i; + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + if (odp_unlikely(len > ODP_PACKET_SOCKET_MAX_BURST_RX)) return -1; @@ -465,6 +481,11 @@ static int sock_mmsg_send(pktio_entry_t *pktio_entry, unsigned sent_msgs = 0; unsigned flags; + if (pktio_entry->s.state == STATE_STOP) { + __odp_errno = EPERM; + return -1; + } + if (odp_unlikely(len > ODP_PACKET_SOCKET_MAX_BURST_TX)) return -1; @@ -534,11 +555,25 @@ static int sock_promisc_mode_get(pktio_entry_t *pktio_entry) pktio_entry->s.name); } +static int sock_start(pktio_entry_t *pktio_entry) +{ + pktio_entry->s.state = STATE_START; + return 0; +} + +static int sock_stop(pktio_entry_t *pktio_entry) +{ + pktio_entry->s.state = STATE_STOP; + return 0; +} + const pktio_if_ops_t sock_basic_pktio_ops = { .init = NULL, .term = NULL, .open = sock_basic_open, .close = sock_close, + .start = sock_start, + .stop = sock_stop, .recv = sock_basic_recv, .send = sock_basic_send, .mtu_get = sock_mtu_get, @@ -552,6 +587,8 @@ const pktio_if_ops_t sock_mmsg_pktio_ops = { .term = NULL, .open = sock_mmsg_open, .close = sock_close, + .start = sock_start, + .stop = sock_stop, .recv = sock_mmsg_recv, .send = sock_mmsg_send, .mtu_get = sock_mtu_get,