aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-5.4/701-net-0273-net-dsa-ocelot-add-tsn-support-for-felix-switch.patch
blob: 72b101bfb0bc5ae69ad72249593ca238934f1c25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
From 36b446d44d66a6d6a072d3f5e87ebb05e0b88d98 Mon Sep 17 00:00:00 2001
From: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
Date: Fri, 29 Nov 2019 14:28:37 +0800
Subject: [PATCH] net: dsa: ocelot: add tsn support for felix switch

Support tsn capabilities in DSA felix switch driver. This felix tsn
driver is using tsn configuration of ocelot, and registered on each
switch port through DSA port setup.

Signed-off-by: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
---
 drivers/net/dsa/ocelot/Kconfig         |   8 +
 drivers/net/dsa/ocelot/Makefile        |   2 +
 drivers/net/dsa/ocelot/felix.c         |  50 ++++
 drivers/net/dsa/ocelot/felix_tsn.c     | 432 +++++++++++++++++++++++++++++++++
 drivers/net/dsa/ocelot/felix_tsn.h     |  61 +++++
 drivers/net/dsa/ocelot/felix_vsc9959.c |   8 +-
 include/net/dsa.h                      |   1 +
 net/dsa/dsa2.c                         |   4 +
 8 files changed, 564 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/dsa/ocelot/felix_tsn.c
 create mode 100644 drivers/net/dsa/ocelot/felix_tsn.h

--- a/drivers/net/dsa/ocelot/Kconfig
+++ b/drivers/net/dsa/ocelot/Kconfig
@@ -9,3 +9,11 @@ config NET_DSA_MSCC_FELIX
 	  the Vitesse / Microsemi / Microchip Ocelot family of switching cores.
 	  It is embedded as a PCIe function of the NXP LS1028A ENETC integrated
 	  endpoint.
+
+config MSCC_FELIX_SWITCH_TSN
+	tristate "TSN on FELIX switch driver"
+	depends on NET_DSA_MSCC_FELIX
+	depends on TSN
+	help
+	  This driver supports TSN on felix switch.
+
--- a/drivers/net/dsa/ocelot/Makefile
+++ b/drivers/net/dsa/ocelot/Makefile
@@ -4,3 +4,5 @@ obj-$(CONFIG_NET_DSA_MSCC_FELIX) += mscc
 mscc_felix-objs := \
 	felix.o \
 	felix_vsc9959.o
+
+obj-$(CONFIG_MSCC_FELIX_SWITCH_TSN) += felix_tsn.o
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -9,6 +9,38 @@
 #include <linux/of.h>
 #include <net/dsa.h>
 #include "felix.h"
+#include "felix_tsn.h"
+
+#ifdef CONFIG_MSCC_FELIX_SWITCH_TSN
+const struct tsn_ops switch_tsn_ops = {
+	.device_init			= felix_tsn_init,
+	.get_capability                 = felix_tsn_get_cap,
+	.qbv_set			= felix_qbv_set,
+	.qbv_get			= felix_qbv_get,
+	.qbv_get_status			= felix_qbv_get_status,
+	.qbu_set			= felix_qbu_set,
+	.qbu_get                        = felix_qbu_get,
+	.cb_streamid_set		= felix_cb_streamid_set,
+	.cb_streamid_get		= felix_cb_streamid_get,
+	.cb_streamid_counters_get	= felix_cb_streamid_counters_get,
+	.qci_sfi_set			= felix_qci_sfi_set,
+	.qci_sfi_get			= felix_qci_sfi_get,
+	.qci_sfi_counters_get		= felix_qci_sfi_counters_get,
+	.qci_get_maxcap			= felix_qci_max_cap_get,
+	.qci_sgi_set			= felix_qci_sgi_set,
+	.qci_sgi_get			= felix_qci_sgi_get,
+	.qci_sgi_status_get		= felix_qci_sgi_status_get,
+	.qci_fmi_set			= felix_qci_fmi_set,
+	.qci_fmi_get			= felix_qci_fmi_get,
+	.cbs_set			= felix_cbs_set,
+	.cbs_get			= felix_cbs_get,
+	.ct_set				= felix_cut_thru_set,
+	.cbgen_set			= felix_seq_gen_set,
+	.cbrec_set			= felix_seq_rec_set,
+	.cb_get				= felix_cb_get,
+	.dscp_set			= felix_dscp_set,
+};
+#endif
 
 static enum dsa_tag_protocol felix_get_tag_protocol(struct dsa_switch *ds,
 						    int port)
