License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2005-04-17 06:20:36 +08:00
|
|
|
#ifndef __NET_PKT_SCHED_H
|
|
|
|
#define __NET_PKT_SCHED_H
|
|
|
|
|
2006-01-09 14:12:03 +08:00
|
|
|
#include <linux/jiffies.h>
|
2007-03-16 16:18:42 +08:00
|
|
|
#include <linux/ktime.h>
|
2015-01-14 00:13:43 +08:00
|
|
|
#include <linux/if_vlan.h>
|
2017-10-13 20:00:58 +08:00
|
|
|
#include <linux/netdevice.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <net/sch_generic.h>
|
2017-10-13 20:00:58 +08:00
|
|
|
#include <net/net_namespace.h>
|
2017-08-09 20:30:31 +08:00
|
|
|
#include <uapi/linux/pkt_sched.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2016-11-03 21:56:01 +08:00
|
|
|
#define DEFAULT_TX_QUEUE_LEN 1000
|
2021-09-24 10:35:58 +08:00
|
|
|
#define STAB_SIZE_LOG_MAX 30
|
2016-11-03 21:56:01 +08:00
|
|
|
|
2009-11-03 11:26:03 +08:00
|
|
|
struct qdisc_walker {
|
2005-04-17 06:20:36 +08:00
|
|
|
int stop;
|
|
|
|
int skip;
|
|
|
|
int count;
|
|
|
|
int (*fn)(struct Qdisc *, unsigned long cl, struct qdisc_walker *);
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void *qdisc_priv(struct Qdisc *q)
|
|
|
|
{
|
2020-10-08 00:51:11 +08:00
|
|
|
return &q->privdata;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2020-11-03 17:18:21 +08:00
|
|
|
static inline struct Qdisc *qdisc_from_priv(void *priv)
|
|
|
|
{
|
|
|
|
return container_of(priv, struct Qdisc, privdata);
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
Timer resolution MUST BE < 10% of min_schedulable_packet_size/bandwidth
|
|
|
|
|
|
|
|
Normal IP packet size ~ 512byte, hence:
|
|
|
|
|
|
|
|
0.5Kbyte/1Mbyte/sec = 0.5msec, so that we need 50usec timer for
|
|
|
|
10Mbit ethernet.
|
|
|
|
|
|
|
|
10msec resolution -> <50Kbit/sec.
|
|
|
|
|
|
|
|
The result: [34]86 is not good choice for QoS router :-(
|
|
|
|
|
2011-03-31 09:57:33 +08:00
|
|
|
The things are not so bad, because we may use artificial
|
2005-04-17 06:20:36 +08:00
|
|
|
clock evaluated by integration of network data flow
|
|
|
|
in the most critical places.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef u64 psched_time_t;
|
|
|
|
typedef long psched_tdiff_t;
|
|
|
|
|
2009-06-09 06:05:13 +08:00
|
|
|
/* Avoid doing 64 bit divide */
|
|
|
|
#define PSCHED_SHIFT 6
|
2009-06-15 17:31:47 +08:00
|
|
|
#define PSCHED_TICKS2NS(x) ((s64)(x) << PSCHED_SHIFT)
|
|
|
|
#define PSCHED_NS2TICKS(x) ((x) >> PSCHED_SHIFT)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-06-15 17:31:47 +08:00
|
|
|
#define PSCHED_TICKS_PER_SEC PSCHED_NS2TICKS(NSEC_PER_SEC)
|
2007-03-24 02:28:30 +08:00
|
|
|
#define PSCHED_PASTPERFECT 0
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-03-24 02:29:25 +08:00
|
|
|
static inline psched_time_t psched_get_time(void)
|
|
|
|
{
|
2014-08-23 09:32:09 +08:00
|
|
|
return PSCHED_NS2TICKS(ktime_get_ns());
|
2007-03-24 02:29:25 +08:00
|
|
|
}
|
|
|
|
|
2007-03-16 16:19:15 +08:00
|
|
|
struct qdisc_watchdog {
|
|
|
|
struct hrtimer timer;
|
|
|
|
struct Qdisc *qdisc;
|
|
|
|
};
|
|
|
|
|
2018-07-04 06:42:52 +08:00
|
|
|
void qdisc_watchdog_init_clockid(struct qdisc_watchdog *wd, struct Qdisc *qdisc,
|
|
|
|
clockid_t clockid);
|
2013-07-31 13:47:13 +08:00
|
|
|
void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc);
|
2020-03-17 10:12:49 +08:00
|
|
|
|
|
|
|
void qdisc_watchdog_schedule_range_ns(struct qdisc_watchdog *wd, u64 expires,
|
|
|
|
u64 delta_ns);
|
|
|
|
|
|
|
|
static inline void qdisc_watchdog_schedule_ns(struct qdisc_watchdog *wd,
|
|
|
|
u64 expires)
|
|
|
|
{
|
|
|
|
return qdisc_watchdog_schedule_range_ns(wd, expires, 0ULL);
|
|
|
|
}
|
2013-02-12 08:12:04 +08:00
|
|
|
|
|
|
|
static inline void qdisc_watchdog_schedule(struct qdisc_watchdog *wd,
|
|
|
|
psched_time_t expires)
|
|
|
|
{
|
2016-06-11 07:41:39 +08:00
|
|
|
qdisc_watchdog_schedule_ns(wd, PSCHED_TICKS2NS(expires));
|
2013-02-12 08:12:04 +08:00
|
|
|
}
|
|
|
|
|
2013-07-31 13:47:13 +08:00
|
|
|
void qdisc_watchdog_cancel(struct qdisc_watchdog *wd);
|
2007-03-16 16:19:15 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
extern struct Qdisc_ops pfifo_qdisc_ops;
|
|
|
|
extern struct Qdisc_ops bfifo_qdisc_ops;
|
2010-01-24 20:30:59 +08:00
|
|
|
extern struct Qdisc_ops pfifo_head_drop_qdisc_ops;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2013-07-31 13:47:13 +08:00
|
|
|
int fifo_set_limit(struct Qdisc *q, unsigned int limit);
|
|
|
|
struct Qdisc *fifo_create_dflt(struct Qdisc *sch, struct Qdisc_ops *ops,
|
2017-12-21 01:35:21 +08:00
|
|
|
unsigned int limit,
|
|
|
|
struct netlink_ext_ack *extack);
|
2013-07-31 13:47:13 +08:00
|
|
|
|
|
|
|
int register_qdisc(struct Qdisc_ops *qops);
|
2022-08-15 11:04:17 +08:00
|
|
|
void unregister_qdisc(struct Qdisc_ops *qops);
|
2013-08-28 07:19:08 +08:00
|
|
|
void qdisc_get_default(char *id, size_t len);
|
|
|
|
int qdisc_set_default(const char *id);
|
|
|
|
|
2017-03-08 23:03:32 +08:00
|
|
|
void qdisc_hash_add(struct Qdisc *q, bool invisible);
|
2016-08-10 17:05:15 +08:00
|
|
|
void qdisc_hash_del(struct Qdisc *q);
|
2013-07-31 13:47:13 +08:00
|
|
|
struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle);
|
2018-09-25 00:22:51 +08:00
|
|
|
struct Qdisc *qdisc_lookup_rcu(struct net_device *dev, u32 handle);
|
2013-07-31 13:47:13 +08:00
|
|
|
struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r,
|
2017-12-21 01:35:18 +08:00
|
|
|
struct nlattr *tab,
|
|
|
|
struct netlink_ext_ack *extack);
|
2013-07-31 13:47:13 +08:00
|
|
|
void qdisc_put_rtab(struct qdisc_rate_table *tab);
|
|
|
|
void qdisc_put_stab(struct qdisc_size_table *tab);
|
2014-06-12 02:35:18 +08:00
|
|
|
void qdisc_warn_nonwc(const char *txt, struct Qdisc *qdisc);
|
2017-12-08 01:54:47 +08:00
|
|
|
bool sch_direct_xmit(struct sk_buff *skb, struct Qdisc *q,
|
|
|
|
struct net_device *dev, struct netdev_queue *txq,
|
|
|
|
spinlock_t *root_lock, bool validate);
|
2013-07-31 13:47:13 +08:00
|
|
|
|
|
|
|
void __qdisc_run(struct Qdisc *q);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-07-16 17:15:04 +08:00
|
|
|
static inline void qdisc_run(struct Qdisc *q)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2017-12-08 01:54:06 +08:00
|
|
|
if (qdisc_run_begin(q)) {
|
net: sched: fix tx action rescheduling issue during deactivation
Currently qdisc_run() checks the STATE_DEACTIVATED of lockless
qdisc before calling __qdisc_run(), which ultimately clear the
STATE_MISSED when all the skb is dequeued. If STATE_DEACTIVATED
is set before clearing STATE_MISSED, there may be rescheduling
of net_tx_action() at the end of qdisc_run_end(), see below:
CPU0(net_tx_atcion) CPU1(__dev_xmit_skb) CPU2(dev_deactivate)
. . .
. set STATE_MISSED .
. __netif_schedule() .
. . set STATE_DEACTIVATED
. . qdisc_reset()
. . .
.<--------------- . synchronize_net()
clear __QDISC_STATE_SCHED | . .
. | . .
. | . some_qdisc_is_busy()
. | . return *false*
. | . .
test STATE_DEACTIVATED | . .
__qdisc_run() *not* called | . .
. | . .
test STATE_MISS | . .
__netif_schedule()--------| . .
. . .
. . .
__qdisc_run() is not called by net_tx_atcion() in CPU0 because
CPU2 has set STATE_DEACTIVATED flag during dev_deactivate(), and
STATE_MISSED is only cleared in __qdisc_run(), __netif_schedule
is called at the end of qdisc_run_end(), causing tx action
rescheduling problem.
qdisc_run() called by net_tx_action() runs in the softirq context,
which should has the same semantic as the qdisc_run() called by
__dev_xmit_skb() protected by rcu_read_lock_bh(). And there is a
synchronize_net() between STATE_DEACTIVATED flag being set and
qdisc_reset()/some_qdisc_is_busy in dev_deactivate(), we can safely
bail out for the deactived lockless qdisc in net_tx_action(), and
qdisc_reset() will reset all skb not dequeued yet.
So add the rcu_read_lock() explicitly to protect the qdisc_run()
and do the STATE_DEACTIVATED checking in net_tx_action() before
calling qdisc_run_begin(). Another option is to do the checking in
the qdisc_run_end(), but it will add unnecessary overhead for
non-tx_action case, because __dev_queue_xmit() will not see qdisc
with STATE_DEACTIVATED after synchronize_net(), the qdisc with
STATE_DEACTIVATED can only be seen by net_tx_action() because of
__netif_schedule().
The STATE_DEACTIVATED checking in qdisc_run() is to avoid race
between net_tx_action() and qdisc_reset(), see:
commit d518d2ed8640 ("net/sched: fix race between deactivation
and dequeue for NOLOCK qdisc"). As the bailout added above for
deactived lockless qdisc in net_tx_action() provides better
protection for the race without calling qdisc_run() at all, so
remove the STATE_DEACTIVATED checking in qdisc_run().
After qdisc_reset(), there is no skb in qdisc to be dequeued, so
clear the STATE_MISSED in dev_reset_queue() too.
Fixes: 6b3ba9146fe6 ("net: sched: allow qdiscs to handle locking")
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
V8: Clearing STATE_MISSED before calling __netif_schedule() has
avoid the endless rescheduling problem, but there may still
be a unnecessary rescheduling, so adjust the commit log.
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-05-14 11:17:00 +08:00
|
|
|
__qdisc_run(q);
|
2017-12-08 01:54:06 +08:00
|
|
|
qdisc_run_end(q);
|
|
|
|
}
|
2015-01-14 00:13:43 +08:00
|
|
|
}
|
|
|
|
|
2023-06-06 19:42:33 +08:00
|
|
|
extern const struct nla_policy rtm_tca_policy[TCA_MAX + 1];
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
/* Calculate maximal size of packet seen by hard_start_xmit
|
|
|
|
routine of this device.
|
|
|
|
*/
|
2012-04-15 13:58:06 +08:00
|
|
|
static inline unsigned int psched_mtu(const struct net_device *dev)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-09 16:40:57 +08:00
|
|
|
return dev->mtu + dev->hard_header_len;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
2017-10-13 20:00:58 +08:00
|
|
|
static inline struct net *qdisc_net(struct Qdisc *q)
|
|
|
|
{
|
|
|
|
return dev_net(q->dev_queue->dev);
|
|
|
|
}
|
|
|
|
|
2022-09-28 17:51:57 +08:00
|
|
|
struct tc_query_caps_base {
|
|
|
|
enum tc_setup_type type;
|
|
|
|
void *caps;
|
|
|
|
};
|
|
|
|
|
2017-10-17 09:01:27 +08:00
|
|
|
struct tc_cbs_qopt_offload {
|
|
|
|
u8 enable;
|
|
|
|
s32 queue;
|
|
|
|
s32 hicredit;
|
|
|
|
s32 locredit;
|
|
|
|
s32 idleslope;
|
|
|
|
s32 sendslope;
|
|
|
|
};
|
|
|
|
|
2018-07-04 06:42:54 +08:00
|
|
|
struct tc_etf_qopt_offload {
|
|
|
|
u8 enable;
|
|
|
|
s32 queue;
|
|
|
|
};
|
|
|
|
|
2023-02-04 21:52:59 +08:00
|
|
|
struct tc_mqprio_caps {
|
|
|
|
bool validate_queue_counts:1;
|
|
|
|
};
|
|
|
|
|
2023-02-04 21:52:57 +08:00
|
|
|
struct tc_mqprio_qopt_offload {
|
|
|
|
/* struct tc_mqprio_qopt must always be the first element */
|
|
|
|
struct tc_mqprio_qopt qopt;
|
2023-04-12 02:01:53 +08:00
|
|
|
struct netlink_ext_ack *extack;
|
2023-02-04 21:52:57 +08:00
|
|
|
u16 mode;
|
|
|
|
u16 shaper;
|
|
|
|
u32 flags;
|
|
|
|
u64 min_rate[TC_QOPT_MAX_QUEUE];
|
|
|
|
u64 max_rate[TC_QOPT_MAX_QUEUE];
|
2023-04-12 02:01:54 +08:00
|
|
|
unsigned long preemptible_tcs;
|
2023-02-04 21:52:57 +08:00
|
|
|
};
|
|
|
|
|
net/sched: taprio: allow user input of per-tc max SDU
IEEE 802.1Q clause 12.29.1.1 "The queueMaxSDUTable structure and data
types" and 8.6.8.4 "Enhancements for scheduled traffic" talk about the
existence of a per traffic class limitation of maximum frame sizes, with
a fallback on the port-based MTU.
As far as I am able to understand, the 802.1Q Service Data Unit (SDU)
represents the MAC Service Data Unit (MSDU, i.e. L2 payload), excluding
any number of prepended VLAN headers which may be otherwise present in
the MSDU. Therefore, the queueMaxSDU is directly comparable to the
device MTU (1500 means L2 payload sizes are accepted, or frame sizes of
1518 octets, or 1522 plus one VLAN header). Drivers which offload this
are directly responsible of translating into other units of measurement.
To keep the fast path checks optimized, we keep 2 arrays in the qdisc,
one for max_sdu translated into frame length (so that it's comparable to
skb->len), and another for offloading and for dumping back to the user.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-09-28 17:51:58 +08:00
|
|
|
struct tc_taprio_caps {
|
|
|
|
bool supports_queue_max_sdu:1;
|
net/sched: taprio: only pass gate mask per TXQ for igc, stmmac, tsnep, am65_cpsw
There are 2 classes of in-tree drivers currently:
- those who act upon struct tc_taprio_sched_entry :: gate_mask as if it
holds a bit mask of TXQs
- those who act upon the gate_mask as if it holds a bit mask of TCs
When it comes to the standard, IEEE 802.1Q-2018 does say this in the
second paragraph of section 8.6.8.4 Enhancements for scheduled traffic:
| A gate control list associated with each Port contains an ordered list
| of gate operations. Each gate operation changes the transmission gate
| state for the gate associated with each of the Port's traffic class
| queues and allows associated control operations to be scheduled.
In typically obtuse language, it refers to a "traffic class queue"
rather than a "traffic class" or a "queue". But careful reading of
802.1Q clarifies that "traffic class" and "queue" are in fact
synonymous (see 8.6.6 Queuing frames):
| A queue in this context is not necessarily a single FIFO data structure.
| A queue is a record of all frames of a given traffic class awaiting
| transmission on a given Bridge Port. The structure of this record is not
| specified.
i.o.w. their definition of "queue" isn't the Linux TX queue.
The gate_mask really is input into taprio via its UAPI as a mask of
traffic classes, but taprio_sched_to_offload() converts it into a TXQ
mask.
The breakdown of drivers which handle TC_SETUP_QDISC_TAPRIO is:
- hellcreek, felix, sja1105: these are DSA switches, it's not even very
clear what TXQs correspond to, other than purely software constructs.
Only the mqprio configuration with 8 TCs and 1 TXQ per TC makes sense.
So it's fine to convert these to a gate mask per TC.
- enetc: I have the hardware and can confirm that the gate mask is per
TC, and affects all TXQs (BD rings) configured for that priority.
- igc: in igc_save_qbv_schedule(), the gate_mask is clearly interpreted
to be per-TXQ.
- tsnep: Gerhard Engleder clarifies that even though this hardware
supports at most 1 TXQ per TC, the TXQ indices may be different from
the TC values themselves, and it is the TXQ indices that matter to
this hardware. So keep it per-TXQ as well.
- stmmac: I have a GMAC datasheet, and in the EST section it does
specify that the gate events are per TXQ rather than per TC.
- lan966x: again, this is a switch, and while not a DSA one, the way in
which it implements lan966x_mqprio_add() - by only allowing num_tc ==
NUM_PRIO_QUEUES (8) - makes it clear to me that TXQs are a purely
software construct here as well. They seem to map 1:1 with TCs.
- am65_cpsw: from looking at am65_cpsw_est_set_sched_cmds(), I get the
impression that the fetch_allow variable is treated like a prio_mask.
This definitely sounds closer to a per-TC gate mask rather than a
per-TXQ one, and TI documentation does seem to recomment an identity
mapping between TCs and TXQs. However, Roger Quadros would like to do
some testing before making changes, so I'm leaving this driver to
operate as it did before, for now. Link with more details at the end.
Based on this breakdown, we have 5 drivers with a gate mask per TC and
4 with a gate mask per TXQ. So let's make the gate mask per TXQ the
opt-in and the gate mask per TC the default.
Benefit from the TC_QUERY_CAPS feature that Jakub suggested we add, and
query the device driver before calling the proper ndo_setup_tc(), and
figure out if it expects one or the other format.
Link: https://patchwork.kernel.org/project/netdevbpf/patch/20230202003621.2679603-15-vladimir.oltean@nxp.com/#25193204
Cc: Horatiu Vultur <horatiu.vultur@microchip.com>
Cc: Siddharth Vadapalli <s-vadapalli@ti.com>
Cc: Roger Quadros <rogerq@kernel.org>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Acked-by: Kurt Kanzenbach <kurt@linutronix.de> # hellcreek
Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-02-04 21:53:04 +08:00
|
|
|
bool gate_mask_per_txq:1;
|
net/sched: taprio: give higher priority to higher TCs in software dequeue mode
Current taprio software implementation is haunted by the shadow of the
igb/igc hardware model. It iterates over child qdiscs in increasing
order of TXQ index, therefore giving higher xmit priority to TXQ 0 and
lower to TXQ N. According to discussions with Vinicius, that is the
default (perhaps even unchangeable) prioritization scheme used for the
NICs that taprio was first written for (igb, igc), and we have a case of
two bugs canceling out, resulting in a functional setup on igb/igc, but
a less sane one on other NICs.
To the best of my understanding, taprio should prioritize based on the
traffic class, so it should really dequeue starting with the highest
traffic class and going down from there. We get to the TXQ using the
tc_to_txq[] netdev property.
TXQs within the same TC have the same (strict) priority, so we should
pick from them as fairly as we can. We can achieve that by implementing
something very similar to q->curband from multiq_dequeue().
Since igb/igc really do have TXQ 0 of higher hardware priority than
TXQ 1 etc, we need to preserve the behavior for them as well. We really
have no choice, because in txtime-assist mode, taprio is essentially a
software scheduler towards offloaded child tc-etf qdiscs, so the TXQ
selection really does matter (not all igb TXQs support ETF/SO_TXTIME,
says Kurt Kanzenbach).
To preserve the behavior, we need a capability bit so that taprio can
determine if it's running on igb/igc, or on something else. Because igb
doesn't offload taprio at all, we can't piggyback on the
qdisc_offload_query_caps() call from taprio_enable_offload(), but
instead we need a separate call which is also made for software
scheduling.
Introduce two static keys to minimize the performance penalty on systems
which only have igb/igc NICs, and on systems which only have other NICs.
For mixed systems, taprio will have to dynamically check whether to
dequeue using one prioritization algorithm or using the other.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-02-07 21:54:30 +08:00
|
|
|
/* Device expects lower TXQ numbers to have higher priority over higher
|
|
|
|
* TXQs, regardless of their TC mapping. DO NOT USE FOR NEW DRIVERS,
|
|
|
|
* INSTEAD ENFORCE A PROPER TC:TXQ MAPPING COMING FROM USER SPACE.
|
|
|
|
*/
|
|
|
|
bool broken_mqprio:1;
|
net/sched: taprio: allow user input of per-tc max SDU
IEEE 802.1Q clause 12.29.1.1 "The queueMaxSDUTable structure and data
types" and 8.6.8.4 "Enhancements for scheduled traffic" talk about the
existence of a per traffic class limitation of maximum frame sizes, with
a fallback on the port-based MTU.
As far as I am able to understand, the 802.1Q Service Data Unit (SDU)
represents the MAC Service Data Unit (MSDU, i.e. L2 payload), excluding
any number of prepended VLAN headers which may be otherwise present in
the MSDU. Therefore, the queueMaxSDU is directly comparable to the
device MTU (1500 means L2 payload sizes are accepted, or frame sizes of
1518 octets, or 1522 plus one VLAN header). Drivers which offload this
are directly responsible of translating into other units of measurement.
To keep the fast path checks optimized, we keep 2 arrays in the qdisc,
one for max_sdu translated into frame length (so that it's comparable to
skb->len), and another for offloading and for dumping back to the user.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-09-28 17:51:58 +08:00
|
|
|
};
|
|
|
|
|
taprio: Add support for hardware offloading
This allows taprio to offload the schedule enforcement to capable
network cards, resulting in more precise windows and less CPU usage.
The gate mask acts on traffic classes (groups of queues of same
priority), as specified in IEEE 802.1Q-2018, and following the existing
taprio and mqprio semantics.
It is up to the driver to perform conversion between tc and individual
netdev queues if for some reason it needs to make that distinction.
Full offload is requested from the network interface by specifying
"flags 2" in the tc qdisc creation command, which in turn corresponds to
the TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD bit.
The important detail here is the clockid which is implicitly /dev/ptpN
for full offload, and hence not configurable.
A reference counting API is added to support the use case where Ethernet
drivers need to keep the taprio offload structure locally (i.e. they are
a multi-port switch driver, and configuring a port depends on the
settings of other ports as well). The refcount_t variable is kept in a
private structure (__tc_taprio_qopt_offload) and not exposed to drivers.
In the future, the private structure might also be expanded with a
backpointer to taprio_sched *q, to implement the notification system
described in the patch (of when admin became oper, or an error occurred,
etc, so the offload can be monitored with 'tc qdisc show').
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Voon Weifeng <weifeng.voon@intel.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-09-15 09:59:58 +08:00
|
|
|
struct tc_taprio_sched_entry {
|
|
|
|
u8 command; /* TC_TAPRIO_CMD_* */
|
|
|
|
|
|
|
|
/* The gate_mask in the offloading side refers to traffic classes */
|
|
|
|
u32 gate_mask;
|
|
|
|
u32 interval;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tc_taprio_qopt_offload {
|
net/sched: taprio: pass mqprio queue configuration to ndo_setup_tc()
The taprio qdisc does not currently pass the mqprio queue configuration
down to the offloading device driver. So the driver cannot act upon the
TXQ counts/offsets per TC, or upon the prio->tc map. It was probably
assumed that the driver only wants to offload num_tc (see
TC_MQPRIO_HW_OFFLOAD_TCS), which it can get from netdev_get_num_tc(),
but there's clearly more to the mqprio configuration than that.
I've considered 2 mechanisms to remedy that. First is to pass a struct
tc_mqprio_qopt_offload as part of the tc_taprio_qopt_offload. The second
is to make taprio actually call TC_SETUP_QDISC_MQPRIO, *in addition to*
TC_SETUP_QDISC_TAPRIO.
The difference is that in the first case, existing drivers (offloading
or not) all ignore taprio's mqprio portion currently, whereas in the
second case, we could control whether to call TC_SETUP_QDISC_MQPRIO,
based on a new capability. The question is which approach would be
better.
I'm afraid that calling TC_SETUP_QDISC_MQPRIO unconditionally (not based
on a taprio capability bit) would risk introducing regressions. For
example, taprio doesn't populate (or validate) qopt->hw, as well as
mqprio.flags, mqprio.shaper, mqprio.min_rate, mqprio.max_rate.
In comparison, adding a capability is functionally equivalent to just
passing the mqprio in a way that drivers can ignore it, except it's
slightly more complicated to use it (need to set the capability).
Ultimately, what made me go for the "mqprio in taprio" variant was that
it's easier for offloading drivers to interpret the mqprio qopt slightly
differently when it comes from taprio vs when it comes from mqprio,
should that ever become necessary.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2023-02-04 21:53:03 +08:00
|
|
|
struct tc_mqprio_qopt_offload mqprio;
|
2023-04-12 02:01:53 +08:00
|
|
|
struct netlink_ext_ack *extack;
|
taprio: Add support for hardware offloading
This allows taprio to offload the schedule enforcement to capable
network cards, resulting in more precise windows and less CPU usage.
The gate mask acts on traffic classes (groups of queues of same
priority), as specified in IEEE 802.1Q-2018, and following the existing
taprio and mqprio semantics.
It is up to the driver to perform conversion between tc and individual
netdev queues if for some reason it needs to make that distinction.
Full offload is requested from the network interface by specifying
"flags 2" in the tc qdisc creation command, which in turn corresponds to
the TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD bit.
The important detail here is the clockid which is implicitly /dev/ptpN
for full offload, and hence not configurable.
A reference counting API is added to support the use case where Ethernet
drivers need to keep the taprio offload structure locally (i.e. they are
a multi-port switch driver, and configuring a port depends on the
settings of other ports as well). The refcount_t variable is kept in a
private structure (__tc_taprio_qopt_offload) and not exposed to drivers.
In the future, the private structure might also be expanded with a
backpointer to taprio_sched *q, to implement the notification system
described in the patch (of when admin became oper, or an error occurred,
etc, so the offload can be monitored with 'tc qdisc show').
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Voon Weifeng <weifeng.voon@intel.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-09-15 09:59:58 +08:00
|
|
|
u8 enable;
|
|
|
|
ktime_t base_time;
|
|
|
|
u64 cycle_time;
|
|
|
|
u64 cycle_time_extension;
|
net/sched: taprio: allow user input of per-tc max SDU
IEEE 802.1Q clause 12.29.1.1 "The queueMaxSDUTable structure and data
types" and 8.6.8.4 "Enhancements for scheduled traffic" talk about the
existence of a per traffic class limitation of maximum frame sizes, with
a fallback on the port-based MTU.
As far as I am able to understand, the 802.1Q Service Data Unit (SDU)
represents the MAC Service Data Unit (MSDU, i.e. L2 payload), excluding
any number of prepended VLAN headers which may be otherwise present in
the MSDU. Therefore, the queueMaxSDU is directly comparable to the
device MTU (1500 means L2 payload sizes are accepted, or frame sizes of
1518 octets, or 1522 plus one VLAN header). Drivers which offload this
are directly responsible of translating into other units of measurement.
To keep the fast path checks optimized, we keep 2 arrays in the qdisc,
one for max_sdu translated into frame length (so that it's comparable to
skb->len), and another for offloading and for dumping back to the user.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-09-28 17:51:58 +08:00
|
|
|
u32 max_sdu[TC_MAX_QUEUE];
|
taprio: Add support for hardware offloading
This allows taprio to offload the schedule enforcement to capable
network cards, resulting in more precise windows and less CPU usage.
The gate mask acts on traffic classes (groups of queues of same
priority), as specified in IEEE 802.1Q-2018, and following the existing
taprio and mqprio semantics.
It is up to the driver to perform conversion between tc and individual
netdev queues if for some reason it needs to make that distinction.
Full offload is requested from the network interface by specifying
"flags 2" in the tc qdisc creation command, which in turn corresponds to
the TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD bit.
The important detail here is the clockid which is implicitly /dev/ptpN
for full offload, and hence not configurable.
A reference counting API is added to support the use case where Ethernet
drivers need to keep the taprio offload structure locally (i.e. they are
a multi-port switch driver, and configuring a port depends on the
settings of other ports as well). The refcount_t variable is kept in a
private structure (__tc_taprio_qopt_offload) and not exposed to drivers.
In the future, the private structure might also be expanded with a
backpointer to taprio_sched *q, to implement the notification system
described in the patch (of when admin became oper, or an error occurred,
etc, so the offload can be monitored with 'tc qdisc show').
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Voon Weifeng <weifeng.voon@intel.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-09-15 09:59:58 +08:00
|
|
|
|
|
|
|
size_t num_entries;
|
2020-02-28 04:58:44 +08:00
|
|
|
struct tc_taprio_sched_entry entries[];
|
taprio: Add support for hardware offloading
This allows taprio to offload the schedule enforcement to capable
network cards, resulting in more precise windows and less CPU usage.
The gate mask acts on traffic classes (groups of queues of same
priority), as specified in IEEE 802.1Q-2018, and following the existing
taprio and mqprio semantics.
It is up to the driver to perform conversion between tc and individual
netdev queues if for some reason it needs to make that distinction.
Full offload is requested from the network interface by specifying
"flags 2" in the tc qdisc creation command, which in turn corresponds to
the TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD bit.
The important detail here is the clockid which is implicitly /dev/ptpN
for full offload, and hence not configurable.
A reference counting API is added to support the use case where Ethernet
drivers need to keep the taprio offload structure locally (i.e. they are
a multi-port switch driver, and configuring a port depends on the
settings of other ports as well). The refcount_t variable is kept in a
private structure (__tc_taprio_qopt_offload) and not exposed to drivers.
In the future, the private structure might also be expanded with a
backpointer to taprio_sched *q, to implement the notification system
described in the patch (of when admin became oper, or an error occurred,
etc, so the offload can be monitored with 'tc qdisc show').
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Voon Weifeng <weifeng.voon@intel.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-09-15 09:59:58 +08:00
|
|
|
};
|
|
|
|
|
2022-07-05 03:02:40 +08:00
|
|
|
#if IS_ENABLED(CONFIG_NET_SCH_TAPRIO)
|
|
|
|
|
taprio: Add support for hardware offloading
This allows taprio to offload the schedule enforcement to capable
network cards, resulting in more precise windows and less CPU usage.
The gate mask acts on traffic classes (groups of queues of same
priority), as specified in IEEE 802.1Q-2018, and following the existing
taprio and mqprio semantics.
It is up to the driver to perform conversion between tc and individual
netdev queues if for some reason it needs to make that distinction.
Full offload is requested from the network interface by specifying
"flags 2" in the tc qdisc creation command, which in turn corresponds to
the TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD bit.
The important detail here is the clockid which is implicitly /dev/ptpN
for full offload, and hence not configurable.
A reference counting API is added to support the use case where Ethernet
drivers need to keep the taprio offload structure locally (i.e. they are
a multi-port switch driver, and configuring a port depends on the
settings of other ports as well). The refcount_t variable is kept in a
private structure (__tc_taprio_qopt_offload) and not exposed to drivers.
In the future, the private structure might also be expanded with a
backpointer to taprio_sched *q, to implement the notification system
described in the patch (of when admin became oper, or an error occurred,
etc, so the offload can be monitored with 'tc qdisc show').
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
Signed-off-by: Voon Weifeng <weifeng.voon@intel.com>
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-09-15 09:59:58 +08:00
|
|
|
/* Reference counting */
|
|
|
|
struct tc_taprio_qopt_offload *taprio_offload_get(struct tc_taprio_qopt_offload
|
|
|
|
*offload);
|
|
|
|
void taprio_offload_free(struct tc_taprio_qopt_offload *offload);
|
|
|
|
|
2022-07-05 03:02:40 +08:00
|
|
|
#else
|
|
|
|
|
|
|
|
/* Reference counting */
|
|
|
|
static inline struct tc_taprio_qopt_offload *
|
|
|
|
taprio_offload_get(struct tc_taprio_qopt_offload *offload)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void taprio_offload_free(struct tc_taprio_qopt_offload *offload)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2021-03-10 22:50:44 +08:00
|
|
|
/* Ensure skb_mstamp_ns, which might have been populated with the txtime, is
|
|
|
|
* not mistaken for a software timestamp, because this will otherwise prevent
|
|
|
|
* the dispatch of hardware timestamps to the socket.
|
|
|
|
*/
|
|
|
|
static inline void skb_txtime_consumed(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
skb->tstamp = ktime_set(0, 0);
|
|
|
|
}
|
|
|
|
|
2021-12-15 01:24:33 +08:00
|
|
|
struct tc_skb_cb {
|
|
|
|
struct qdisc_skb_cb qdisc_cb;
|
|
|
|
|
|
|
|
u16 mru;
|
2022-01-06 23:38:04 +08:00
|
|
|
u8 post_ct:1;
|
|
|
|
u8 post_ct_snat:1;
|
|
|
|
u8 post_ct_dnat:1;
|
2021-12-15 01:24:34 +08:00
|
|
|
u16 zone; /* Only valid if post_ct = true */
|
2021-12-15 01:24:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct tc_skb_cb *tc_skb_cb(const struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct tc_skb_cb *cb = (struct tc_skb_cb *)skb->cb;
|
|
|
|
|
|
|
|
BUILD_BUG_ON(sizeof(*cb) > sizeof_field(struct sk_buff, cb));
|
|
|
|
return cb;
|
|
|
|
}
|
|
|
|
|
2022-09-21 10:41:04 +08:00
|
|
|
static inline bool tc_qdisc_stats_dump(struct Qdisc *sch,
|
|
|
|
unsigned long cl,
|
|
|
|
struct qdisc_walker *arg)
|
|
|
|
{
|
|
|
|
if (arg->count >= arg->skip && arg->fn(sch, cl, arg) < 0) {
|
|
|
|
arg->stop = 1;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
arg->count++;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif
|