From patchwork Fri Oct 10 18:28:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rosenboim, Leonid" X-Patchwork-Id: 38629 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 660D8202DB for ; Fri, 10 Oct 2014 18:28:46 +0000 (UTC) Received: by mail-lb0-f198.google.com with SMTP id 10sf2442172lbg.9 for ; Fri, 10 Oct 2014 11:28:45 -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:from:to:thread-topic:thread-index :importance:date:message-id:references:in-reply-to:accept-language :mime-version:cc:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-language:content-type:content-transfer-encoding; bh=4C0aiP3FkfYRoqBqrrbyeHrSQA3Fc+ryRarLUJ0R9WU=; b=BubqDFZmH1bOiJClHhkErZPgPaaYbgHgzTRFDjXW9Clu9FIQYAnlYj5gcRS9nsNk8/ L7IbHthiRMlJruauWkiK6MuhYELEOuAP+mkXIfJZ935vHn9dMYTZRYZ3pJWu7yj42aNZ 1MNP3qU+KNnfn7nsElJRgDM4ef2xBK/beYH3eHvb+eQISjxgGIdP4uLvxSN+wTZzKJME GwEh4xD1d4t8CG++mWO0VZi+Bm7cccJY2GRhFutDgnOpTu+ZuMrPOzyeFip9a2NwZ07u lctMPxzpl3zw9tKxQW9qLhLOyPGGipnkhKL7Wws6IickiYRg8N1Cajvou4u/Y4SuEaTW vg/w== X-Gm-Message-State: ALoCoQku06MFPaxzluc41+az08U1P4N1U0lkAik4+xgYJxbawMGkjkBClwWPd78wnF0jdsHd00MG X-Received: by 10.194.20.229 with SMTP id q5mr1286587wje.2.1412965725162; Fri, 10 Oct 2014 11:28:45 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.41 with SMTP id s9ls34364lae.41.gmail; Fri, 10 Oct 2014 11:28:45 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr6901587lad.40.1412965724975; Fri, 10 Oct 2014 11:28:44 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com [209.85.215.48]) by mx.google.com with ESMTPS id g2si7698537laf.43.2014.10.10.11.28.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 10 Oct 2014 11:28:44 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by mail-la0-f48.google.com with SMTP id gi9so3725147lab.7 for ; Fri, 10 Oct 2014 11:28:44 -0700 (PDT) X-Received: by 10.153.6.36 with SMTP id cr4mr6901557lad.40.1412965724636; Fri, 10 Oct 2014 11:28:44 -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.84.229 with SMTP id c5csp477953lbz; Fri, 10 Oct 2014 11:28:43 -0700 (PDT) X-Received: by 10.140.82.100 with SMTP id g91mr11299471qgd.30.1412965722965; Fri, 10 Oct 2014 11:28:42 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id h16si12373711qay.36.2014.10.10.11.28.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 10 Oct 2014 11:28:42 -0700 (PDT) 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 1Xcevh-0005uZ-4W; Fri, 10 Oct 2014 18:28:41 +0000 Received: from mail-bn1bon0059.outbound.protection.outlook.com ([157.56.111.59] helo=na01-bn1-obe.outbound.protection.outlook.com) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xceva-0005uQ-ID for lng-odp@lists.linaro.org; Fri, 10 Oct 2014 18:28:34 +0000 Received: from SN2PR07MB031.namprd07.prod.outlook.com (10.255.174.41) by SN2PR07MB064.namprd07.prod.outlook.com (10.255.174.152) with Microsoft SMTP Server (TLS) id 15.0.1044.10; Fri, 10 Oct 2014 18:28:21 +0000 Received: from SN2PR07MB031.namprd07.prod.outlook.com ([169.254.1.197]) by SN2PR07MB031.namprd07.prod.outlook.com ([169.254.1.197]) with mapi id 15.00.1049.012; Fri, 10 Oct 2014 18:28:21 +0000 From: "Rosenboim, Leonid" To: Stuart Haslam , "lng-odp@lists.linaro.org" Thread-Topic: [lng-odp] [RFC PATCH] Remove queue types ODP_QUEUE_TYPE_PKTIN and PKTOUT Thread-Index: AQHP5ACI84phNx2BSkSVwEHS6gz/epwpohZY Importance: high X-Priority: 1 Date: Fri, 10 Oct 2014 18:28:20 +0000 Message-ID: <1412965700261.42362@caviumnetworks.com> References: <1412886823-18347-1-git-send-email-stuart.haslam@arm.com> In-Reply-To: <1412886823-18347-1-git-send-email-stuart.haslam@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [64.2.3.195] x-microsoft-antispam: BCL:0;PCL:0;RULEID:;SRVR:SN2PR07MB064; x-exchange-antispam-report-test: UriScan:; x-forefront-prvs: 03607C04F0 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(377454003)(54356999)(80022003)(46102003)(92566001)(86362001)(575784001)(101416001)(31966008)(76176999)(2656002)(87936001)(50986999)(117636001)(76482002)(92726001)(15202345003)(19580405001)(36756003)(15975445006)(85806002)(19580395003)(81686999)(120916001)(99396003)(21056001)(66066001)(106356001)(105586002)(106116001)(4396001)(64706001)(20776003)(95666004)(77096002)(97736003)(99286002)(40100002)(122556002)(85306004)(85852003)(107046002); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR07MB064; H:SN2PR07MB031.namprd07.prod.outlook.com; FPR:; MLV:sfv; PTR:InfoNoRecords; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-OriginatorOrg: caviumnetworks.com X-Topics: patch Cc: "Kapoor, Prasun" , "Manoharan, Balasubramanian" Subject: Re: [lng-odp] [RFC PATCH] Remove queue types ODP_QUEUE_TYPE_PKTIN and PKTOUT 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: , 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: Leonid.Rosenboim@caviumnetworks.com 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.48 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 Content-Language: en-US Stuart, The declaration of a queue as PKTIN, PKTOUT during creation time is NOT an implementation detail, and was in my opinion deliberate and changing this will have serious consequences for our ability to support this API on Octeon SoCs. Octeon has queues implemented in hardware, and there are two distinct types of queues supported in the hardware of these chips: One type of queue is for scheduling incoming packets, timer events and generic events initiated by an application or packets in transit (SSO). The other type of queues are only used for packet output (PKO). For mapping an ODP queue to one of these, the implementation needs to know the queue's intended use to select and reserve a resource from the correct resource type. It seems your comprehension of the API is entirely focused on a software based implementation, without considering advanced network processors, and the ability of the ODP API to abstract these hardware mechanisms. The objective of enabling the mapping of network processor packet processing hardware to ODP APIs is an objective clearly set forth in ODP charter, and should not be neglected. Here are some documents in the public domain containing further information. http://university.caviumnetworks.com/downloads/Mini_version_of_Prog_Guide_EDU_July_2010.pdf. hactive.googlecode.com/files/CN50XX-HRM-V0.99E.pdf Detailed documentation on the latest SoC models and complete and updated programmers guide is available under NDA. - Leo diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 6055324..d566a19 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -473,7 +473,7 @@ static void *gen_recv_thread(void *arg) qparam.sched.group = ODP_SCHED_GROUP_DEFAULT; snprintf(inq_name, sizeof(inq_name), "%i-pktio_inq_def", (int)pktio); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; - inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam); + inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_SCHED, &qparam); if (inq_def == ODP_QUEUE_INVALID) { ODP_ERR(" [%02i] Error: pktio queue creation failed\n", thr); return NULL; diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index ec6c87a..ba90242 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -291,7 +291,7 @@ odp_queue_t polled_odp_queue_create(const char *name, my_queue = odp_queue_create(name, my_type, param); - if ((ODP_QUEUE_TYPE_SCHED == type) || (ODP_QUEUE_TYPE_PKTIN == type)) { + if (ODP_QUEUE_TYPE_SCHED == type) { poll_queues[num_polled_queues++] = my_queue; printf("%s: adding %d\n", __func__, my_queue); } @@ -572,7 +572,7 @@ void initialize_intf(char *intf) snprintf(inq_name, sizeof(inq_name), "%i-pktio_inq_def", (int)pktio); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; - inq_def = QUEUE_CREATE(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam); + inq_def = QUEUE_CREATE(inq_name, ODP_QUEUE_TYPE_SCHED, &qparam); if (ODP_QUEUE_INVALID == inq_def) { ODP_ERR("Error: pktio queue creation failed for %s\n", intf); exit(EXIT_FAILURE); diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c index 8aa0ba0..4f08dd2 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -165,7 +165,7 @@ static odp_pktio_t queue_mode_init_params(void *arg, odp_buffer_pool_t pool) snprintf(inq_name, sizeof(inq_name), "%i-pktio_inq_def", (int)pktio); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; - inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam); + inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_SCHED, &qparam); if (inq_def == ODP_QUEUE_INVALID) { ODP_ERR(" Error: pktio queue creation failed"); return ODP_PKTIO_INVALID; diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 145ae47..afb2cd2 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -151,7 +151,7 @@ static void *pktio_queue_thread(void *arg) snprintf(inq_name, sizeof(inq_name), "%i-pktio_inq_def", (int)pktio); inq_name[ODP_QUEUE_NAME_LEN - 1] = '\0'; - inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_PKTIN, &qparam); + inq_def = odp_queue_create(inq_name, ODP_QUEUE_TYPE_SCHED, &qparam); if (inq_def == ODP_QUEUE_INVALID) { ODP_ERR(" [%02i] Error: pktio queue creation failed\n", thr); return NULL; diff --git a/platform/linux-generic/include/api/odp_queue.h b/platform/linux-generic/include/api/odp_queue.h index 5e083f1..38ff272 100644 --- a/platform/linux-generic/include/api/odp_queue.h +++ b/platform/linux-generic/include/api/odp_queue.h @@ -42,8 +42,6 @@ typedef int odp_queue_type_t; #define ODP_QUEUE_TYPE_SCHED 0 /**< Scheduled queue */ #define ODP_QUEUE_TYPE_POLL 1 /**< Not scheduled queue */ -#define ODP_QUEUE_TYPE_PKTIN 2 /**< Packet input queue */ -#define ODP_QUEUE_TYPE_PKTOUT 3 /**< Packet output queue */ /** * ODP schedule priority diff --git a/platform/linux-generic/include/odp_queue_internal.h b/platform/linux-generic/include/odp_queue_internal.h index 8b6c517..5329d4f 100644 --- a/platform/linux-generic/include/odp_queue_internal.h +++ b/platform/linux-generic/include/odp_queue_internal.h @@ -95,6 +95,9 @@ void queue_unlock(queue_entry_t *queue); odp_buffer_t queue_sched_buf(odp_queue_t queue); int queue_sched_atomic(odp_queue_t handle); +void queue_set_pktin(queue_entry_t *queue, odp_pktio_t id); +void queue_set_pktout(queue_entry_t *queue, odp_pktio_t id); + static inline uint32_t queue_to_id(odp_queue_t handle) { return handle - 1; diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 0c30f0f..fbf23ff 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -65,13 +65,13 @@ int odp_pktio_init_global(void) snprintf(name, sizeof(name), "%i-pktio_outq_default", (int)id); name[ODP_QUEUE_NAME_LEN-1] = '\0'; - qid = odp_queue_create(name, ODP_QUEUE_TYPE_PKTOUT, NULL); + qid = odp_queue_create(name, ODP_QUEUE_TYPE_SCHED, NULL); if (qid == ODP_QUEUE_INVALID) return -1; pktio_entry->s.outq_default = qid; queue_entry = queue_to_qentry(qid); - queue_entry->s.pktout = id; + queue_set_pktout(queue_entry, id); } return 0; @@ -325,16 +325,12 @@ int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue) if (pktio_entry == NULL || qentry == NULL) return -1; - if (qentry->s.type != ODP_QUEUE_TYPE_PKTIN) - return -1; - lock_entry(pktio_entry); pktio_entry->s.inq_default = queue; unlock_entry(pktio_entry); queue_lock(qentry); - qentry->s.pktin = id; - qentry->s.status = QUEUE_STATUS_SCHED; + queue_set_pktin(qentry, id); queue_unlock(qentry); odp_schedule_queue(queue, qentry->s.param.sched.prio); diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 1318bcd..1f0e33a 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -53,6 +53,8 @@ static void queue_init(queue_entry_t *queue, const char *name, { strncpy(queue->s.name, name, ODP_QUEUE_NAME_LEN - 1); queue->s.type = type; + queue->s.pktin = ODP_PKTIO_INVALID; + queue->s.pktout = ODP_PKTIO_INVALID; if (param) { memcpy(&queue->s.param, param, sizeof(odp_queue_param_t)); @@ -64,27 +66,10 @@ static void queue_init(queue_entry_t *queue, const char *name, queue->s.param.sched.group = ODP_SCHED_GROUP_DEFAULT; } - switch (type) { - case ODP_QUEUE_TYPE_PKTIN: - queue->s.enqueue = pktin_enqueue; - queue->s.dequeue = pktin_dequeue; - queue->s.enqueue_multi = pktin_enq_multi; - queue->s.dequeue_multi = pktin_deq_multi; - break; - case ODP_QUEUE_TYPE_PKTOUT: - queue->s.enqueue = pktout_enqueue; - queue->s.dequeue = pktout_dequeue; - queue->s.enqueue_multi = pktout_enq_multi; - queue->s.dequeue_multi = pktout_deq_multi; - break; - default: - queue->s.enqueue = queue_enq; - queue->s.dequeue = queue_deq; - queue->s.enqueue_multi = queue_enq_multi; - queue->s.dequeue_multi = queue_deq_multi; - break; - } - + queue->s.enqueue = queue_enq; + queue->s.dequeue = queue_deq; + queue->s.enqueue_multi = queue_enq_multi; + queue->s.dequeue_multi = queue_deq_multi; queue->s.head = NULL; queue->s.tail = NULL; queue->s.sched_buf = ODP_BUFFER_INVALID; @@ -162,8 +147,7 @@ odp_queue_t odp_queue_create(const char *name, odp_queue_type_t type, if (queue->s.status == QUEUE_STATUS_FREE) { queue_init(queue, name, type, param); - if (type == ODP_QUEUE_TYPE_SCHED || - type == ODP_QUEUE_TYPE_PKTIN) + if (type == ODP_QUEUE_TYPE_SCHED) queue->s.status = QUEUE_STATUS_NOTSCHED; else queue->s.status = QUEUE_STATUS_READY; @@ -175,8 +159,7 @@ odp_queue_t odp_queue_create(const char *name, odp_queue_type_t type, UNLOCK(&queue->s.lock); } - if (handle != ODP_QUEUE_INVALID && - (type == ODP_QUEUE_TYPE_SCHED || type == ODP_QUEUE_TYPE_PKTIN)) { + if (handle != ODP_QUEUE_INVALID && type == ODP_QUEUE_TYPE_SCHED) { odp_buffer_t buf; buf = odp_schedule_buffer_alloc(handle); @@ -353,8 +337,7 @@ odp_buffer_hdr_t *queue_deq(queue_entry_t *queue) if (queue->s.head == NULL) { /* Already empty queue */ - if (queue->s.status == QUEUE_STATUS_SCHED && - queue->s.type != ODP_QUEUE_TYPE_PKTIN) + if (queue->s.status == QUEUE_STATUS_SCHED) queue->s.status = QUEUE_STATUS_NOTSCHED; } else { buf_hdr = queue->s.head; @@ -381,8 +364,7 @@ int queue_deq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num) if (queue->s.head == NULL) { /* Already empty queue */ - if (queue->s.status == QUEUE_STATUS_SCHED && - queue->s.type != ODP_QUEUE_TYPE_PKTIN) + if (queue->s.status == QUEUE_STATUS_SCHED) queue->s.status = QUEUE_STATUS_NOTSCHED; } else { odp_buffer_hdr_t *hdr = queue->s.head; @@ -453,3 +435,24 @@ void queue_unlock(queue_entry_t *queue) { UNLOCK(&queue->s.lock); } + +void queue_set_pktin(queue_entry_t *queue, odp_pktio_t pktio_id) +{ + queue->s.pktin = pktio_id; + queue->s.enqueue = pktin_enqueue; + queue->s.dequeue = pktin_dequeue; + queue->s.enqueue_multi = pktin_enq_multi; + queue->s.dequeue_multi = pktin_deq_multi; + if (queue->s.type == ODP_QUEUE_TYPE_SCHED) + queue->s.status = QUEUE_STATUS_SCHED; +} + +void queue_set_pktout(queue_entry_t *queue, odp_pktio_t pktio_id) +{ + queue->s.pktout = pktio_id; + queue->s.enqueue = pktout_enqueue; + queue->s.dequeue = pktout_dequeue; + queue->s.enqueue_multi = pktout_enq_multi; + queue->s.dequeue_multi = pktout_deq_multi; +} + diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 1bf819b..5742196 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -301,8 +301,8 @@ static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[], /* Remove empty queue from scheduling, * except packet input queues */ - if (odp_queue_type(queue) == - ODP_QUEUE_TYPE_PKTIN) + queue_entry_t *qentry = queue_to_qentry(queue); + if (qentry->s.pktin != ODP_PKTIO_INVALID) odp_queue_enq(pri_q, desc_buf); continue;