From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 2A2FF2716 for ; Tue, 5 May 2015 17:12:35 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP; 05 May 2015 08:11:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,373,1427785200"; d="scan'208";a="489630795" Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by FMSMGA003.fm.intel.com with ESMTP; 05 May 2015 08:11:29 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.246]) by IRSMSX151.ger.corp.intel.com ([169.254.4.46]) with mapi id 14.03.0224.002; Tue, 5 May 2015 16:11:28 +0100 From: "Dumitrescu, Cristian" To: "Jastrzebski, MichalX K" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2] pipeline: add statistics for librte_pipeline ports and tables Thread-Index: AQHQgz93PTXJCOBl8EytCIs463gLPJ1thNzw Date: Tue, 5 May 2015 15:11:27 +0000 Message-ID: <3EB4FA525960D640B5BDFFD6A3D891263235BBA3@IRSMSX108.ger.corp.intel.com> References: <1430396143-10936-1-git-send-email-michalx.k.jastrzebski@intel.com> In-Reply-To: <1430396143-10936-1-git-send-email-michalx.k.jastrzebski@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] pipeline: add statistics for librte_pipeline ports and tables 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: Tue, 05 May 2015 15:12:36 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Michal Jastrzebski > Sent: Thursday, April 30, 2015 1:16 PM > To: dev@dpdk.org > Cc: Wodkowski, PawelX > Subject: [dpdk-dev] [PATCH v2] pipeline: add statistics for librte_pipeli= ne > ports and tables >=20 > From: Pawel Wodkowski >=20 > This patch adds statistics collection for librte_pipeline. > Those statistics ale disabled by default during build time. >=20 > Signed-off-by: Pawel Wodkowski > --- > config/common_bsdapp | 1 + > config/common_linuxapp | 1 + > lib/librte_pipeline/rte_pipeline.c | 185 > +++++++++++++++++++++++++++++++++--- > lib/librte_pipeline/rte_pipeline.h | 99 +++++++++++++++++++ > 4 files changed, 275 insertions(+), 11 deletions(-) >=20 > diff --git a/config/common_bsdapp b/config/common_bsdapp > index 1d0f5b2..e4f0bf5 100644 > --- a/config/common_bsdapp > +++ b/config/common_bsdapp > @@ -414,6 +414,7 @@ CONFIG_RTE_TABLE_LPM_STATS_COLLECT=3Dn > # Compile librte_pipeline > # > CONFIG_RTE_LIBRTE_PIPELINE=3Dy > +CONFIG_RTE_PIPELINE_STATS_COLLECT=3Dn >=20 > # > # Compile librte_kni > diff --git a/config/common_linuxapp b/config/common_linuxapp > index 8b01ca9..05553d9 100644 > --- a/config/common_linuxapp > +++ b/config/common_linuxapp > @@ -421,6 +421,7 @@ CONFIG_RTE_TABLE_LPM_STATS_COLLECT=3Dn > # Compile librte_pipeline > # > CONFIG_RTE_LIBRTE_PIPELINE=3Dy > +CONFIG_RTE_PIPELINE_STATS_COLLECT=3Dn >=20 > # > # Compile librte_kni > diff --git a/lib/librte_pipeline/rte_pipeline.c > b/lib/librte_pipeline/rte_pipeline.c > index 36d92c9..69bf003 100644 > --- a/lib/librte_pipeline/rte_pipeline.c > +++ b/lib/librte_pipeline/rte_pipeline.c > @@ -48,6 +48,17 @@ >=20 > #define RTE_TABLE_INVALID UINT32_MAX >=20 > +#ifdef RTE_PIPELINE_STATS_COLLECT > +#define RTE_PIPELINE_STATS_ADD(counter, val) \ > + ({ (counter) +=3D (val); }) > + > +#define RTE_PIPELINE_STATS_ADD_M(counter, mask) \ > + ({ (counter) +=3D __builtin_popcountll(mask); }) > +#else > +#define RTE_PIPELINE_STATS_ADD(counter, val) > +#define RTE_PIPELINE_STATS_ADD_M(counter, mask) > +#endif > + > struct rte_port_in { > /* Input parameters */ > struct rte_port_in_ops ops; > @@ -63,6 +74,8 @@ struct rte_port_in { >=20 > /* List of enabled ports */ > struct rte_port_in *next; > + > + uint64_t n_pkts_dropped_by_ah; > }; >=20 > struct rte_port_out { > @@ -74,6 +87,8 @@ struct rte_port_out { >=20 > /* Handle to low-level port */ > void *h_port; > + > + uint64_t n_pkts_dropped_by_ah; > }; >=20 > struct rte_table { > @@ -90,6 +105,12 @@ struct rte_table { >=20 > /* Handle to the low-level table object */ > void *h_table; > + > + /* Stats for this table. */ > + uint64_t n_pkts_dropped_by_lkp_hit_ah; > + uint64_t n_pkts_dropped_by_lkp_miss_ah; > + uint64_t n_pkts_dropped_lkp_hit; > + uint64_t n_pkts_dropped_lkp_miss; > }; >=20 > #define RTE_PIPELINE_MAX_NAME_SZ 124 > @@ -1040,6 +1061,8 @@ rte_pipeline_action_handler_port_bulk(struct > rte_pipeline *p, >=20 > port_out->f_action_bulk(p->pkts, &pkts_mask, port_out- > >arg_ah); > p->action_mask0[RTE_PIPELINE_ACTION_DROP] |=3D > pkts_mask ^ mask; > + RTE_PIPELINE_STATS_ADD_M(port_out- > >n_pkts_dropped_by_ah, > + pkts_mask ^ mask); > } >=20 > /* Output port TX */ > @@ -1071,6 +1094,9 @@ rte_pipeline_action_handler_port(struct > rte_pipeline *p, uint64_t pkts_mask) > p- > >action_mask0[RTE_PIPELINE_ACTION_DROP] |=3D > (pkt_mask ^ 1LLU) << i; >=20 > + RTE_PIPELINE_STATS_ADD(port_out- > >n_pkts_dropped_by_ah, > + pkt_mask ^ 1LLU); > + > /* Output port TX */ > if (pkt_mask !=3D 0) > port_out->ops.f_tx(port_out- > >h_port, > @@ -1104,6 +1130,9 @@ rte_pipeline_action_handler_port(struct > rte_pipeline *p, uint64_t pkts_mask) > p- > >action_mask0[RTE_PIPELINE_ACTION_DROP] |=3D > (pkt_mask ^ 1LLU) << i; >=20 > + RTE_PIPELINE_STATS_ADD(port_out- > >n_pkts_dropped_by_ah, > + pkt_mask ^ 1LLU); > + > /* Output port TX */ > if (pkt_mask !=3D 0) > port_out->ops.f_tx(port_out- > >h_port, > @@ -1140,6 +1169,9 @@ rte_pipeline_action_handler_port_meta(struct > rte_pipeline *p, > p- > >action_mask0[RTE_PIPELINE_ACTION_DROP] |=3D > (pkt_mask ^ 1LLU) << i; >=20 > + RTE_PIPELINE_STATS_ADD(port_out- > >n_pkts_dropped_by_ah, > + pkt_mask ^ 1ULL); > + > /* Output port TX */ > if (pkt_mask !=3D 0) > port_out->ops.f_tx(port_out- > >h_port, > @@ -1174,6 +1206,9 @@ rte_pipeline_action_handler_port_meta(struct > rte_pipeline *p, > p- > >action_mask0[RTE_PIPELINE_ACTION_DROP] |=3D > (pkt_mask ^ 1LLU) << i; >=20 > + RTE_PIPELINE_STATS_ADD(port_out- > >n_pkts_dropped_by_ah, > + pkt_mask ^ 1ULL); > + > /* Output port TX */ > if (pkt_mask !=3D 0) > port_out->ops.f_tx(port_out- > >h_port, > @@ -1232,10 +1267,10 @@ rte_pipeline_run(struct rte_pipeline *p) > if (port_in->f_action !=3D NULL) { > uint64_t mask =3D pkts_mask; >=20 > - port_in->f_action(p->pkts, n_pkts, &pkts_mask, > - port_in->arg_ah); > - p->action_mask0[RTE_PIPELINE_ACTION_DROP] |=3D > - pkts_mask ^ mask; > + port_in->f_action(p->pkts, n_pkts, &pkts_mask, > port_in->arg_ah); > + mask ^=3D pkts_mask; > + p->action_mask0[RTE_PIPELINE_ACTION_DROP] |=3D > mask; > + RTE_PIPELINE_STATS_ADD_M(port_in- > >n_pkts_dropped_by_ah, mask); > } >=20 > /* Table */ > @@ -1261,9 +1296,10 @@ rte_pipeline_run(struct rte_pipeline *p) > table->f_action_miss(p->pkts, > &lookup_miss_mask, > default_entry, table- > >arg_ah); > - p->action_mask0[ > - > RTE_PIPELINE_ACTION_DROP] |=3D > - lookup_miss_mask ^ mask; > + mask ^=3D lookup_miss_mask; > + p- > >action_mask0[RTE_PIPELINE_ACTION_DROP] |=3D mask; > + RTE_PIPELINE_STATS_ADD_M( > + table- > >n_pkts_dropped_by_lkp_miss_ah, mask); > } >=20 > /* Table reserved actions */ > @@ -1277,6 +1313,10 @@ rte_pipeline_run(struct rte_pipeline *p) > uint32_t pos =3D default_entry->action; >=20 > p->action_mask0[pos] =3D > lookup_miss_mask; > + if (pos =3D=3D > RTE_PIPELINE_ACTION_DROP) { > + > RTE_PIPELINE_STATS_ADD_M(table->n_pkts_dropped_lkp_miss, > + lookup_miss_mask); > + } > } > } >=20 > @@ -1289,9 +1329,10 @@ rte_pipeline_run(struct rte_pipeline *p) > table->f_action_hit(p->pkts, > &lookup_hit_mask, > p->entries, table->arg_ah); > - p->action_mask0[ > - > RTE_PIPELINE_ACTION_DROP] |=3D > - lookup_hit_mask ^ mask; > + mask ^=3D lookup_hit_mask; > + p- > >action_mask0[RTE_PIPELINE_ACTION_DROP] |=3D mask; > + RTE_PIPELINE_STATS_ADD_M( > + table- > >n_pkts_dropped_by_lkp_hit_ah, mask); > } >=20 > /* Table reserved actions */ > @@ -1308,6 +1349,9 @@ rte_pipeline_run(struct rte_pipeline *p) > p- > >action_mask0[RTE_PIPELINE_ACTION_TABLE] |=3D > p->action_mask1[ >=20 > RTE_PIPELINE_ACTION_TABLE]; > + > + RTE_PIPELINE_STATS_ADD_M(table- > >n_pkts_dropped_lkp_hit, > + p- > >action_mask1[RTE_PIPELINE_ACTION_DROP]); > } >=20 > /* Prepare for next iteration */ > @@ -1370,9 +1414,128 @@ rte_pipeline_port_out_packet_insert(struct > rte_pipeline *p, >=20 > if (pkt_mask !=3D 0) /* Output port TX */ > port_out->ops.f_tx(port_out->h_port, pkt); > - else > + else { > rte_pktmbuf_free(pkt); > + RTE_PIPELINE_STATS_ADD(port_out- > >n_pkts_dropped_by_ah, 1); > + } > + } > + > + return 0; > +} > + > +int rte_pipeline_port_in_stats_read(struct rte_pipeline *p, uint32_t > port_id, > + struct rte_pipeline_port_in_stats *stats, int clear) > +{ > + struct rte_port_in *port; > + int retval; > + > + if (p =3D=3D NULL) { > + RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", > + __func__); > + return -EINVAL; > + } > + > + if (port_id >=3D p->num_ports_in) { > + RTE_LOG(ERR, PIPELINE, > + "%s: port IN ID %u is out of range\n", > + __func__, port_id); > + return -EINVAL; > + } > + > + port =3D &p->ports_in[port_id]; > + > + if (port->ops.f_stats !=3D NULL) { > + retval =3D port->ops.f_stats(port->h_port, &stats->stats, > clear); > + if (retval) > + return retval; > + } else if (stats !=3D NULL) > + memset(&stats->stats, 0, sizeof(stats->stats)); > + > + if (stats !=3D NULL) > + stats->n_pkts_dropped_by_ah =3D port- > >n_pkts_dropped_by_ah; > + > + if (clear !=3D 0) > + port->n_pkts_dropped_by_ah =3D 0; > + > + return 0; > +} > + > +int rte_pipeline_port_out_stats_read(struct rte_pipeline *p, uint32_t > port_id, > + struct rte_pipeline_port_out_stats *stats, int clear) > +{ > + struct rte_port_out *port; > + int retval; > + > + if (p =3D=3D NULL) { > + RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", > __func__); > + return -EINVAL; > + } > + > + if (port_id >=3D p->num_ports_out) { > + RTE_LOG(ERR, PIPELINE, > + "%s: port OUT ID %u is out of range\n", __func__, > port_id); > + return -EINVAL; > + } > + > + port =3D &p->ports_out[port_id]; > + if (port->ops.f_stats !=3D NULL) { > + retval =3D port->ops.f_stats(port->h_port, &stats->stats, > clear); > + if (retval !=3D 0) > + return retval; > + } else if (stats !=3D NULL) > + memset(&stats->stats, 0, sizeof(stats->stats)); > + > + if (stats !=3D NULL) > + stats->n_pkts_dropped_by_ah =3D port- > >n_pkts_dropped_by_ah; > + > + if (clear !=3D 0) > + port->n_pkts_dropped_by_ah =3D 0; > + > + return 0; > +} > + > +int rte_pipeline_table_stats_read(struct rte_pipeline *p, uint32_t table= _id, > + struct rte_pipeline_table_stats *stats, int clear) > +{ > + struct rte_table *table; > + int retval; > + > + if (p =3D=3D NULL) { > + RTE_LOG(ERR, PIPELINE, "%s: pipeline parameter NULL\n", > + __func__); > + return -EINVAL; > + } > + > + if (table_id >=3D p->num_tables) { > + RTE_LOG(ERR, PIPELINE, > + "%s: table %u is out of range\n", __func__, > table_id); > + return -EINVAL; > + } > + > + table =3D &p->tables[table_id]; > + if (table->ops.f_stats !=3D NULL) { > + retval =3D table->ops.f_stats(table->h_table, &stats->stats, > clear); > + if (retval !=3D 0) > + return retval; > + } else if (stats !=3D NULL) > + memset(&stats->stats, 0, sizeof(stats->stats)); > + > + if (stats !=3D NULL) { > + stats->n_pkts_dropped_by_lkp_hit_ah =3D > + table->n_pkts_dropped_by_lkp_hit_ah; > + stats->n_pkts_dropped_by_lkp_miss_ah =3D > + table->n_pkts_dropped_by_lkp_miss_ah; > + stats->n_pkts_dropped_lkp_hit =3D table- > >n_pkts_dropped_lkp_hit; > + stats->n_pkts_dropped_lkp_miss =3D table- > >n_pkts_dropped_lkp_miss; > + } > + > + if (clear !=3D 0) { > + table->n_pkts_dropped_by_lkp_hit_ah =3D 0; > + table->n_pkts_dropped_by_lkp_miss_ah =3D 0; > + table->n_pkts_dropped_lkp_hit =3D 0; > + table->n_pkts_dropped_lkp_miss =3D 0; > } >=20 > return 0; > } > + > diff --git a/lib/librte_pipeline/rte_pipeline.h > b/lib/librte_pipeline/rte_pipeline.h > index fb1014a..a7757c6 100644 > --- a/lib/librte_pipeline/rte_pipeline.h > +++ b/lib/librte_pipeline/rte_pipeline.h > @@ -111,6 +111,45 @@ struct rte_pipeline_params { > uint32_t offset_port_id; > }; >=20 > +/** Pipeline port in stats. */ > +struct rte_pipeline_port_in_stats { > + /** Port in stats. */ > + struct rte_port_in_stats stats; > + > + /** Number of packets dropped by action handler. */ > + uint64_t n_pkts_dropped_by_ah; > + > +}; > + > +/** Pipeline port out stats. */ > +struct rte_pipeline_port_out_stats { > + /** Port out stats. */ > + struct rte_port_out_stats stats; > + > + /** Number of packets dropped by action handler. */ > + uint64_t n_pkts_dropped_by_ah; > +}; > + > +/** Pipeline table stats. */ > +struct rte_pipeline_table_stats { > + /** Table stats. */ > + struct rte_table_stats stats; > + > + /** Number of packets dropped by lookup hit action handler. */ > + uint64_t n_pkts_dropped_by_lkp_hit_ah; > + > + /** Number of packets dropped by lookup miss action handler. */ > + uint64_t n_pkts_dropped_by_lkp_miss_ah; > + > + /** Number of packets dropped by pipeline in behalf of this table > based on > + * on action specified in table entry. */ > + uint64_t n_pkts_dropped_lkp_hit; > + > + /** Number of packets dropped by pipeline in behalf of this table > based on > + * on action specified in table entry. */ > + uint64_t n_pkts_dropped_lkp_miss; > +}; > + > /** > * Pipeline create > * > @@ -425,6 +464,26 @@ int rte_pipeline_table_entry_delete(struct > rte_pipeline *p, > int *key_found, > struct rte_pipeline_table_entry *entry); >=20 > +/** > + * Read pipeline table stats. > + * > + * This function reads table statistics identified by *table_id* of give= n > + * pipeline *p*. > + * > + * @param p > + * Handle to pipeline instance. > + * @param table_id > + * Port ID what stats will be returned. > + * @param stats > + * Statistics buffer. > + * @param clear > + * If not 0 clear stats after reading. > + * @return > + * 0 on success, error code otherwise > + */ > +int rte_pipeline_table_stats_read(struct rte_pipeline *p, uint32_t table= _id, > + struct rte_pipeline_table_stats *stats, int clear); > + > /* > * Port IN > * > @@ -539,6 +598,26 @@ int rte_pipeline_port_in_enable(struct rte_pipeline > *p, > int rte_pipeline_port_in_disable(struct rte_pipeline *p, > uint32_t port_id); >=20 > +/** > + * Read pipeline port in stats. > + * > + * This function reads port in statistics identified by *port_id* of giv= en > + * pipeline *p*. > + * > + * @param p > + * Handle to pipeline instance. > + * @param port_id > + * Port ID what stats will be returned. > + * @param stats > + * Statistics buffer. > + * @param clear > + * If not 0 clear stats after reading. > + * @return > + * 0 on success, error code otherwise > + */ > +int rte_pipeline_port_in_stats_read(struct rte_pipeline *p, uint32_t > port_id, > + struct rte_pipeline_port_in_stats *stats, int clear); > + > /* > * Port OUT > * > @@ -657,6 +736,26 @@ int rte_pipeline_port_out_packet_insert(struct > rte_pipeline *p, > uint32_t port_id, > struct rte_mbuf *pkt); >=20 > +/** > + * Read pipeline port out stats. > + * > + * This function reads port out statistics identified by *port_id* of gi= ven > + * pipeline *p*. > + * > + * @param p > + * Handle to pipeline instance. > + * @param port_id > + * Port ID what stats will be returned. > + * @param stats > + * Statistics buffer. > + * @param clear > + * If not 0 clear stats after reading. > + * @return > + * 0 on success, error code otherwise > + */ > +int rte_pipeline_port_out_stats_read(struct rte_pipeline *p, uint32_t > port_id, > + struct rte_pipeline_port_out_stats *stats, int clear); > + > #ifdef __cplusplus > } > #endif > -- > 1.7.9.5 Acked by: Cristian Dumitrescu