From: "Dumitrescu, Cristian" <cristian.dumitrescu@intel.com>
To: Eelco Chaudron <echaudro@redhat.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v3 1/2] lib/librte_meter: add RFC4115 trTCM meter support
Date: Fri, 21 Dec 2018 16:15:53 +0000 [thread overview]
Message-ID: <3EB4FA525960D640B5BDFFD6A3D891268E81857C@IRSMSX108.ger.corp.intel.com> (raw)
In-Reply-To: <20181218153842.10961.32000.stgit@iMac>
Hi Eelco,
<snip>
>
> +/** trTCM parameters per metered traffic flow. The CIR, EIT, CBS and EBS
Small typo here: EIT to be replaced by EIR.
> +parameters only count bytes of IP packets and do not include link specific
> +headers. The CBS and EBS need to be greater than zero if CIR and EIR are
> +none-zero respectively.*/
> +struct rte_meter_trtcm_rfc4115_params {
> + uint64_t cir; /**< Committed Information Rate (CIR). Measured in
> bytes per second. */
> + uint64_t eir; /**< Excess Information Rate (EIR). Measured in bytes
> per second. */
> + uint64_t cbs; /**< Committed Burst Size (CBS). Measured in bytes.
> */
> + uint64_t ebs; /**< Excess Burst Size (EBS). Measured in bytes. */
> +};
> +
<snip>
> +static inline enum rte_meter_color __rte_experimental
> +rte_meter_trtcm_rfc4115_color_blind_check(
> + struct rte_meter_trtcm_rfc4115 *m,
> + struct rte_meter_trtcm_rfc4115_profile *p,
> + uint64_t time,
> + uint32_t pkt_len)
> +{
> + uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc,
> te;
> +
> + /* Bucket update */
> + time_diff_tc = time - m->time_tc;
> + time_diff_te = time - m->time_te;
> + n_periods_tc = time_diff_tc / p->cir_period;
> + n_periods_te = time_diff_te / p->eir_period;
> + m->time_tc += n_periods_tc * p->cir_period;
> + m->time_te += n_periods_te * p->eir_period;
> +
> + tc = m->tc + n_periods_tc * p->cir_bytes_per_period;
> + if (tc > p->cbs)
> + tc = p->cbs;
> +
> + te = m->te + n_periods_te * p->eir_bytes_per_period;
> + if (te > p->ebs)
> + te = p->ebs;
> +
> + /* Color logic */
> + if (tc >= pkt_len) {
> + m->tc = tc - pkt_len;
> + m->te = te;
> + return e_RTE_METER_GREEN;
> + } else if (te >= pkt_len) {
> + m->tc = tc;
> + m->te = te - pkt_len;
> + return e_RTE_METER_YELLOW;
> + }
> +
> + /* If we end up here the color is RED */
> + m->tc = tc;
> + m->te = te;
> + return e_RTE_METER_RED;
> +}
> +
Since the branch (tc >= pkt_len) == TRUE always returns, I suggest we remove the following "else", as it is redundant:
/* Color logic */
if (tc >= pkt_len) {
m->tc = tc - pkt_len;
m->te = te;
return e_RTE_METER_GREEN;
}
if (te >= pkt_len) {
m->tc = tc;
m->te = te - pkt_len;
return e_RTE_METER_YELLOW;
}
/* If we end up here the color is RED */
m->tc = tc;
m->te = te;
return e_RTE_METER_RED;
> +static inline enum rte_meter_color __rte_experimental
> +rte_meter_trtcm_rfc4115_color_aware_check(
> + struct rte_meter_trtcm_rfc4115 *m,
> + struct rte_meter_trtcm_rfc4115_profile *p,
> + uint64_t time,
> + uint32_t pkt_len,
> + enum rte_meter_color pkt_color)
> +{
> + uint64_t time_diff_tc, time_diff_te, n_periods_tc, n_periods_te, tc,
> te;
> +
> + /* Bucket update */
> + time_diff_tc = time - m->time_tc;
> + time_diff_te = time - m->time_te;
> + n_periods_tc = time_diff_tc / p->cir_period;
> + n_periods_te = time_diff_te / p->eir_period;
> + m->time_tc += n_periods_tc * p->cir_period;
> + m->time_te += n_periods_te * p->eir_period;
> +
> + tc = m->tc + n_periods_tc * p->cir_bytes_per_period;
> + if (tc > p->cbs)
> + tc = p->cbs;
> +
> + te = m->te + n_periods_te * p->eir_bytes_per_period;
> + if (te > p->ebs)
> + te = p->ebs;
> +
> + /* Color logic */
> + if (pkt_color == e_RTE_METER_GREEN) {
> + if (tc >= pkt_len) {
> + m->tc = tc - pkt_len;
> + m->te = te;
> + return e_RTE_METER_GREEN;
> + } else if (te >= pkt_len) {
> + m->tc = tc;
> + m->te = te - pkt_len;
> + return e_RTE_METER_YELLOW;
> + }
> + } else if (pkt_color == e_RTE_METER_YELLOW && te >= pkt_len) {
> + m->tc = tc;
> + m->te = te - pkt_len;
> + return e_RTE_METER_YELLOW;
> + }
> +
> + /* If we end up here the color is RED */
> + m->tc = tc;
> + m->te = te;
> + return e_RTE_METER_RED;
> +}
> +
> +
I suggest we follow the logic from the diagram in the RFC rather than the logic in the text preceding the diagram. Although the two descriptions are equivalent (after a bit of thinking), the diagram seems more optimal to me:
/* Color logic */
if ((pkt_color == e_RTE_METER_GREEN) && (tc >= pkt_len)) {
m->tc = tc - pkt_len;
m->te = te;
return e_RTE_METER_GREEN;
}
if ((pkt_color != e_RTE_METER_RED) && (te >= pkt_len)) {
m->tc = tc;
m->te = te - pkt_len;
return e_RTE_METER_YELLOW;
}
/* If we end up here the color is RED */
m->tc = tc;
m->te = te;
return e_RTE_METER_RED;
<snip>
Thanks,
Cristian
next prev parent reply other threads:[~2018-12-21 16:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 15:38 [dpdk-dev] [PATCH v3 0/2] " Eelco Chaudron
2018-12-18 15:38 ` [dpdk-dev] [PATCH v3 1/2] " Eelco Chaudron
2018-12-21 16:15 ` Dumitrescu, Cristian [this message]
2019-01-04 14:03 ` Eelco Chaudron
2018-12-18 15:38 ` [dpdk-dev] [PATCH v3 2/2] test/test_meter: update meter test to include RFC4115 meters Eelco Chaudron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3EB4FA525960D640B5BDFFD6A3D891268E81857C@IRSMSX108.ger.corp.intel.com \
--to=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
--cc=echaudro@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).