From: Vladimir Oltean <vladimir.oltean@nxp.com> To: netdev@vger.kernel.org Cc: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Jamal Hadi Salim <jhs@mojatatu.com>, Cong Wang <xiyou.wangcong@gmail.com>, Jiri Pirko <jiri@resnulli.us>, Vinicius Costa Gomes <vinicius.gomes@intel.com>, Kurt Kanzenbach <kurt@linutronix.de>, Jacob Keller <jacob.e.keller@intel.com>, Gerhard Engleder <gerhard@engleder-embedded.com>, Jesse Brandeburg <jesse.brandeburg@intel.com>, Tony Nguyen <anthony.l.nguyen@intel.com>, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net-next 03/15] net/sched: taprio: refactor one skb dequeue from TXQ to separate function Date: Tue, 7 Feb 2023 15:54:28 +0200 [thread overview] Message-ID: <20230207135440.1482856-4-vladimir.oltean@nxp.com> (raw) In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> Future changes will refactor the TXQ selection procedure, and a lot of stuff will become messy, the indentation of the bulk of the dequeue procedure would increase, etc. Break out the bulk of the function into a new one, which knows the TXQ (child qdisc) we should perform a dequeue from. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de> --- v1->v2: none net/sched/sch_taprio.c | 121 +++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 58 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 0fde303978a5..272a8b7c0f9f 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -512,6 +512,66 @@ static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry) atomic64_read(&q->picos_per_byte))); } +static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, + struct sched_entry *entry, + u32 gate_mask) +{ + struct taprio_sched *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + struct Qdisc *child = q->qdiscs[txq]; + struct sk_buff *skb; + ktime_t guard; + int prio; + int len; + u8 tc; + + if (unlikely(!child)) + return NULL; + + if (TXTIME_ASSIST_IS_ENABLED(q->flags)) { + skb = child->ops->dequeue(child); + if (!skb) + return NULL; + goto skb_found; + } + + skb = child->ops->peek(child); + if (!skb) + return NULL; + + prio = skb->priority; + tc = netdev_get_prio_tc_map(dev, prio); + + if (!(gate_mask & BIT(tc))) + return NULL; + + len = qdisc_pkt_len(skb); + guard = ktime_add_ns(taprio_get_time(q), length_to_duration(q, len)); + + /* In the case that there's no gate entry, there's no + * guard band ... + */ + if (gate_mask != TAPRIO_ALL_GATES_OPEN && + ktime_after(guard, entry->close_time)) + return NULL; + + /* ... and no budget. */ + if (gate_mask != TAPRIO_ALL_GATES_OPEN && + atomic_sub_return(len, &entry->budget) < 0) + return NULL; + + skb = child->ops->dequeue(child); + if (unlikely(!skb)) + return NULL; + +skb_found: + qdisc_bstats_update(sch, skb); + qdisc_qstats_backlog_dec(sch, skb); + sch->q.qlen--; + + return skb; +} + /* Will not be called in the full offload case, since the TX queues are * attached to the Qdisc created using qdisc_create_dflt() */ @@ -537,64 +597,9 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) goto done; for (i = 0; i < dev->num_tx_queues; i++) { - struct Qdisc *child = q->qdiscs[i]; - ktime_t guard; - int prio; - int len; - u8 tc; - - if (unlikely(!child)) - continue; - - if (TXTIME_ASSIST_IS_ENABLED(q->flags)) { - skb = child->ops->dequeue(child); - if (!skb) - continue; - goto skb_found; - } - - skb = child->ops->peek(child); - if (!skb) - continue; - - prio = skb->priority; - tc = netdev_get_prio_tc_map(dev, prio); - - if (!(gate_mask & BIT(tc))) { - skb = NULL; - continue; - } - - len = qdisc_pkt_len(skb); - guard = ktime_add_ns(taprio_get_time(q), - length_to_duration(q, len)); - - /* In the case that there's no gate entry, there's no - * guard band ... - */ - if (gate_mask != TAPRIO_ALL_GATES_OPEN && - ktime_after(guard, entry->close_time)) { - skb = NULL; - continue; - } - - /* ... and no budget. */ - if (gate_mask != TAPRIO_ALL_GATES_OPEN && - atomic_sub_return(len, &entry->budget) < 0) { - skb = NULL; - continue; - } - - skb = child->ops->dequeue(child); - if (unlikely(!skb)) - continue; - -skb_found: - qdisc_bstats_update(sch, skb); - qdisc_qstats_backlog_dec(sch, skb); - sch->q.qlen--; - - goto done; + skb = taprio_dequeue_from_txq(sch, i, entry, gate_mask); + if (skb) + goto done; } done: -- 2.34.1
WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Oltean <vladimir.oltean@nxp.com> To: netdev@vger.kernel.org Cc: Jiri Pirko <jiri@resnulli.us>, intel-wired-lan@lists.osuosl.org, Kurt Kanzenbach <kurt@linutronix.de>, Jamal Hadi Salim <jhs@mojatatu.com>, Jesse Brandeburg <jesse.brandeburg@intel.com>, Gerhard Engleder <gerhard@engleder-embedded.com>, Eric Dumazet <edumazet@google.com>, Tony Nguyen <anthony.l.nguyen@intel.com>, Cong Wang <xiyou.wangcong@gmail.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, "David S. Miller" <davem@davemloft.net>, linux-kernel@vger.kernel.org Subject: [Intel-wired-lan] [PATCH v2 net-next 03/15] net/sched: taprio: refactor one skb dequeue from TXQ to separate function Date: Tue, 7 Feb 2023 15:54:28 +0200 [thread overview] Message-ID: <20230207135440.1482856-4-vladimir.oltean@nxp.com> (raw) In-Reply-To: <20230207135440.1482856-1-vladimir.oltean@nxp.com> Future changes will refactor the TXQ selection procedure, and a lot of stuff will become messy, the indentation of the bulk of the dequeue procedure would increase, etc. Break out the bulk of the function into a new one, which knows the TXQ (child qdisc) we should perform a dequeue from. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de> --- v1->v2: none net/sched/sch_taprio.c | 121 +++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 58 deletions(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 0fde303978a5..272a8b7c0f9f 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -512,6 +512,66 @@ static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry) atomic64_read(&q->picos_per_byte))); } +static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq, + struct sched_entry *entry, + u32 gate_mask) +{ + struct taprio_sched *q = qdisc_priv(sch); + struct net_device *dev = qdisc_dev(sch); + struct Qdisc *child = q->qdiscs[txq]; + struct sk_buff *skb; + ktime_t guard; + int prio; + int len; + u8 tc; + + if (unlikely(!child)) + return NULL; + + if (TXTIME_ASSIST_IS_ENABLED(q->flags)) { + skb = child->ops->dequeue(child); + if (!skb) + return NULL; + goto skb_found; + } + + skb = child->ops->peek(child); + if (!skb) + return NULL; + + prio = skb->priority; + tc = netdev_get_prio_tc_map(dev, prio); + + if (!(gate_mask & BIT(tc))) + return NULL; + + len = qdisc_pkt_len(skb); + guard = ktime_add_ns(taprio_get_time(q), length_to_duration(q, len)); + + /* In the case that there's no gate entry, there's no + * guard band ... + */ + if (gate_mask != TAPRIO_ALL_GATES_OPEN && + ktime_after(guard, entry->close_time)) + return NULL; + + /* ... and no budget. */ + if (gate_mask != TAPRIO_ALL_GATES_OPEN && + atomic_sub_return(len, &entry->budget) < 0) + return NULL; + + skb = child->ops->dequeue(child); + if (unlikely(!skb)) + return NULL; + +skb_found: + qdisc_bstats_update(sch, skb); + qdisc_qstats_backlog_dec(sch, skb); + sch->q.qlen--; + + return skb; +} + /* Will not be called in the full offload case, since the TX queues are * attached to the Qdisc created using qdisc_create_dflt() */ @@ -537,64 +597,9 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) goto done; for (i = 0; i < dev->num_tx_queues; i++) { - struct Qdisc *child = q->qdiscs[i]; - ktime_t guard; - int prio; - int len; - u8 tc; - - if (unlikely(!child)) - continue; - - if (TXTIME_ASSIST_IS_ENABLED(q->flags)) { - skb = child->ops->dequeue(child); - if (!skb) - continue; - goto skb_found; - } - - skb = child->ops->peek(child); - if (!skb) - continue; - - prio = skb->priority; - tc = netdev_get_prio_tc_map(dev, prio); - - if (!(gate_mask & BIT(tc))) { - skb = NULL; - continue; - } - - len = qdisc_pkt_len(skb); - guard = ktime_add_ns(taprio_get_time(q), - length_to_duration(q, len)); - - /* In the case that there's no gate entry, there's no - * guard band ... - */ - if (gate_mask != TAPRIO_ALL_GATES_OPEN && - ktime_after(guard, entry->close_time)) { - skb = NULL; - continue; - } - - /* ... and no budget. */ - if (gate_mask != TAPRIO_ALL_GATES_OPEN && - atomic_sub_return(len, &entry->budget) < 0) { - skb = NULL; - continue; - } - - skb = child->ops->dequeue(child); - if (unlikely(!skb)) - continue; - -skb_found: - qdisc_bstats_update(sch, skb); - qdisc_qstats_backlog_dec(sch, skb); - sch->q.qlen--; - - goto done; + skb = taprio_dequeue_from_txq(sch, i, entry, gate_mask); + if (skb) + goto done; } done: -- 2.34.1 _______________________________________________ Intel-wired-lan mailing list Intel-wired-lan@osuosl.org https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
next prev parent reply other threads:[~2023-02-07 13:55 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-07 13:54 [PATCH v2 net-next 00/15] taprio automatic queueMaxSDU and new TXQ selection procedure Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] " Vladimir Oltean 2023-02-07 13:54 ` [PATCH v2 net-next 01/15] net/sched: taprio: delete peek() implementation Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] " Vladimir Oltean 2023-02-07 13:54 ` [PATCH v2 net-next 02/15] net/sched: taprio: continue with other TXQs if one dequeue() failed Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] " Vladimir Oltean 2023-02-07 13:54 ` Vladimir Oltean [this message] 2023-02-07 13:54 ` [Intel-wired-lan] [PATCH v2 net-next 03/15] net/sched: taprio: refactor one skb dequeue from TXQ to separate function Vladimir Oltean 2023-02-07 13:54 ` [PATCH v2 net-next 04/15] net/sched: taprio: avoid calling child->ops->dequeue(child) twice Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] " Vladimir Oltean 2023-02-07 13:54 ` [PATCH v2 net-next 05/15] net/sched: taprio: give higher priority to higher TCs in software dequeue mode Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] " Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] [PATCH v2 net-next 06/15] net/sched: taprio: calculate tc gate durations Vladimir Oltean 2023-02-07 13:54 ` Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] [PATCH v2 net-next 07/15] net/sched: taprio: rename close_time to end_time Vladimir Oltean 2023-02-07 13:54 ` Vladimir Oltean 2023-02-07 13:54 ` [PATCH v2 net-next 08/15] net/sched: taprio: calculate budgets per traffic class Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] " Vladimir Oltean 2023-02-07 13:54 ` [PATCH v2 net-next 09/15] net/sched: taprio: calculate guard band against actual TC gate close time Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] " Vladimir Oltean 2023-02-07 13:54 ` [PATCH v2 net-next 10/15] net/sched: make stab available before ops->init() call Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] " Vladimir Oltean 2023-02-10 15:07 ` Eric Dumazet 2023-02-10 15:07 ` [Intel-wired-lan] " Eric Dumazet 2023-02-10 15:20 ` Vladimir Oltean 2023-02-10 15:20 ` [Intel-wired-lan] " Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] [PATCH v2 net-next 11/15] net/sched: taprio: warn about missing size table Vladimir Oltean 2023-02-07 13:54 ` Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] [PATCH v2 net-next 12/15] net/sched: keep the max_frm_len information inside struct sched_gate_list Vladimir Oltean 2023-02-07 13:54 ` Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] [PATCH v2 net-next 13/15] net/sched: taprio: automatically calculate queueMaxSDU based on TC gate durations Vladimir Oltean 2023-02-07 13:54 ` Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] [PATCH v2 net-next 14/15] net/sched: taprio: split segmentation logic from qdisc_enqueue() Vladimir Oltean 2023-02-07 13:54 ` Vladimir Oltean 2023-02-07 13:54 ` [Intel-wired-lan] [PATCH v2 net-next 15/15] net/sched: taprio: don't segment unnecessarily Vladimir Oltean 2023-02-07 13:54 ` Vladimir Oltean 2023-02-08 9:50 ` [PATCH v2 net-next 00/15] taprio automatic queueMaxSDU and new TXQ selection procedure patchwork-bot+netdevbpf 2023-02-08 9:50 ` [Intel-wired-lan] " patchwork-bot+netdevbpf
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=20230207135440.1482856-4-vladimir.oltean@nxp.com \ --to=vladimir.oltean@nxp.com \ --cc=anthony.l.nguyen@intel.com \ --cc=davem@davemloft.net \ --cc=edumazet@google.com \ --cc=gerhard@engleder-embedded.com \ --cc=intel-wired-lan@lists.osuosl.org \ --cc=jacob.e.keller@intel.com \ --cc=jesse.brandeburg@intel.com \ --cc=jhs@mojatatu.com \ --cc=jiri@resnulli.us \ --cc=kuba@kernel.org \ --cc=kurt@linutronix.de \ --cc=linux-kernel@vger.kernel.org \ --cc=netdev@vger.kernel.org \ --cc=pabeni@redhat.com \ --cc=vinicius.gomes@intel.com \ --cc=xiyou.wangcong@gmail.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.