From patchwork Fri Jan 16 12:58:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 43237 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 ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6803F240BA for ; Fri, 16 Jan 2015 12:59:12 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id w7sf11042851lbi.0 for ; Fri, 16 Jan 2015 04:59:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id: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=3KN2cMDdoOoGaWKSYhBtto7kUoZMLBtZpT+XgWcCD+M=; b=FyplzzZTyVde16o1s+N7Nkw0ZMJzqSwA94Fl2jQQV53stz5o/ZaH+UnjZQNvh3hrRN xHGaHKYRNqHvjUtEQiKROzZ/VjbiYqdJe5SxIkWeOz2H14aeLwoWxKA8BvXFEIb6+ziJ z4+ibJOwinrOtdkfo0enPbBDAIvZPq9DNXJ2OkYlhfhCqIqHc+VbFYA8PHvhvSjokla7 zUH0wXP7i3zbETvOXyPYjOkPO91SAmxloZcqXd9O4mQgD4PKS/GCJhwqmjckSoQT5Wfh ae2Yp0i3ir/7JUqCj2FZF5ew5m4FzXwOjguL9a3NxZjDTJoVDE4+CspviY8ivIR4zO27 og/A== X-Gm-Message-State: ALoCoQnvFcrV2Jw0XRz2KqzOvP+Lcugj8J+rhQoWEDrbpRVGgpxFE89odZd/RmyYwpCkvDqcSTjE X-Received: by 10.180.93.165 with SMTP id cv5mr423860wib.6.1421413151304; Fri, 16 Jan 2015 04:59:11 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.98 with SMTP id l2ls342244laf.73.gmail; Fri, 16 Jan 2015 04:59:11 -0800 (PST) X-Received: by 10.112.24.130 with SMTP id u2mr15247239lbf.57.1421413151143; Fri, 16 Jan 2015 04:59:11 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id p4si4382489lag.35.2015.01.16.04.59.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 04:59:11 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id u10so18204885lbd.13 for ; Fri, 16 Jan 2015 04:59:11 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr15461140laz.71.1421413151043; Fri, 16 Jan 2015 04:59:11 -0800 (PST) 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.9.200 with SMTP id c8csp297914lbb; Fri, 16 Jan 2015 04:59:10 -0800 (PST) X-Received: by 10.140.86.233 with SMTP id p96mr23723815qgd.49.1421413149185; Fri, 16 Jan 2015 04:59:09 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id v47si5821912qgd.77.2015.01.16.04.59.07 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 16 Jan 2015 04:59:09 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YC6US-0007t4-RT; Fri, 16 Jan 2015 12:59:04 +0000 Received: from mail-lb0-f178.google.com ([209.85.217.178]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YC6UI-0007sv-DQ for lng-odp@lists.linaro.org; Fri, 16 Jan 2015 12:58:54 +0000 Received: by mail-lb0-f178.google.com with SMTP id u14so18281092lbd.9 for ; Fri, 16 Jan 2015 04:58:48 -0800 (PST) X-Received: by 10.152.21.134 with SMTP id v6mr15376496lae.13.1421413128714; Fri, 16 Jan 2015 04:58:48 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id ki4sm1452787lac.1.2015.01.16.04.58.46 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 Jan 2015 04:58:47 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Fri, 16 Jan 2015 15:58:17 +0300 Message-Id: <1421413097-17325-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 1.8.5.1.163.gd7aced9 X-Topics: patch Subject: [lng-odp] [PATCHv8] linux-generic: fix odp_pktio_inq_remdef X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 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-bounces@lists.linaro.org 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.182 as permitted sender) smtp.mail=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 Correctly remove queue from packet i/o and remove it from scheduler. Signed-off-by: Maxim Uvarov Tested-by: Anders Roxell --- v8: fixed Stuart comments and added test. Implementation of odp_pktio_inq_remdef also fixes segfault in existance pktio test. .../linux-generic/include/odp_queue_internal.h | 10 ++++++++ platform/linux-generic/odp_packet_io.c | 29 +++++++++++++++++++++- platform/linux-generic/odp_schedule.c | 5 ++++ test/validation/odp_pktio.c | 17 +++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index d5c8e4e..dbc42c0 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -129,6 +129,16 @@ static inline int queue_is_destroyed(odp_queue_t handle) return queue->s.status == QUEUE_STATUS_DESTROYED; } + +static inline int queue_is_sched(odp_queue_t handle) +{ + queue_entry_t *queue; + + queue = queue_to_qentry(handle); + + return ((queue->s.status == QUEUE_STATUS_SCHED) && + (queue->s.pktin != ODP_PKTIO_INVALID)); +} #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index cd109d2..04de756 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -429,7 +429,34 @@ int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue) int odp_pktio_inq_remdef(odp_pktio_t id) { - return odp_pktio_inq_setdef(id, ODP_QUEUE_INVALID); + pktio_entry_t *pktio_entry = get_pktio_entry(id); + odp_queue_t queue; + queue_entry_t *qentry; + + if (pktio_entry == NULL) + return -1; + + lock_entry(pktio_entry); + queue = pktio_entry->s.inq_default; + qentry = queue_to_qentry(queue); + + queue_lock(qentry); + if (qentry->s.status == QUEUE_STATUS_FREE) { + queue_unlock(qentry); + unlock_entry(pktio_entry); + return -1; + } + + qentry->s.enqueue = queue_enq_dummy; + qentry->s.enqueue_multi = queue_enq_multi_dummy; + qentry->s.status = QUEUE_STATUS_NOTSCHED; + qentry->s.pktin = ODP_PKTIO_INVALID; + queue_unlock(qentry); + + pktio_entry->s.inq_default = ODP_QUEUE_INVALID; + unlock_entry(pktio_entry); + + return 0; } odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id) diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index a14de4f..775b788 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -286,6 +286,11 @@ static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[], desc = odp_buffer_addr(desc_buf); queue = desc->queue; + if (odp_queue_type(queue) == + ODP_QUEUE_TYPE_PKTIN && + !queue_is_sched(queue)) + continue; + num = odp_queue_deq_multi(queue, sched_local.buf, max_deq); diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c index d1eb0d5..03e954a 100644 --- a/test/validation/odp_pktio.c +++ b/test/validation/odp_pktio.c @@ -379,6 +379,7 @@ static void pktio_test_txrx(odp_queue_type_t q_type, int num_pkts) pktio_txrx_multi(&pktios[0], &pktios[if_b], num_pkts); for (i = 0; i < num_ifaces; ++i) { + odp_pktio_inq_remdef(pktios[i].id); ret = odp_pktio_close(pktios[i].id); CU_ASSERT(ret == 0); } @@ -472,6 +473,21 @@ static void test_odp_pktio_mac(void) return; } +static void test_odp_pktio_inq_remdef(void) +{ + odp_pktio_t pktio = create_pktio(iface_name[0]); + int i; + + CU_ASSERT(pktio != ODP_PKTIO_INVALID); + CU_ASSERT(create_inq(pktio) == 0); + CU_ASSERT(odp_pktio_inq_remdef(pktio) == 0); + + for (i = 0; i < 100; i++) + odp_schedule(NULL, ODP_TIME_MSEC); + + CU_ASSERT(odp_pktio_close(pktio) == 0); +} + static void test_odp_pktio_open(void) { odp_pktio_t pktio; @@ -582,6 +598,7 @@ CU_TestInfo pktio_tests[] = { {"pktio mtu", test_odp_pktio_mtu}, {"pktio promisc mode", test_odp_pktio_promisc}, {"pktio mac", test_odp_pktio_mac}, + {"pktio inq_remdef", test_odp_pktio_inq_remdef}, CU_TEST_INFO_NULL };