@@ -138,6 +170,21 @@ static int felix_vlan_del(struct dsa_swi
 	return 0;
 }
 
+#ifdef CONFIG_MSCC_FELIX_SWITCH_TSN
+static int felix_tsn_enable(struct dsa_port *dp)
+{
+	struct net_device *dev;
+
+	if (dp->type == DSA_PORT_TYPE_USER) {
+		dev = dp->slave;
+		tsn_port_register(dev,
+				  (struct tsn_ops *)&switch_tsn_ops,
+				  GROUP_OFFSET_SWITCH);
+	}
+	return 0;
+}
+#endif
+
 static int felix_port_enable(struct dsa_switch *ds, int port,
 			     struct phy_device *phy)
 {
@@ -386,6 +433,9 @@ static const struct dsa_switch_ops felix
 	.port_hwtstamp_set	= felix_hwtstamp_set,
 	.port_rxtstamp		= felix_rxtstamp,
 	.port_txtstamp		= felix_txtstamp,
+#ifdef CONFIG_MSCC_FELIX_SWITCH_TSN
+	.port_tsn_enable	= felix_tsn_enable,
+#endif
 };
 
 static struct felix_info *felix_instance_tbl[] = {
--- /dev/null
+++ b/drivers/net/dsa/ocelot/felix_tsn.c
@@ -0,0 +1,432 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/* Felix Switch TSN driver
+ *
+ * Copyright 2018-2019 NXP
+ */
+
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <soc/mscc/ocelot.h>
+#include <net/tsn.h>
+#include "felix.h"
+
+static struct ocelot *felix_dev_to_ocelot(struct net_device *ndev)
+{
+	struct pci_dev *pdev;
+	struct felix *felix;
+
+	pdev = list_entry(ndev->dev.parent, struct pci_dev, dev);
+	felix = pci_get_drvdata(pdev);
+	if (!felix)
+		return NULL;
+
+	return &felix->ocelot;
+}
+
+static int felix_dev_to_port(struct net_device *ndev, struct ocelot *ocelot)
+{
+	struct felix *felix = ocelot_to_felix(ocelot);
+	struct dsa_switch *ds = felix->ds;
+	struct dsa_port *dp;
+	int i;
+
+	for (i = 0; i < ds->num_ports; i++) {
+		dp = &ds->ports[i];
+		if (dp->dn == ndev->dev.of_node)
+			return dp->index;
+	}
+
+	return -ENODEV;
+}
+
+u32 felix_tsn_get_cap(struct net_device *ndev)
+{
+	u32 cap = 0;
+
+	cap = (TSN_CAP_QBV | TSN_CAP_QCI | TSN_CAP_QBU | TSN_CAP_CBS |
+	       TSN_CAP_CB | TSN_CAP_TBS | TSN_CAP_CTH);
+
+	return cap;
+}
+
+int felix_qbv_set(struct net_device *ndev,
+		  struct tsn_qbv_conf *shaper_config)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qbv_set(ocelot, port, shaper_config);
+}
+
+int felix_qbv_get(struct net_device *ndev,
+		  struct tsn_qbv_conf *shaper_config)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qbv_get(ocelot, port, shaper_config);
+}
+
+int felix_qbv_get_status(struct net_device *ndev,
+			 struct tsn_qbv_status *qbvstatus)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qbv_get_status(ocelot, port, qbvstatus);
+}
+
+int felix_qbu_set(struct net_device *ndev, u8 preemptible)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qbu_set(ocelot, port, preemptible);
+}
+
+int felix_qbu_get(struct net_device *ndev, struct tsn_preempt_status *c)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qbu_get(ocelot, port, c);
+}
+
+int felix_cb_streamid_set(struct net_device *ndev, u32 index, bool enable,
+			  struct tsn_cb_streamid *streamid)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_cb_streamid_set(ocelot, port, index, enable, streamid);
+}
+
+int felix_cb_streamid_get(struct net_device *ndev, u32 index,
+			  struct tsn_cb_streamid *streamid)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_cb_streamid_get(ocelot, port, index, streamid);
+}
+
+int felix_cb_streamid_counters_get(struct net_device *ndev, u32 index,
+				   struct tsn_cb_streamid_counters *sc)
+{
+	return 0;
+}
+
+int felix_qci_sfi_set(struct net_device *ndev, u32 index, bool enable,
+		      struct tsn_qci_psfp_sfi_conf *sfi)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qci_sfi_set(ocelot, port, index, enable, sfi);
+}
+
+int felix_qci_sfi_get(struct net_device *ndev, u32 index,
+		      struct tsn_qci_psfp_sfi_conf *sfi)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qci_sfi_get(ocelot, port, index, sfi);
+}
+
+int felix_qci_sfi_counters_get(struct net_device *ndev, u32 index,
+			       struct tsn_qci_psfp_sfi_counters *sfi_cnt)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qci_sfi_counters_get(ocelot, port, index, sfi_cnt);
+}
+
+int felix_qci_max_cap_get(struct net_device *ndev,
+			  struct tsn_qci_psfp_stream_param *stream_para)
+{
+	struct ocelot *ocelot;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+
+	return ocelot_qci_max_cap_get(ocelot, stream_para);
+}
+
+int felix_qci_sgi_set(struct net_device *ndev, u32 index,
+		      struct tsn_qci_psfp_sgi_conf *sgi_conf)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qci_sgi_set(ocelot, port, index, sgi_conf);
+}
+
+int felix_qci_sgi_get(struct net_device *ndev, u32 index,
+		      struct tsn_qci_psfp_sgi_conf *sgi_conf)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qci_sgi_get(ocelot, port, index, sgi_conf);
+}
+
+int felix_qci_sgi_status_get(struct net_device *ndev, u32 index,
+			     struct tsn_psfp_sgi_status *sgi_status)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qci_sgi_status_get(ocelot, port, index, sgi_status);
+}
+
+int felix_qci_fmi_set(struct net_device *ndev, u32 index,
+		      bool enable, struct tsn_qci_psfp_fmi *fmi)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qci_fmi_set(ocelot, port, index, enable, fmi);
+}
+
+int felix_qci_fmi_get(struct net_device *ndev, u32 index,
+		      struct tsn_qci_psfp_fmi *fmi,
+		      struct tsn_qci_psfp_fmi_counters *counters)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_qci_fmi_get(ocelot, port, index, fmi, counters);
+}
+
+int felix_cbs_set(struct net_device *ndev, u8 tc, u8 bw)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_cbs_set(ocelot, port, tc, bw);
+}
+
+int felix_cbs_get(struct net_device *ndev, u8 tc)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_cbs_get(ocelot, port, tc);
+}
+
+int felix_cut_thru_set(struct net_device *ndev, u8 cut_thru)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_cut_thru_set(ocelot, port, cut_thru);
+}
+
+int felix_seq_gen_set(struct net_device *ndev, u32 index,
+		      struct tsn_seq_gen_conf *sg_conf)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_seq_gen_set(ocelot, port, index, sg_conf);
+}
+
+int felix_seq_rec_set(struct net_device *ndev, u32 index,
+		      struct tsn_seq_rec_conf *sr_conf)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_seq_rec_set(ocelot, port, index, sr_conf);
+}
+
+int felix_cb_get(struct net_device *ndev, u32 index,
+		 struct tsn_cb_status *c)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_cb_get(ocelot, port, index, c);
+}
+
+int felix_dscp_set(struct net_device *ndev, bool enable, const u8 dscp_ix,
+		   struct tsn_qos_switch_dscp_conf *c)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return -ENODEV;
+	port = felix_dev_to_port(ndev, ocelot);
+	if (port < 0)
+		return -ENODEV;
+
+	return ocelot_dscp_set(ocelot, port, enable, dscp_ix, c);
+}
+
+void felix_tsn_init(struct net_device *ndev)
+{
+	struct ocelot *ocelot;
+	int port;
+
+	ocelot = felix_dev_to_ocelot(ndev);
+	if (!ocelot)
+		return;
+	port = felix_dev_to_port(ndev, ocelot);
+
+	ocelot_pcp_map_enable(ocelot, port);
+	ocelot_rtag_parse_enable(ocelot, port);
+}
--- /dev/null
+++ b/drivers/net/dsa/ocelot/felix_tsn.h
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: (GPL-2.0 OR MIT)
+ *
+ * TSN_SWITCH driver
+ *
+ * Copyright 2018-2019 NXP
+ */
+
+#ifndef _MSCC_FELIX_SWITCH_TSN_H_
+#define _MSCC_FELIX_SWITCH_TSN_H_
+#include <net/tsn.h>
+
+u32 felix_tsn_get_cap(struct net_device *ndev);
+int felix_qbv_set(struct net_device *ndev,
+		  struct tsn_qbv_conf *shaper_config);
+int felix_qbv_get(struct net_device *ndev,
+		  struct tsn_qbv_conf *shaper_config);
+int felix_qbv_get_status(struct net_device *ndev,
+			 struct tsn_qbv_status *qbvstatus);
+int felix_cut_thru_set(struct net_device *ndev, u8 cut_thru);
+int felix_cbs_set(struct net_device *ndev, u8 tc, u8 bw);
+int felix_cbs_get(struct net_device *ndev, u8 tc);
+int felix_qbu_set(struct net_device *ndev, u8 preemptible);
+int felix_qbu_get(struct net_device *ndev, struct tsn_preempt_status *c);
+int felix_cb_streamid_get(struct net_device *ndev, u32 index,
+			  struct tsn_cb_streamid *streamid);
+int felix_cb_streamid_set(struct net_device *ndev, u32 index,
+			  bool enable, struct tsn_cb_streamid *streamid);
+int felix_cb_streamid_counters_get(struct net_device *ndev, u32 index,
+				   struct tsn_cb_streamid_counters *sc);
+int felix_qci_sfi_get(struct net_device *ndev, u32 index,
+		      struct tsn_qci_psfp_sfi_conf *sfi);
+int felix_qci_sfi_set(struct net_device *ndev, u32 index,
+		      bool enable, struct tsn_qci_psfp_sfi_conf *sfi);
+int felix_cb_streamid_counters_get(struct net_device *ndev, u32 index,
+				   struct tsn_cb_streamid_counters *s_counters);
+int felix_qci_sfi_counters_get(struct net_device *ndev, u32 index,
+			       struct tsn_qci_psfp_sfi_counters *sfi_counters);
+int felix_qci_max_cap_get(struct net_device *ndev,
+			  struct tsn_qci_psfp_stream_param *stream_para);
+int felix_qci_sgi_set(struct net_device *ndev, u32 index,
+		      struct tsn_qci_psfp_sgi_conf *sgi_conf);
+int felix_qci_sgi_get(struct net_device *ndev, u32 index,
+		      struct tsn_qci_psfp_sgi_conf *sgi_conf);
+int felix_qci_sgi_status_get(struct net_device *ndev, u16 index,
+			     struct tsn_psfp_sgi_status *sgi_status);
+int felix_qci_fmi_set(struct net_device *ndev, u32 index,
+		      bool enable, struct tsn_qci_psfp_fmi *fmi);
+int felix_qci_fmi_get(struct net_device *ndev, u32 index,
+		      struct tsn_qci_psfp_fmi *fmi,
+		      struct tsn_qci_psfp_fmi_counters *counters);
+int felix_seq_gen_set(struct net_device *ndev, u32 index,
+		      struct tsn_seq_gen_conf *sg_conf);
+int felix_seq_rec_set(struct net_device *ndev, u32 index,
+		      struct tsn_seq_rec_conf *sr_conf);
+int felix_cb_get(struct net_device *ndev, u32 index,
+		 struct tsn_cb_status  *c);
+int felix_dscp_set(struct net_device *ndev, bool enable, const u8 dscp_ix,
+		   struct tsn_qos_switch_dscp_conf *c);
+
+void felix_tsn_init(struct net_device *ndev);
+#endif
--- a/drivers/net/dsa/ocelot/felix_vsc9959.c
+++ b/drivers/net/dsa/ocelot/felix_vsc9959.c
@@ -176,7 +176,7 @@ static const u32 vsc9959_qsys_regmap[] =
 	REG(QSYS_QMAXSDU_CFG_6,			0x00f62c),
 	REG(QSYS_QMAXSDU_CFG_7,			0x00f648),
 	REG(QSYS_PREEMPTION_CFG,		0x00f664),
