From patchwork Thu Dec 25 14:25:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 42628 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BFB7626C9C for ; Thu, 25 Dec 2014 14:25:59 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id b13sf5779884wgh.9 for ; Thu, 25 Dec 2014 06:25:58 -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=g/oGEl4NvBMna0CMwCNslwyhAC6URH255ZETaKNJkcI=; b=Dw5KY4g1W5Hds6peqSmfsg7DK+H7xD0wPMV+shZ7VHgxDAvlC1LAcl2EJ6imZgXjvw QSCBiTELmSsj2pYhzch2nDOJlZrpNLcx2YDXQjKckovRfVweQ7Kjn1DPsHl3o7/EiHtk /+OkkwqqxOK4fHBtx7W5Omfor7FTS2dpqfqEAHj8DTrqV27/Yr2/o0xRKzxKRUC9rSTg eEFfZyv/lSAbX/oWsVlrG5tIgcPHqreTT+lZI2qVUCIr5dU8dSBRthlePo6+4ny0UCE5 GTJ1zr0Sm3YApBYI1etGRlWhSt2w+cwLtFhUFn68XSXnL5N5Aq3v4IGAWZ8pAHMxAjEa a8Pw== X-Gm-Message-State: ALoCoQk0BHE42oXhSXXp8LnaY08lYCPWfeU2p5sWUqCjyvjnu06bZHfSHD3OyK0R+loW0YLEm+57 X-Received: by 10.180.19.42 with SMTP id b10mr3991029wie.0.1419517558925; Thu, 25 Dec 2014 06:25:58 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.97 with SMTP id l1ls2019304lam.59.gmail; Thu, 25 Dec 2014 06:25:58 -0800 (PST) X-Received: by 10.112.14.6 with SMTP id l6mr39609641lbc.91.1419517558761; Thu, 25 Dec 2014 06:25:58 -0800 (PST) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id r2si28729795lar.126.2014.12.25.06.25.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Dec 2014 06:25:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by mail-lb0-f180.google.com with SMTP id l4so7680455lbv.39 for ; Thu, 25 Dec 2014 06:25:58 -0800 (PST) X-Received: by 10.112.84.225 with SMTP id c1mr17829253lbz.22.1419517558579; Thu, 25 Dec 2014 06:25:58 -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.142.69 with SMTP id ru5csp1892225lbb; Thu, 25 Dec 2014 06:25:57 -0800 (PST) X-Received: by 10.140.108.201 with SMTP id j67mr59455496qgf.89.1419517556746; Thu, 25 Dec 2014 06:25:56 -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 m107si29469048qge.114.2014.12.25.06.25.55 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 25 Dec 2014 06:25:56 -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 1Y49MN-00056d-Gu; Thu, 25 Dec 2014 14:25:51 +0000 Received: from mail-la0-f44.google.com ([209.85.215.44]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y49MG-00056X-Kb for lng-odp@lists.linaro.org; Thu, 25 Dec 2014 14:25:44 +0000 Received: by mail-la0-f44.google.com with SMTP id gd6so8073343lab.31 for ; Thu, 25 Dec 2014 06:25:38 -0800 (PST) X-Received: by 10.112.169.34 with SMTP id ab2mr39208385lbc.77.1419517538830; Thu, 25 Dec 2014 06:25:38 -0800 (PST) Received: from localhost.localdomain ([188.92.105.210]) by mx.google.com with ESMTPSA id nz3sm7347554lbb.25.2014.12.25.06.25.36 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Dec 2014 06:25:37 -0800 (PST) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 25 Dec 2014 17:25:29 +0300 Message-Id: <1419517529-18589-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] [PATCHv7] 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.180 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 --- .../linux-generic/include/odp_queue_internal.h | 11 ++++++++ platform/linux-generic/odp_packet_io.c | 29 +++++++++++++++++++++- platform/linux-generic/odp_schedule.c | 7 +++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index d5c8e4e..16734ee 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -129,6 +129,17 @@ 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_DESTROYED) || + (queue->s.status == QUEUE_STATUS_NOTSCHED) || + queue->s.pktin == ODP_PKTIO_INVALID) ? 0 : 1; +} #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 59590d2..dd069aa 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -381,7 +381,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..365dc98 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); @@ -296,7 +301,7 @@ static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[], */ if (odp_queue_type(queue) == ODP_QUEUE_TYPE_PKTIN && - !queue_is_destroyed(queue)) + queue_is_sched(queue)) odp_queue_enq(pri_q, desc_buf); continue;