Skip to content

Commit

Permalink
taprio: Add support for hardware offloading
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Voon Weifeng <[email protected]>
Signed-off-by: Vladimir Oltean <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
vcgomes authored and davem330 committed Sep 16, 2019
1 parent 67e80b9 commit 9c66d15
Show file tree
Hide file tree
Showing 4 changed files with 392 additions and 44 deletions.
1 change: 1 addition & 0 deletions include/linux/netdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ enum tc_setup_type {
TC_SETUP_QDISC_ETF,
TC_SETUP_ROOT_QDISC,
TC_SETUP_QDISC_GRED,
TC_SETUP_QDISC_TAPRIO,
};

/* These structures hold the attributes of bpf state that are being passed
Expand Down
23 changes: 23 additions & 0 deletions include/net/pkt_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,27 @@ struct tc_etf_qopt_offload {
s32 queue;
};

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 {
u8 enable;
ktime_t base_time;
u64 cycle_time;
u64 cycle_time_extension;

size_t num_entries;
struct tc_taprio_sched_entry entries[0];
};

/* 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);

#endif
3 changes: 2 additions & 1 deletion include/uapi/linux/pkt_sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,8 @@ enum {
* [TCA_TAPRIO_ATTR_SCHED_ENTRY_INTERVAL]
*/

#define TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST 0x1
#define TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST BIT(0)
#define TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD BIT(1)

enum {
TCA_TAPRIO_ATTR_UNSPEC,
Expand Down
Loading

0 comments on commit 9c66d15

Please sign in to comment.