-	REG_RESERVED(QSYS_CIR_CFG),
+	REG(QSYS_CIR_CFG,			0x000000),
 	REG(QSYS_EIR_CFG,			0x000004),
 	REG(QSYS_SE_CFG,			0x000008),
 	REG(QSYS_SE_DWRR_CFG,			0x00000c),
@@ -269,7 +269,7 @@ static const u32 vsc9959_sys_regmap[] =
 	REG_RESERVED(SYS_MMGT_FAST),
 	REG_RESERVED(SYS_EVENTS_DIF),
 	REG_RESERVED(SYS_EVENTS_CORE),
-	REG_RESERVED(SYS_CNT),
+	REG(SYS_CNT,				0x000000),
 	REG(SYS_PTP_STATUS,			0x000f14),
 	REG(SYS_PTP_TXSTAMP,			0x000f18),
 	REG(SYS_PTP_NXT,			0x000f1c),
@@ -290,6 +290,10 @@ static const u32 vsc9959_ptp_regmap[] =
 	REG(PTP_CFG_MISC,                  0x0000a0),
 	REG(PTP_CLK_CFG_ADJ_CFG,           0x0000a4),
 	REG(PTP_CLK_CFG_ADJ_FREQ,          0x0000a8),
+	REG(PTP_CUR_NSF,                   0x0000bc),
+	REG(PTP_CUR_NSEC,                  0x0000c0),
+	REG(PTP_CUR_SEC_LSB,               0x0000c4),
+	REG(PTP_CUR_SEC_MSB,               0x0000c8),
 };
 
 static const u32 vsc9959_gcb_regmap[] = {
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -559,6 +559,7 @@ struct dsa_switch_ops {
 	 */
 	netdev_tx_t (*port_deferred_xmit)(struct dsa_switch *ds, int port,
 					  struct sk_buff *skb);
+	int	(*port_tsn_enable)(struct dsa_port *dp);
 };
 
 struct dsa_switch_driver {
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -323,6 +323,10 @@ static int dsa_port_setup(struct dsa_por
 		if (err)
 			break;
 
+		/* Enable TSN function on switch port */
+		if (ds->ops->port_tsn_enable)
+			ds->ops->port_tsn_enable(dp);
+
 		devlink_port_type_eth_set(dlp, dp->slave);
 		break;
 	}