From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 4C8ACC320 for ; Thu, 4 Jun 2015 19:48:26 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 04 Jun 2015 10:48:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,553,1427785200"; d="scan'208";a="741075707" Received: from irsmsx110.ger.corp.intel.com ([163.33.3.25]) by orsmga002.jf.intel.com with ESMTP; 04 Jun 2015 10:48:22 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.59]) by irsmsx110.ger.corp.intel.com ([163.33.3.25]) with mapi id 14.03.0224.002; Thu, 4 Jun 2015 18:48:21 +0100 From: "Dumitrescu, Cristian" To: Stephen Hemminger Thread-Topic: [PATCH 5/5] rte_sched: allow reading without clearing Thread-Index: AQHQmKhpLI+mwMg7FkqQhg6w+j4wC52cqpEQ Date: Thu, 4 Jun 2015 17:48:21 +0000 Message-ID: <3EB4FA525960D640B5BDFFD6A3D89126323714E9@IRSMSX108.ger.corp.intel.com> References: <1432750217-4186-1-git-send-email-stephen@networkplumber.org> <1432750217-4186-6-git-send-email-stephen@networkplumber.org> In-Reply-To: <1432750217-4186-6-git-send-email-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 5/5] rte_sched: allow reading without clearing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jun 2015 17:48:27 -0000 > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Wednesday, May 27, 2015 7:10 PM > To: Dumitrescu, Cristian > Cc: dev@dpdk.org; Stephen Hemminger > Subject: [PATCH 5/5] rte_sched: allow reading without clearing >=20 > The rte_sched statistics API should allow reading statistics without > clearing. Make auto-clear optional. In this version, this is handled > by deprecating the old API and adding a new one. >=20 > Signed-off-by: Stephen Hemminger > --- > app/test/test_sched.c | 4 +-- > lib/librte_sched/rte_sched.c | 65 +++++++++++++++++++++-------= ------ > lib/librte_sched/rte_sched.h | 37 ++++++++++++++----- > lib/librte_sched/rte_sched_version.map | 2 ++ > 4 files changed, 74 insertions(+), 34 deletions(-) >=20 > diff --git a/app/test/test_sched.c b/app/test/test_sched.c > index c7239f8..03f89b4 100644 > --- a/app/test/test_sched.c > +++ b/app/test/test_sched.c > @@ -198,13 +198,13 @@ test_sched(void) >=20 > struct rte_sched_subport_stats subport_stats; > uint32_t tc_ov; > - rte_sched_subport_read_stats(port, SUBPORT, &subport_stats, > &tc_ov); > + rte_sched_subport_stats(port, SUBPORT, &subport_stats, &tc_ov, > 1); > #if 0 > TEST_ASSERT_EQUAL(subport_stats.n_pkts_tc[TC-1], 10, "Wrong > subport stats\n"); > #endif > struct rte_sched_queue_stats queue_stats; > uint16_t qlen; > - rte_sched_queue_read_stats(port, QUEUE, &queue_stats, &qlen); > + rte_sched_queue_stats(port, QUEUE, &queue_stats, &qlen, 1); > #if 0 > TEST_ASSERT_EQUAL(queue_stats.n_pkts, 10, "Wrong queue > stats\n"); > #endif > diff --git a/lib/librte_sched/rte_sched.c b/lib/librte_sched/rte_sched.c > index 9c9419d..b4d7edd 100644 > --- a/lib/librte_sched/rte_sched.c > +++ b/lib/librte_sched/rte_sched.c > @@ -965,61 +965,78 @@ rte_sched_port_pkt_read_color(const struct > rte_mbuf *pkt) > } >=20 > int > -rte_sched_subport_read_stats(struct rte_sched_port *port, > - uint32_t subport_id, > - struct rte_sched_subport_stats *stats, > - uint32_t *tc_ov) > +rte_sched_subport_stats(struct rte_sched_port *port, uint32_t > subport_id, > + struct rte_sched_subport_stats *stats, > + uint32_t *tc_ov, int clear) > { > struct rte_sched_subport *s; >=20 > /* Check user parameters */ > - if ((port =3D=3D NULL) || > - (subport_id >=3D port->n_subports_per_port) || > - (stats =3D=3D NULL) || > - (tc_ov =3D=3D NULL)) { > + if (port =3D=3D NULL || subport_id >=3D port->n_subports_per_port) > return -1; > - } > + > s =3D port->subport + subport_id; >=20 > /* Copy subport stats and clear */ > - memcpy(stats, &s->stats, sizeof(struct rte_sched_subport_stats)); > - memset(&s->stats, 0, sizeof(struct rte_sched_subport_stats)); > + if (stats) > + *stats =3D s->stats; > + if (clear) > + memset(&s->stats, 0, sizeof(struct > rte_sched_subport_stats)); >=20 > /* Subport TC ovesubscription status */ > - *tc_ov =3D s->tc_ov; > + if (tc_ov) > + *tc_ov =3D s->tc_ov; >=20 > return 0; > } >=20 > +/* Deprecated API, always clears */ > int > -rte_sched_queue_read_stats(struct rte_sched_port *port, > - uint32_t queue_id, > - struct rte_sched_queue_stats *stats, > - uint16_t *qlen) > +rte_sched_subport_read_stats(struct rte_sched_port *port, uint32_t > subport_id, > + struct rte_sched_subport_stats *stats, > + uint32_t *tc_ov) > +{ > + return rte_sched_subport_stats(port, subport_id, stats, tc_ov, 1); > +} > + > +int > +rte_sched_queue_stats(struct rte_sched_port *port, uint32_t queue_id, > + struct rte_sched_queue_stats *stats, > + uint16_t *qlen, int clear) > { > struct rte_sched_queue *q; > struct rte_sched_queue_extra *qe; >=20 > /* Check user parameters */ > - if ((port =3D=3D NULL) || > - (queue_id >=3D rte_sched_port_queues_per_port(port)) || > - (stats =3D=3D NULL) || > - (qlen =3D=3D NULL)) { > + if (port =3D=3D NULL || queue_id >=3D > rte_sched_port_queues_per_port(port)) > return -1; > - } > + > q =3D port->queue + queue_id; > qe =3D port->queue_extra + queue_id; >=20 > /* Copy queue stats and clear */ > - memcpy(stats, &qe->stats, sizeof(struct rte_sched_queue_stats)); > - memset(&qe->stats, 0, sizeof(struct rte_sched_queue_stats)); > + if (stats) > + *stats =3D qe->stats; > + if (clear) > + memset(&qe->stats, 0, sizeof(struct > rte_sched_queue_stats)); >=20 > /* Queue length */ > - *qlen =3D q->qw - q->qr; > + if (qlen) > + *qlen =3D q->qw - q->qr; >=20 > return 0; > } >=20 > +/* Deprecated API, always clears */ > +int > +rte_sched_queue_read_stats(struct rte_sched_port *port, > + uint32_t queue_id, > + struct rte_sched_queue_stats *stats, > + uint16_t *qlen) > +{ > + return rte_sched_queue_stats(port, queue_id, stats, qlen, 1); > +} > + > static inline uint32_t > rte_sched_port_qindex(struct rte_sched_port *port, uint32_t subport, > uint32_t pipe, uint32_t traffic_class, uint32_t queue) > { > diff --git a/lib/librte_sched/rte_sched.h b/lib/librte_sched/rte_sched.h > index f7c0b8e..053454c 100644 > --- a/lib/librte_sched/rte_sched.h > +++ b/lib/librte_sched/rte_sched.h > @@ -300,14 +300,24 @@ rte_sched_port_get_memory_footprint(struct > rte_sched_port_params *params); > * @param tc_ov > * Pointer to pre-allocated 4-entry array where the oversubscription s= tatus > for > * each of the 4 subport traffic classes should be stored. > + * @parm clear > + * Reset statistics after read > + * > * @return > * 0 upon success, error code otherwise > */ > int > -rte_sched_subport_read_stats(struct rte_sched_port *port, > - uint32_t subport_id, > - struct rte_sched_subport_stats *stats, > - uint32_t *tc_ov); > +rte_sched_subport_stats(struct rte_sched_port *port, uint32_t > subport_id, > + struct rte_sched_subport_stats *stats, > + uint32_t *tc_ov, int clear); > + > +/* Note: use rte_sched_subport_stats() instead, > + * which allows separate read and clear. > + */ > +int > +rte_sched_subport_read_stats(struct rte_sched_port *port, uint32_t > subport_id, > + struct rte_sched_subport_stats *stats, > + uint32_t *tc_ov) __attribute__((deprecated)); >=20 > /** > * Hierarchical scheduler queue statistics read > @@ -321,14 +331,25 @@ rte_sched_subport_read_stats(struct > rte_sched_port *port, > * counters should be stored > * @param qlen > * Pointer to pre-allocated variable where the current queue length sh= ould > be stored. > + * @parm clear > + * Reset statistics after read > * @return > * 0 upon success, error code otherwise > */ > int > -rte_sched_queue_read_stats(struct rte_sched_port *port, > - uint32_t queue_id, > - struct rte_sched_queue_stats *stats, > - uint16_t *qlen); > +rte_sched_queue_stats(struct rte_sched_port *port, > + uint32_t queue_id, > + struct rte_sched_queue_stats *stats, > + uint16_t *qlen, int clear); > + > + > +/* Note: use rte_sched_queue_stats() instead > + * which allows separate read and clear. > + */ > +int > +rte_sched_queue_read_stats(struct rte_sched_port *port, uint32_t > queue_id, > + struct rte_sched_queue_stats *stats, > + uint16_t *qlen) __attribute__((deprecated)); >=20 > /** > * Scheduler hierarchy path write to packet descriptor. Typically called= by the > diff --git a/lib/librte_sched/rte_sched_version.map > b/lib/librte_sched/rte_sched_version.map > index 6626a74..cdbaeb7 100644 > --- a/lib/librte_sched/rte_sched_version.map > +++ b/lib/librte_sched/rte_sched_version.map > @@ -14,8 +14,10 @@ DPDK_2.0 { > rte_sched_port_enqueue; > rte_sched_port_free; > rte_sched_port_get_memory_footprint; > + rte_sched_queue_stats; > rte_sched_queue_read_stats; > rte_sched_subport_config; > + rte_sched_subport_stats; > rte_sched_subport_read_stats; > rte_sched_port_pkt_write; > rte_sched_port_pkt_read_tree_path; > -- > 2.1.4 If we plan to obsolete API function rte_sched_queue_read_stats() and have p= eople use the new API function rte_sched_queue_stats(), we should replace e= very usage of the obsolete function with call to new function. We need to d= o this in examples/qos_sched and app/test.