Skip to content

Commit 9c66d15

Browse files
vcgomesdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: Voon Weifeng <[email protected]> Signed-off-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 67e80b9 commit 9c66d15

File tree

4 files changed

+392
-44
lines changed

4 files changed

+392
-44
lines changed

include/linux/netdevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ enum tc_setup_type {
847847
TC_SETUP_QDISC_ETF,
848848
TC_SETUP_ROOT_QDISC,
849849
TC_SETUP_QDISC_GRED,
850+
TC_SETUP_QDISC_TAPRIO,
850851
};
851852

852853
/* These structures hold the attributes of bpf state that are being passed

include/net/pkt_sched.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,27 @@ struct tc_etf_qopt_offload {
161161
s32 queue;
162162
};
163163

164+
struct tc_taprio_sched_entry {
165+
u8 command; /* TC_TAPRIO_CMD_* */
166+
167+
/* The gate_mask in the offloading side refers to traffic classes */
168+
u32 gate_mask;
169+
u32 interval;
170+
};
171+
172+
struct tc_taprio_qopt_offload {
173+
u8 enable;
174+
ktime_t base_time;
175+
u64 cycle_time;
176+
u64 cycle_time_extension;
177+
178+
size_t num_entries;
179+
struct tc_taprio_sched_entry entries[0];
180+
};
181+
182+
/* Reference counting */
183+
struct tc_taprio_qopt_offload *taprio_offload_get(struct tc_taprio_qopt_offload
184+
*offload);
185+
void taprio_offload_free(struct tc_taprio_qopt_offload *offload);
186+
164187
#endif

include/uapi/linux/pkt_sched.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,8 @@ enum {
11601160
* [TCA_TAPRIO_ATTR_SCHED_ENTRY_INTERVAL]
11611161
*/
11621162

1163-
#define TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST 0x1
1163+
#define TCA_TAPRIO_ATTR_FLAG_TXTIME_ASSIST BIT(0)
1164+
#define TCA_TAPRIO_ATTR_FLAG_FULL_OFFLOAD BIT(1)
11641165

11651166
enum {
11661167
TCA_TAPRIO_ATTR_UNSPEC,

0 commit comments

Comments
 (0)