aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/ti/keystone_ethss2.c')
-rw-r--r--drivers/net/ethernet/ti/keystone_ethss2.c396
1 files changed, 335 insertions, 61 deletions
diff --git a/drivers/net/ethernet/ti/keystone_ethss2.c b/drivers/net/ethernet/ti/keystone_ethss2.c
index 5f2c64f56c4..77cf57c5512 100644
--- a/drivers/net/ethernet/ti/keystone_ethss2.c
+++ b/drivers/net/ethernet/ti/keystone_ethss2.c
@@ -60,6 +60,9 @@
60#define MACSL_RX_ENABLE_CSF BIT(23) 60#define MACSL_RX_ENABLE_CSF BIT(23)
61#define MACSL_RX_ENABLE_EXT_CTL BIT(18) 61#define MACSL_RX_ENABLE_EXT_CTL BIT(18)
62#define MACSL_ENABLE BIT(5) 62#define MACSL_ENABLE BIT(5)
63#define MACSL_DEFAULT_CONFIG (MACSL_ENABLE |\
64 MACSL_RX_ENABLE_EXT_CTL |\
65 MACSL_RX_ENABLE_CSF)
63#define GMACSL_RET_WARN_RESET_INCOMPLETE -2 66#define GMACSL_RET_WARN_RESET_INCOMPLETE -2
64 67
65#define CPSW2_NUM_PORTS 9 68#define CPSW2_NUM_PORTS 9
@@ -157,10 +160,13 @@
157 160
158#define MAX_SLAVES (CPSW2_NUM_PORTS - 1) 161#define MAX_SLAVES (CPSW2_NUM_PORTS - 1)
159 162
160/* s: 0-based slave_port */ 163/* s: 0-based slave_num */
161#define SGMII2_BASE(s) (((s) < 2) ? cpsw_dev->sgmii_port_regs : \ 164#define SGMII2_BASE(s) (((s) < 2) ? cpsw_dev->sgmii_port_regs : \
162 cpsw_dev->sgmii_port_regs + SGMII_REGS_SIZE * 2) 165 cpsw_dev->sgmii_port_regs + SGMII_REGS_SIZE * 2)
163 166
167#define IS_SGMII_MAC_PHY(i) \
168 (((i) == SGMII_LINK_MAC_PHY) || ((i) == SGMII_LINK_MAC_PHY_MASTER))
169
164 170
165/* CPSW Statistics register map size */ 171/* CPSW Statistics register map size */
166#define CPSW2_STATS_REGS_SIZE 0x200 172#define CPSW2_STATS_REGS_SIZE 0x200
@@ -179,6 +185,9 @@ struct cpts2_port_ts_ctl {
179 u8 ts_mcast_type; 185 u8 ts_mcast_type;
180}; 186};
181 187
188/* slave_num: 0-based
189 * port_num: 1-based
190 */
182struct cpsw2_slave { 191struct cpsw2_slave {
183 struct cpsw2_slave_regs __iomem *regs; 192 struct cpsw2_slave_regs __iomem *regs;
184 int slave_num; 193 int slave_num;
@@ -348,9 +357,50 @@ struct cpsw2_hw_stats {
348 u32 ale_rate_limit_drop; 357 u32 ale_rate_limit_drop;
349 u32 ale_vid_ingress_drop; 358 u32 ale_vid_ingress_drop;
350 u32 ale_da_eq_sa_drop; 359 u32 ale_da_eq_sa_drop;
351 u32 ale_block_drop; 360 u32 rsvd0[3];
352 u32 ale_secure_drop; 361 u32 ale_unknown_ucast;
353 u32 ale_auth_drop; 362 u32 ale_unknown_ucast_bytes;
363 u32 ale_unknown_mcast;
364 u32 ale_unknown_mcast_bytes;
365 u32 ale_unknown_bcast;
366 u32 ale_unknown_bcast_bytes;
367 u32 ale_pol_match;
368 u32 ale_pol_match_red;
369 u32 ale_pol_match_yellow;
370 u32 rsvd1[44];
371 u32 tx_mem_protect_err;
372 u32 tx_pri0;
373 u32 tx_pri1;
374 u32 tx_pri2;
375 u32 tx_pri3;
376 u32 tx_pri4;
377 u32 tx_pri5;
378 u32 tx_pri6;
379 u32 tx_pri7;
380 u32 tx_pri0_bcnt;
381 u32 tx_pri1_bcnt;
382 u32 tx_pri2_bcnt;
383 u32 tx_pri3_bcnt;
384 u32 tx_pri4_bcnt;
385 u32 tx_pri5_bcnt;
386 u32 tx_pri6_bcnt;
387 u32 tx_pri7_bcnt;
388 u32 tx_pri0_drop;
389 u32 tx_pri1_drop;
390 u32 tx_pri2_drop;
391 u32 tx_pri3_drop;
392 u32 tx_pri4_drop;
393 u32 tx_pri5_drop;
394 u32 tx_pri6_drop;
395 u32 tx_pri7_drop;
396 u32 tx_pri0_drop_bcnt;
397 u32 tx_pri1_drop_bcnt;
398 u32 tx_pri2_drop_bcnt;
399 u32 tx_pri3_drop_bcnt;
400 u32 tx_pri4_drop_bcnt;
401 u32 tx_pri5_drop_bcnt;
402 u32 tx_pri6_drop_bcnt;
403 u32 tx_pri7_drop_bcnt;
354}; 404};
355 405
356/* Offset 0x3e000 */ 406/* Offset 0x3e000 */
@@ -486,9 +536,32 @@ static const struct netcp2_ethtool_stat et_stats[] = {
486 {CPSW2_STATS0_INFO(ale_rate_limit_drop)}, 536 {CPSW2_STATS0_INFO(ale_rate_limit_drop)},
487 {CPSW2_STATS0_INFO(ale_vid_ingress_drop)}, 537 {CPSW2_STATS0_INFO(ale_vid_ingress_drop)},
488 {CPSW2_STATS0_INFO(ale_da_eq_sa_drop)}, 538 {CPSW2_STATS0_INFO(ale_da_eq_sa_drop)},
489 {CPSW2_STATS0_INFO(ale_block_drop)}, 539 {CPSW2_STATS0_INFO(ale_unknown_ucast)},
490 {CPSW2_STATS0_INFO(ale_secure_drop)}, 540 {CPSW2_STATS0_INFO(ale_unknown_ucast_bytes)},
491 {CPSW2_STATS0_INFO(ale_auth_drop)}, 541 {CPSW2_STATS0_INFO(ale_unknown_mcast)},
542 {CPSW2_STATS0_INFO(ale_unknown_mcast_bytes)},
543 {CPSW2_STATS0_INFO(ale_unknown_bcast)},
544 {CPSW2_STATS0_INFO(ale_unknown_bcast_bytes)},
545 {CPSW2_STATS0_INFO(ale_pol_match)},
546 {CPSW2_STATS0_INFO(ale_pol_match_red)},
547 {CPSW2_STATS0_INFO(ale_pol_match_yellow)},
548 {CPSW2_STATS0_INFO(tx_mem_protect_err)},
549 {CPSW2_STATS0_INFO(tx_pri0_drop)},
550 {CPSW2_STATS0_INFO(tx_pri1_drop)},
551 {CPSW2_STATS0_INFO(tx_pri2_drop)},
552 {CPSW2_STATS0_INFO(tx_pri3_drop)},
553 {CPSW2_STATS0_INFO(tx_pri4_drop)},
554 {CPSW2_STATS0_INFO(tx_pri5_drop)},
555 {CPSW2_STATS0_INFO(tx_pri6_drop)},
556 {CPSW2_STATS0_INFO(tx_pri7_drop)},
557 {CPSW2_STATS0_INFO(tx_pri0_drop_bcnt)},
558 {CPSW2_STATS0_INFO(tx_pri1_drop_bcnt)},
559 {CPSW2_STATS0_INFO(tx_pri2_drop_bcnt)},
560 {CPSW2_STATS0_INFO(tx_pri3_drop_bcnt)},
561 {CPSW2_STATS0_INFO(tx_pri4_drop_bcnt)},
562 {CPSW2_STATS0_INFO(tx_pri5_drop_bcnt)},
563 {CPSW2_STATS0_INFO(tx_pri6_drop_bcnt)},
564 {CPSW2_STATS0_INFO(tx_pri7_drop_bcnt)},
492 /* CPSW module 1 */ 565 /* CPSW module 1 */
493 {CPSW2_STATS1_INFO(rx_good_frames)}, 566 {CPSW2_STATS1_INFO(rx_good_frames)},
494 {CPSW2_STATS1_INFO(rx_broadcast_frames)}, 567 {CPSW2_STATS1_INFO(rx_broadcast_frames)},
@@ -529,9 +602,32 @@ static const struct netcp2_ethtool_stat et_stats[] = {
529 {CPSW2_STATS1_INFO(ale_rate_limit_drop)}, 602 {CPSW2_STATS1_INFO(ale_rate_limit_drop)},
530 {CPSW2_STATS1_INFO(ale_vid_ingress_drop)}, 603 {CPSW2_STATS1_INFO(ale_vid_ingress_drop)},
531 {CPSW2_STATS1_INFO(ale_da_eq_sa_drop)}, 604 {CPSW2_STATS1_INFO(ale_da_eq_sa_drop)},
532 {CPSW2_STATS1_INFO(ale_block_drop)}, 605 {CPSW2_STATS1_INFO(ale_unknown_ucast)},
533 {CPSW2_STATS1_INFO(ale_secure_drop)}, 606 {CPSW2_STATS1_INFO(ale_unknown_ucast_bytes)},
534 {CPSW2_STATS1_INFO(ale_auth_drop)}, 607 {CPSW2_STATS1_INFO(ale_unknown_mcast)},
608 {CPSW2_STATS1_INFO(ale_unknown_mcast_bytes)},
609 {CPSW2_STATS1_INFO(ale_unknown_bcast)},
610 {CPSW2_STATS1_INFO(ale_unknown_bcast_bytes)},
611 {CPSW2_STATS1_INFO(ale_pol_match)},
612 {CPSW2_STATS1_INFO(ale_pol_match_red)},
613 {CPSW2_STATS1_INFO(ale_pol_match_yellow)},
614 {CPSW2_STATS1_INFO(tx_mem_protect_err)},
615 {CPSW2_STATS1_INFO(tx_pri0_drop)},
616 {CPSW2_STATS1_INFO(tx_pri1_drop)},
617 {CPSW2_STATS1_INFO(tx_pri2_drop)},
618 {CPSW2_STATS1_INFO(tx_pri3_drop)},
619 {CPSW2_STATS1_INFO(tx_pri4_drop)},
620 {CPSW2_STATS1_INFO(tx_pri5_drop)},
621 {CPSW2_STATS1_INFO(tx_pri6_drop)},
622 {CPSW2_STATS1_INFO(tx_pri7_drop)},
623 {CPSW2_STATS1_INFO(tx_pri0_drop_bcnt)},
624 {CPSW2_STATS1_INFO(tx_pri1_drop_bcnt)},
625 {CPSW2_STATS1_INFO(tx_pri2_drop_bcnt)},
626 {CPSW2_STATS1_INFO(tx_pri3_drop_bcnt)},
627 {CPSW2_STATS1_INFO(tx_pri4_drop_bcnt)},
628 {CPSW2_STATS1_INFO(tx_pri5_drop_bcnt)},
629 {CPSW2_STATS1_INFO(tx_pri6_drop_bcnt)},
630 {CPSW2_STATS1_INFO(tx_pri7_drop_bcnt)},
535 /* CPSW module 2 */ 631 /* CPSW module 2 */
536 {CPSW2_STATS2_INFO(rx_good_frames)}, 632 {CPSW2_STATS2_INFO(rx_good_frames)},
537 {CPSW2_STATS2_INFO(rx_broadcast_frames)}, 633 {CPSW2_STATS2_INFO(rx_broadcast_frames)},
@@ -572,9 +668,32 @@ static const struct netcp2_ethtool_stat et_stats[] = {
572 {CPSW2_STATS2_INFO(ale_rate_limit_drop)}, 668 {CPSW2_STATS2_INFO(ale_rate_limit_drop)},
573 {CPSW2_STATS2_INFO(ale_vid_ingress_drop)}, 669 {CPSW2_STATS2_INFO(ale_vid_ingress_drop)},
574 {CPSW2_STATS2_INFO(ale_da_eq_sa_drop)}, 670 {CPSW2_STATS2_INFO(ale_da_eq_sa_drop)},
575 {CPSW2_STATS2_INFO(ale_block_drop)}, 671 {CPSW2_STATS2_INFO(ale_unknown_ucast)},
576 {CPSW2_STATS2_INFO(ale_secure_drop)}, 672 {CPSW2_STATS2_INFO(ale_unknown_ucast_bytes)},
577 {CPSW2_STATS2_INFO(ale_auth_drop)}, 673 {CPSW2_STATS2_INFO(ale_unknown_mcast)},
674 {CPSW2_STATS2_INFO(ale_unknown_mcast_bytes)},
675 {CPSW2_STATS2_INFO(ale_unknown_bcast)},
676 {CPSW2_STATS2_INFO(ale_unknown_bcast_bytes)},
677 {CPSW2_STATS2_INFO(ale_pol_match)},
678 {CPSW2_STATS2_INFO(ale_pol_match_red)},
679 {CPSW2_STATS2_INFO(ale_pol_match_yellow)},
680 {CPSW2_STATS2_INFO(tx_mem_protect_err)},
681 {CPSW2_STATS2_INFO(tx_pri0_drop)},
682 {CPSW2_STATS2_INFO(tx_pri1_drop)},
683 {CPSW2_STATS2_INFO(tx_pri2_drop)},
684 {CPSW2_STATS2_INFO(tx_pri3_drop)},
685 {CPSW2_STATS2_INFO(tx_pri4_drop)},
686 {CPSW2_STATS2_INFO(tx_pri5_drop)},
687 {CPSW2_STATS2_INFO(tx_pri6_drop)},
688 {CPSW2_STATS2_INFO(tx_pri7_drop)},
689 {CPSW2_STATS2_INFO(tx_pri0_drop_bcnt)},
690 {CPSW2_STATS2_INFO(tx_pri1_drop_bcnt)},
691 {CPSW2_STATS2_INFO(tx_pri2_drop_bcnt)},
692 {CPSW2_STATS2_INFO(tx_pri3_drop_bcnt)},
693 {CPSW2_STATS2_INFO(tx_pri4_drop_bcnt)},
694 {CPSW2_STATS2_INFO(tx_pri5_drop_bcnt)},
695 {CPSW2_STATS2_INFO(tx_pri6_drop_bcnt)},
696 {CPSW2_STATS2_INFO(tx_pri7_drop_bcnt)},
578 /* CPSW module 3 */ 697 /* CPSW module 3 */
579 {CPSW2_STATS3_INFO(rx_good_frames)}, 698 {CPSW2_STATS3_INFO(rx_good_frames)},
580 {CPSW2_STATS3_INFO(rx_broadcast_frames)}, 699 {CPSW2_STATS3_INFO(rx_broadcast_frames)},
@@ -615,9 +734,32 @@ static const struct netcp2_ethtool_stat et_stats[] = {
615 {CPSW2_STATS3_INFO(ale_rate_limit_drop)}, 734 {CPSW2_STATS3_INFO(ale_rate_limit_drop)},
616 {CPSW2_STATS3_INFO(ale_vid_ingress_drop)}, 735 {CPSW2_STATS3_INFO(ale_vid_ingress_drop)},
617 {CPSW2_STATS3_INFO(ale_da_eq_sa_drop)}, 736 {CPSW2_STATS3_INFO(ale_da_eq_sa_drop)},
618 {CPSW2_STATS3_INFO(ale_block_drop)}, 737 {CPSW2_STATS3_INFO(ale_unknown_ucast)},
619 {CPSW2_STATS3_INFO(ale_secure_drop)}, 738 {CPSW2_STATS3_INFO(ale_unknown_ucast_bytes)},
620 {CPSW2_STATS3_INFO(ale_auth_drop)}, 739 {CPSW2_STATS3_INFO(ale_unknown_mcast)},
740 {CPSW2_STATS3_INFO(ale_unknown_mcast_bytes)},
741 {CPSW2_STATS3_INFO(ale_unknown_bcast)},
742 {CPSW2_STATS3_INFO(ale_unknown_bcast_bytes)},
743 {CPSW2_STATS3_INFO(ale_pol_match)},
744 {CPSW2_STATS3_INFO(ale_pol_match_red)},
745 {CPSW2_STATS3_INFO(ale_pol_match_yellow)},
746 {CPSW2_STATS3_INFO(tx_mem_protect_err)},
747 {CPSW2_STATS3_INFO(tx_pri0_drop)},
748 {CPSW2_STATS3_INFO(tx_pri1_drop)},
749 {CPSW2_STATS3_INFO(tx_pri2_drop)},
750 {CPSW2_STATS3_INFO(tx_pri3_drop)},
751 {CPSW2_STATS3_INFO(tx_pri4_drop)},
752 {CPSW2_STATS3_INFO(tx_pri5_drop)},
753 {CPSW2_STATS3_INFO(tx_pri6_drop)},
754 {CPSW2_STATS3_INFO(tx_pri7_drop)},
755 {CPSW2_STATS3_INFO(tx_pri0_drop_bcnt)},
756 {CPSW2_STATS3_INFO(tx_pri1_drop_bcnt)},
757 {CPSW2_STATS3_INFO(tx_pri2_drop_bcnt)},
758 {CPSW2_STATS3_INFO(tx_pri3_drop_bcnt)},
759 {CPSW2_STATS3_INFO(tx_pri4_drop_bcnt)},
760 {CPSW2_STATS3_INFO(tx_pri5_drop_bcnt)},
761 {CPSW2_STATS3_INFO(tx_pri6_drop_bcnt)},
762 {CPSW2_STATS3_INFO(tx_pri7_drop_bcnt)},
621 /* CPSW module 4 */ 763 /* CPSW module 4 */
622 {CPSW2_STATS4_INFO(rx_good_frames)}, 764 {CPSW2_STATS4_INFO(rx_good_frames)},
623 {CPSW2_STATS4_INFO(rx_broadcast_frames)}, 765 {CPSW2_STATS4_INFO(rx_broadcast_frames)},
@@ -658,9 +800,32 @@ static const struct netcp2_ethtool_stat et_stats[] = {
658 {CPSW2_STATS4_INFO(ale_rate_limit_drop)}, 800 {CPSW2_STATS4_INFO(ale_rate_limit_drop)},
659 {CPSW2_STATS4_INFO(ale_vid_ingress_drop)}, 801 {CPSW2_STATS4_INFO(ale_vid_ingress_drop)},
660 {CPSW2_STATS4_INFO(ale_da_eq_sa_drop)}, 802 {CPSW2_STATS4_INFO(ale_da_eq_sa_drop)},
661 {CPSW2_STATS4_INFO(ale_block_drop)}, 803 {CPSW2_STATS4_INFO(ale_unknown_ucast)},
662 {CPSW2_STATS4_INFO(ale_secure_drop)}, 804 {CPSW2_STATS4_INFO(ale_unknown_ucast_bytes)},
663 {CPSW2_STATS4_INFO(ale_auth_drop)}, 805 {CPSW2_STATS4_INFO(ale_unknown_mcast)},
806 {CPSW2_STATS4_INFO(ale_unknown_mcast_bytes)},
807 {CPSW2_STATS4_INFO(ale_unknown_bcast)},
808 {CPSW2_STATS4_INFO(ale_unknown_bcast_bytes)},
809 {CPSW2_STATS4_INFO(ale_pol_match)},
810 {CPSW2_STATS4_INFO(ale_pol_match_red)},
811 {CPSW2_STATS4_INFO(ale_pol_match_yellow)},
812 {CPSW2_STATS4_INFO(tx_mem_protect_err)},
813 {CPSW2_STATS4_INFO(tx_pri0_drop)},
814 {CPSW2_STATS4_INFO(tx_pri1_drop)},
815 {CPSW2_STATS4_INFO(tx_pri2_drop)},
816 {CPSW2_STATS4_INFO(tx_pri3_drop)},
817 {CPSW2_STATS4_INFO(tx_pri4_drop)},
818 {CPSW2_STATS4_INFO(tx_pri5_drop)},
819 {CPSW2_STATS4_INFO(tx_pri6_drop)},
820 {CPSW2_STATS4_INFO(tx_pri7_drop)},
821 {CPSW2_STATS4_INFO(tx_pri0_drop_bcnt)},
822 {CPSW2_STATS4_INFO(tx_pri1_drop_bcnt)},
823 {CPSW2_STATS4_INFO(tx_pri2_drop_bcnt)},
824 {CPSW2_STATS4_INFO(tx_pri3_drop_bcnt)},
825 {CPSW2_STATS4_INFO(tx_pri4_drop_bcnt)},
826 {CPSW2_STATS4_INFO(tx_pri5_drop_bcnt)},
827 {CPSW2_STATS4_INFO(tx_pri6_drop_bcnt)},
828 {CPSW2_STATS4_INFO(tx_pri7_drop_bcnt)},
664 /* CPSW module 5 */ 829 /* CPSW module 5 */
665 {CPSW2_STATS5_INFO(rx_good_frames)}, 830 {CPSW2_STATS5_INFO(rx_good_frames)},
666 {CPSW2_STATS5_INFO(rx_broadcast_frames)}, 831 {CPSW2_STATS5_INFO(rx_broadcast_frames)},
@@ -701,9 +866,32 @@ static const struct netcp2_ethtool_stat et_stats[] = {
701 {CPSW2_STATS5_INFO(ale_rate_limit_drop)}, 866 {CPSW2_STATS5_INFO(ale_rate_limit_drop)},
702 {CPSW2_STATS5_INFO(ale_vid_ingress_drop)}, 867 {CPSW2_STATS5_INFO(ale_vid_ingress_drop)},
703 {CPSW2_STATS5_INFO(ale_da_eq_sa_drop)}, 868 {CPSW2_STATS5_INFO(ale_da_eq_sa_drop)},
704 {CPSW2_STATS5_INFO(ale_block_drop)}, 869 {CPSW2_STATS5_INFO(ale_unknown_ucast)},
705 {CPSW2_STATS5_INFO(ale_secure_drop)}, 870 {CPSW2_STATS5_INFO(ale_unknown_ucast_bytes)},
706 {CPSW2_STATS5_INFO(ale_auth_drop)}, 871 {CPSW2_STATS5_INFO(ale_unknown_mcast)},
872 {CPSW2_STATS5_INFO(ale_unknown_mcast_bytes)},
873 {CPSW2_STATS5_INFO(ale_unknown_bcast)},
874 {CPSW2_STATS5_INFO(ale_unknown_bcast_bytes)},
875 {CPSW2_STATS5_INFO(ale_pol_match)},
876 {CPSW2_STATS5_INFO(ale_pol_match_red)},
877 {CPSW2_STATS5_INFO(ale_pol_match_yellow)},
878 {CPSW2_STATS5_INFO(tx_mem_protect_err)},
879 {CPSW2_STATS5_INFO(tx_pri0_drop)},
880 {CPSW2_STATS5_INFO(tx_pri1_drop)},
881 {CPSW2_STATS5_INFO(tx_pri2_drop)},
882 {CPSW2_STATS5_INFO(tx_pri3_drop)},
883 {CPSW2_STATS5_INFO(tx_pri4_drop)},
884 {CPSW2_STATS5_INFO(tx_pri5_drop)},
885 {CPSW2_STATS5_INFO(tx_pri6_drop)},
886 {CPSW2_STATS5_INFO(tx_pri7_drop)},
887 {CPSW2_STATS5_INFO(tx_pri0_drop_bcnt)},
888 {CPSW2_STATS5_INFO(tx_pri1_drop_bcnt)},
889 {CPSW2_STATS5_INFO(tx_pri2_drop_bcnt)},
890 {CPSW2_STATS5_INFO(tx_pri3_drop_bcnt)},
891 {CPSW2_STATS5_INFO(tx_pri4_drop_bcnt)},
892 {CPSW2_STATS5_INFO(tx_pri5_drop_bcnt)},
893 {CPSW2_STATS5_INFO(tx_pri6_drop_bcnt)},
894 {CPSW2_STATS5_INFO(tx_pri7_drop_bcnt)},
707 /* CPSW module 6 */ 895 /* CPSW module 6 */
708 {CPSW2_STATS6_INFO(rx_good_frames)}, 896 {CPSW2_STATS6_INFO(rx_good_frames)},
709 {CPSW2_STATS6_INFO(rx_broadcast_frames)}, 897 {CPSW2_STATS6_INFO(rx_broadcast_frames)},
@@ -744,9 +932,32 @@ static const struct netcp2_ethtool_stat et_stats[] = {
744 {CPSW2_STATS6_INFO(ale_rate_limit_drop)}, 932 {CPSW2_STATS6_INFO(ale_rate_limit_drop)},
745 {CPSW2_STATS6_INFO(ale_vid_ingress_drop)}, 933 {CPSW2_STATS6_INFO(ale_vid_ingress_drop)},
746 {CPSW2_STATS6_INFO(ale_da_eq_sa_drop)}, 934 {CPSW2_STATS6_INFO(ale_da_eq_sa_drop)},
747 {CPSW2_STATS6_INFO(ale_block_drop)}, 935 {CPSW2_STATS6_INFO(ale_unknown_ucast)},
748 {CPSW2_STATS6_INFO(ale_secure_drop)}, 936 {CPSW2_STATS6_INFO(ale_unknown_ucast_bytes)},
749 {CPSW2_STATS6_INFO(ale_auth_drop)}, 937 {CPSW2_STATS6_INFO(ale_unknown_mcast)},
938 {CPSW2_STATS6_INFO(ale_unknown_mcast_bytes)},
939 {CPSW2_STATS6_INFO(ale_unknown_bcast)},
940 {CPSW2_STATS6_INFO(ale_unknown_bcast_bytes)},
941 {CPSW2_STATS6_INFO(ale_pol_match)},
942 {CPSW2_STATS6_INFO(ale_pol_match_red)},
943 {CPSW2_STATS6_INFO(ale_pol_match_yellow)},
944 {CPSW2_STATS6_INFO(tx_mem_protect_err)},
945 {CPSW2_STATS6_INFO(tx_pri0_drop)},
946 {CPSW2_STATS6_INFO(tx_pri1_drop)},
947 {CPSW2_STATS6_INFO(tx_pri2_drop)},
948 {CPSW2_STATS6_INFO(tx_pri3_drop)},
949 {CPSW2_STATS6_INFO(tx_pri4_drop)},
950 {CPSW2_STATS6_INFO(tx_pri5_drop)},
951 {CPSW2_STATS6_INFO(tx_pri6_drop)},
952 {CPSW2_STATS6_INFO(tx_pri7_drop)},
953 {CPSW2_STATS6_INFO(tx_pri0_drop_bcnt)},
954 {CPSW2_STATS6_INFO(tx_pri1_drop_bcnt)},
955 {CPSW2_STATS6_INFO(tx_pri2_drop_bcnt)},
956 {CPSW2_STATS6_INFO(tx_pri3_drop_bcnt)},
957 {CPSW2_STATS6_INFO(tx_pri4_drop_bcnt)},
958 {CPSW2_STATS6_INFO(tx_pri5_drop_bcnt)},
959 {CPSW2_STATS6_INFO(tx_pri6_drop_bcnt)},
960 {CPSW2_STATS6_INFO(tx_pri7_drop_bcnt)},
750 /* CPSW module 7 */ 961 /* CPSW module 7 */
751 {CPSW2_STATS7_INFO(rx_good_frames)}, 962 {CPSW2_STATS7_INFO(rx_good_frames)},
752 {CPSW2_STATS7_INFO(rx_broadcast_frames)}, 963 {CPSW2_STATS7_INFO(rx_broadcast_frames)},
@@ -787,9 +998,32 @@ static const struct netcp2_ethtool_stat et_stats[] = {
787 {CPSW2_STATS7_INFO(ale_rate_limit_drop)}, 998 {CPSW2_STATS7_INFO(ale_rate_limit_drop)},
788 {CPSW2_STATS7_INFO(ale_vid_ingress_drop)}, 999 {CPSW2_STATS7_INFO(ale_vid_ingress_drop)},
789 {CPSW2_STATS7_INFO(ale_da_eq_sa_drop)}, 1000 {CPSW2_STATS7_INFO(ale_da_eq_sa_drop)},
790 {CPSW2_STATS7_INFO(ale_block_drop)}, 1001 {CPSW2_STATS7_INFO(ale_unknown_ucast)},
791 {CPSW2_STATS7_INFO(ale_secure_drop)}, 1002 {CPSW2_STATS7_INFO(ale_unknown_ucast_bytes)},
792 {CPSW2_STATS7_INFO(ale_auth_drop)}, 1003 {CPSW2_STATS7_INFO(ale_unknown_mcast)},
1004 {CPSW2_STATS7_INFO(ale_unknown_mcast_bytes)},
1005 {CPSW2_STATS7_INFO(ale_unknown_bcast)},
1006 {CPSW2_STATS7_INFO(ale_unknown_bcast_bytes)},
1007 {CPSW2_STATS7_INFO(ale_pol_match)},
1008 {CPSW2_STATS7_INFO(ale_pol_match_red)},
1009 {CPSW2_STATS7_INFO(ale_pol_match_yellow)},
1010 {CPSW2_STATS7_INFO(tx_mem_protect_err)},
1011 {CPSW2_STATS7_INFO(tx_pri0_drop)},
1012 {CPSW2_STATS7_INFO(tx_pri1_drop)},
1013 {CPSW2_STATS7_INFO(tx_pri2_drop)},
1014 {CPSW2_STATS7_INFO(tx_pri3_drop)},
1015 {CPSW2_STATS7_INFO(tx_pri4_drop)},
1016 {CPSW2_STATS7_INFO(tx_pri5_drop)},
1017 {CPSW2_STATS7_INFO(tx_pri6_drop)},
1018 {CPSW2_STATS7_INFO(tx_pri7_drop)},
1019 {CPSW2_STATS7_INFO(tx_pri0_drop_bcnt)},
1020 {CPSW2_STATS7_INFO(tx_pri1_drop_bcnt)},
1021 {CPSW2_STATS7_INFO(tx_pri2_drop_bcnt)},
1022 {CPSW2_STATS7_INFO(tx_pri3_drop_bcnt)},
1023 {CPSW2_STATS7_INFO(tx_pri4_drop_bcnt)},
1024 {CPSW2_STATS7_INFO(tx_pri5_drop_bcnt)},
1025 {CPSW2_STATS7_INFO(tx_pri6_drop_bcnt)},
1026 {CPSW2_STATS7_INFO(tx_pri7_drop_bcnt)},
793 /* CPSW module 8 */ 1027 /* CPSW module 8 */
794 {CPSW2_STATS8_INFO(rx_good_frames)}, 1028 {CPSW2_STATS8_INFO(rx_good_frames)},
795 {CPSW2_STATS8_INFO(rx_broadcast_frames)}, 1029 {CPSW2_STATS8_INFO(rx_broadcast_frames)},
@@ -830,9 +1064,32 @@ static const struct netcp2_ethtool_stat et_stats[] = {
830 {CPSW2_STATS8_INFO(ale_rate_limit_drop)}, 1064 {CPSW2_STATS8_INFO(ale_rate_limit_drop)},
831 {CPSW2_STATS8_INFO(ale_vid_ingress_drop)}, 1065 {CPSW2_STATS8_INFO(ale_vid_ingress_drop)},
832 {CPSW2_STATS8_INFO(ale_da_eq_sa_drop)}, 1066 {CPSW2_STATS8_INFO(ale_da_eq_sa_drop)},
833 {CPSW2_STATS8_INFO(ale_block_drop)}, 1067 {CPSW2_STATS8_INFO(ale_unknown_ucast)},
834 {CPSW2_STATS8_INFO(ale_secure_drop)}, 1068 {CPSW2_STATS8_INFO(ale_unknown_ucast_bytes)},
835 {CPSW2_STATS8_INFO(ale_auth_drop)}, 1069 {CPSW2_STATS8_INFO(ale_unknown_mcast)},
1070 {CPSW2_STATS8_INFO(ale_unknown_mcast_bytes)},
1071 {CPSW2_STATS8_INFO(ale_unknown_bcast)},
1072 {CPSW2_STATS8_INFO(ale_unknown_bcast_bytes)},
1073 {CPSW2_STATS8_INFO(ale_pol_match)},
1074 {CPSW2_STATS8_INFO(ale_pol_match_red)},
1075 {CPSW2_STATS8_INFO(ale_pol_match_yellow)},
1076 {CPSW2_STATS8_INFO(tx_mem_protect_err)},
1077 {CPSW2_STATS8_INFO(tx_pri0_drop)},
1078 {CPSW2_STATS8_INFO(tx_pri1_drop)},
1079 {CPSW2_STATS8_INFO(tx_pri2_drop)},
1080 {CPSW2_STATS8_INFO(tx_pri3_drop)},
1081 {CPSW2_STATS8_INFO(tx_pri4_drop)},
1082 {CPSW2_STATS8_INFO(tx_pri5_drop)},
1083 {CPSW2_STATS8_INFO(tx_pri6_drop)},
1084 {CPSW2_STATS8_INFO(tx_pri7_drop)},
1085 {CPSW2_STATS8_INFO(tx_pri0_drop_bcnt)},
1086 {CPSW2_STATS8_INFO(tx_pri1_drop_bcnt)},
1087 {CPSW2_STATS8_INFO(tx_pri2_drop_bcnt)},
1088 {CPSW2_STATS8_INFO(tx_pri3_drop_bcnt)},
1089 {CPSW2_STATS8_INFO(tx_pri4_drop_bcnt)},
1090 {CPSW2_STATS8_INFO(tx_pri5_drop_bcnt)},
1091 {CPSW2_STATS8_INFO(tx_pri6_drop_bcnt)},
1092 {CPSW2_STATS8_INFO(tx_pri7_drop_bcnt)},
836}; 1093};
837 1094
838#define ETHTOOL_PORT_STATS_NUM (ARRAY_SIZE(et_stats)/CPSW2_NUM_PORTS) 1095#define ETHTOOL_PORT_STATS_NUM (ARRAY_SIZE(et_stats)/CPSW2_NUM_PORTS)
@@ -895,8 +1152,11 @@ struct cpsw2_priv {
895 u32 num_serdes; 1152 u32 num_serdes;
896 u32 serdes_lanes; 1153 u32 serdes_lanes;
897 struct serdes serdes; 1154 struct serdes serdes;
1155 u32 opened;
898}; 1156};
899 1157
1158/* slave_port: 0-based (currently relevant only in multi_if mode)
1159 */
900struct cpsw2_intf { 1160struct cpsw2_intf {
901 struct net_device *ndev; 1161 struct net_device *ndev;
902 struct device *dev; 1162 struct device *dev;
@@ -912,7 +1172,7 @@ struct cpsw2_intf {
912 u32 multi_if; 1172 u32 multi_if;
913 struct list_head cpsw_intf_list; 1173 struct list_head cpsw_intf_list;
914 struct timer_list timer; 1174 struct timer_list timer;
915 u32 sgmii_link; 1175 u32 link_state;
916}; 1176};
917 1177
918struct cpsw2_attribute { 1178struct cpsw2_attribute {
@@ -2484,8 +2744,7 @@ static void _cpsw2_adjust_link(struct cpsw2_slave *slave, bool *link)
2484 2744
2485 if (phy->link) { 2745 if (phy->link) {
2486 mac_control = slave->mac_control; 2746 mac_control = slave->mac_control;
2487 mac_control |= MACSL_ENABLE | MACSL_RX_ENABLE_EXT_CTL | 2747 mac_control |= MACSL_DEFAULT_CONFIG;
2488 MACSL_RX_ENABLE_CSF;
2489 /* enable forwarding */ 2748 /* enable forwarding */
2490 cpsw_ale_control_set(slave->ale, slave_port, 2749 cpsw_ale_control_set(slave->ale, slave_port,
2491 ALE_PORT_STATE, ALE_PORT_STATE_FORWARD); 2750 ALE_PORT_STATE, ALE_PORT_STATE_FORWARD);
@@ -2520,9 +2779,9 @@ static void cpsw2_adjust_link(struct net_device *n_dev, void *context)
2520 _cpsw2_adjust_link(slave, &link); 2779 _cpsw2_adjust_link(slave, &link);
2521 2780
2522 if (link) 2781 if (link)
2523 netcp->link_state |= BIT(slave->slave_num); 2782 netcp->phy_link_state_mask |= BIT(slave->slave_num);
2524 else 2783 else
2525 netcp->link_state &= ~BIT(slave->slave_num); 2784 netcp->phy_link_state_mask &= ~BIT(slave->slave_num);
2526} 2785}
2527 2786
2528/* 2787/*
@@ -2555,10 +2814,10 @@ static void cpsw2_port_config(struct cpsw2_slave *slave, int max_rx_len)
2555 if (max_rx_len > MAX_SIZE_STREAM_BUFFER) 2814 if (max_rx_len > MAX_SIZE_STREAM_BUFFER)
2556 max_rx_len = MAX_SIZE_STREAM_BUFFER; 2815 max_rx_len = MAX_SIZE_STREAM_BUFFER;
2557 2816
2558 writel(max_rx_len, &slave->regs->rx_maxlen); 2817 slave->mac_control = MACSL_DEFAULT_CONFIG;
2559 2818
2560 writel(MACSL_ENABLE | MACSL_RX_ENABLE_EXT_CTL | MACSL_RX_ENABLE_CSF, 2819 writel(max_rx_len, &slave->regs->rx_maxlen);
2561 &slave->regs->mac_control); 2820 writel(slave->mac_control, &slave->regs->mac_control);
2562} 2821}
2563 2822
2564static void cpsw2_slave_stop(struct cpsw2_slave *slave, 2823static void cpsw2_slave_stop(struct cpsw2_slave *slave,
@@ -2588,12 +2847,14 @@ static void cpsw2_slave_link(struct cpsw2_slave *slave,
2588 struct cpsw2_intf *cpsw_intf) 2847 struct cpsw2_intf *cpsw_intf)
2589{ 2848{
2590 struct netcp_priv *netcp = netdev_priv(cpsw_intf->ndev); 2849 struct netcp_priv *netcp = netdev_priv(cpsw_intf->ndev);
2850 int sn = slave->slave_num;
2591 2851
2592 if (slave->link_interface == SGMII_LINK_MAC_PHY) { 2852 if (IS_SGMII_MAC_PHY(slave->link_interface)) {
2593 if (netcp->link_state) 2853 /* check only the bit in phy_link_state_mask
2594 cpsw_intf->sgmii_link |= BIT(slave->slave_num); 2854 * that corresponds to the slave
2595 else 2855 */
2596 cpsw_intf->sgmii_link &= ~BIT(slave->slave_num); 2856 if (!(netcp->phy_link_state_mask & BIT(sn)))
2857 cpsw_intf->link_state &= ~BIT(sn);
2597 } 2858 }
2598} 2859}
2599 2860
@@ -2617,9 +2878,6 @@ static void cpsw2_slave_open(struct cpsw2_slave *slave,
2617 2878
2618 cpsw2_set_slave_mac(slave, cpsw_intf); 2879 cpsw2_set_slave_mac(slave, cpsw_intf);
2619 2880
2620 slave->mac_control = MACSL_ENABLE | MACSL_RX_ENABLE_EXT_CTL |
2621 MACSL_RX_ENABLE_CSF;
2622
2623 /* this slave port here is 1 based */ 2881 /* this slave port here is 1 based */
2624 slave_port = cpsw2_get_slave_port(cpsw_dev, slave->slave_num); 2882 slave_port = cpsw2_get_slave_port(cpsw_dev, slave->slave_num);
2625 2883
@@ -2634,7 +2892,7 @@ static void cpsw2_slave_open(struct cpsw2_slave *slave,
2634 cpsw_ale_add_mcast(cpsw_dev->ale, cpsw_intf->ndev->broadcast, 2892 cpsw_ale_add_mcast(cpsw_dev->ale, cpsw_intf->ndev->broadcast,
2635 1 << slave_port, 0, 0, ALE_MCAST_FWD_2); 2893 1 << slave_port, 0, 0, ALE_MCAST_FWD_2);
2636 2894
2637 if (slave->link_interface == SGMII_LINK_MAC_PHY) { 2895 if (IS_SGMII_MAC_PHY(slave->link_interface)) {
2638 slave->phy = of_phy_connect(cpsw_intf->ndev, 2896 slave->phy = of_phy_connect(cpsw_intf->ndev,
2639 cpsw_intf->phy_node, 2897 cpsw_intf->phy_node,
2640 &cpsw2_adjust_link, 0, 2898 &cpsw2_adjust_link, 0,
@@ -2756,6 +3014,9 @@ static int cpsw2_add_addr(void *intf_priv, struct netcp_addr *naddr)
2756 struct cpsw2_intf *cpsw_intf = intf_priv; 3014 struct cpsw2_intf *cpsw_intf = intf_priv;
2757 struct cpsw2_priv *cpsw_dev = cpsw_intf->cpsw_priv; 3015 struct cpsw2_priv *cpsw_dev = cpsw_intf->cpsw_priv;
2758 3016
3017 if (!cpsw_dev->opened)
3018 return -ENXIO;
3019
2759 dev_dbg(cpsw_dev->dev, "ethss adding address %pM, type %d\n", 3020 dev_dbg(cpsw_dev->dev, "ethss adding address %pM, type %d\n",
2760 naddr->addr, naddr->type); 3021 naddr->addr, naddr->type);
2761 3022
@@ -2782,6 +3043,9 @@ static int cpsw2_del_addr(void *intf_priv, struct netcp_addr *naddr)
2782 struct cpsw2_intf *cpsw_intf = intf_priv; 3043 struct cpsw2_intf *cpsw_intf = intf_priv;
2783 struct cpsw2_priv *cpsw_dev = cpsw_intf->cpsw_priv; 3044 struct cpsw2_priv *cpsw_dev = cpsw_intf->cpsw_priv;
2784 3045
3046 if (!cpsw_dev->opened)
3047 return -ENXIO;
3048
2785 dev_dbg(cpsw_dev->dev, "ethss deleting address %pM, type %d\n", 3049 dev_dbg(cpsw_dev->dev, "ethss deleting address %pM, type %d\n",
2786 naddr->addr, naddr->type); 3050 naddr->addr, naddr->type);
2787 3051
@@ -3002,10 +3266,10 @@ static void cpsw2_timer(unsigned long arg)
3002 struct cpsw2_priv *cpsw_dev = cpsw_intf->cpsw_priv; 3266 struct cpsw2_priv *cpsw_dev = cpsw_intf->cpsw_priv;
3003 u32 sp = cpsw_intf->slave_port; 3267 u32 sp = cpsw_intf->slave_port;
3004 u32 ns = cpsw_intf->num_slaves; 3268 u32 ns = cpsw_intf->num_slaves;
3005 u32 sgmii_link; 3269 u32 link_state;
3006 3270
3007 if (cpsw_dev->multi_if) 3271 if (cpsw_dev->multi_if)
3008 sgmii_link = keystone_sgmii_get_port_link(SGMII2_BASE(sp), sp); 3272 link_state = keystone_sgmii_get_port_link(SGMII2_BASE(sp), sp);
3009 else { 3273 else {
3010 /* Single interface mode. Link is up if any one slave 3274 /* Single interface mode. Link is up if any one slave
3011 * port is up. It assumes slave port always starts from 3275 * port is up. It assumes slave port always starts from
@@ -3013,27 +3277,35 @@ static void cpsw2_timer(unsigned long arg)
3013 */ 3277 */
3014 3278
3015 /* slave port (port > 2) status */ 3279 /* slave port (port > 2) status */
3016 sgmii_link = keystone_sgmii_link_status(SGMII2_BASE(2), 3280 link_state = keystone_sgmii_link_status(SGMII2_BASE(2),
3017 max_t(u32, ns, 2) - 2); 3281 max_t(u32, ns, 2) - 2);
3018 3282
3019 sgmii_link <<= 2; 3283 link_state <<= 2;
3020 3284
3021 /* slave port 0, 1 status */ 3285 /* slave port 0, 1 status */
3022 sgmii_link |= keystone_sgmii_link_status(SGMII2_BASE(0), 3286 link_state |= keystone_sgmii_link_status(SGMII2_BASE(0),
3023 min_t(u32, ns, 2)); 3287 min_t(u32, ns, 2));
3024 } 3288 }
3025 cpsw_intf->sgmii_link = sgmii_link; 3289 cpsw_intf->link_state = link_state;
3026 3290
3291 /* if MAC-to-PHY, check phy link status also
3292 * to conclude the intf link's status
3293 */
3027 for_each_slave(cpsw_intf, cpsw2_slave_link, cpsw_intf); 3294 for_each_slave(cpsw_intf, cpsw2_slave_link, cpsw_intf);
3028 3295
3029 /* FIXME: Don't aggregate link statuses in multi-interface case */ 3296 /* Is this the right logic?
3030 if (cpsw_intf->sgmii_link) { 3297 * multi_if & MAC_PHY: phy state machine already reported carrier
3031 /* link ON */ 3298 * multi_if & !MAC_PHY: report carrier
3032 if (!netif_carrier_ok(cpsw_intf->ndev)) 3299 * !multi_if: any one slave up means intf is up, reporting carrier
3300 * here corrects what phy state machine (if it exists)
3301 * might have reported.
3302 */
3303 if (!cpsw_dev->multi_if ||
3304 (cpsw_dev->multi_if &&
3305 !IS_SGMII_MAC_PHY(cpsw_intf->slaves->link_interface))) {
3306 if (cpsw_intf->link_state)
3033 netif_carrier_on(cpsw_intf->ndev); 3307 netif_carrier_on(cpsw_intf->ndev);
3034 } else { 3308 else
3035 /* link OFF */
3036 if (netif_carrier_ok(cpsw_intf->ndev))
3037 netif_carrier_off(cpsw_intf->ndev); 3309 netif_carrier_off(cpsw_intf->ndev);
3038 } 3310 }
3039 3311
@@ -3439,6 +3711,7 @@ static int cpsw2_open(void *intf_priv, struct net_device *ndev)
3439 PSTREAM_ROUTE_GLOBAL_DMA); 3711 PSTREAM_ROUTE_GLOBAL_DMA);
3440 3712
3441 cpsw2_register_cpts(cpsw_dev); 3713 cpsw2_register_cpts(cpsw_dev);
3714 cpsw_dev->opened = 1;
3442 return 0; 3715 return 0;
3443 3716
3444ale_fail: 3717ale_fail:
@@ -3478,6 +3751,7 @@ static int cpsw2_close(void *intf_priv, struct net_device *ndev)
3478 clk_put(cpsw_dev->cpgmac); 3751 clk_put(cpsw_dev->cpgmac);
3479 3752
3480 cpsw2_unregister_cpts(cpsw_dev); 3753 cpsw2_unregister_cpts(cpsw_dev);
3754 cpsw_dev->opened = 0;
3481 return 0; 3755 return 0;
3482} 3756}
3483 3757