2 * Keystone GBE and XGBE subsystem code
4 * Copyright (C) 2014 Texas Instruments Incorporated
5 * Authors: Sandeep Nair <sandeep_n@ti.com>
6 * Sandeep Paulraj <s-paulraj@ti.com>
7 * Cyril Chemparathy <cyril@ti.com>
8 * Santosh Shilimkar <santosh.shilimkar@ti.com>
9 * Wingman Kwok <w-kwok2@ti.com>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation version 2.
15 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
16 * kind, whether express or implied; without even the implied warranty
17 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
22 #include <linux/module.h>
23 #include <linux/of_mdio.h>
24 #include <linux/of_address.h>
25 #include <linux/if_vlan.h>
26 #include <linux/ethtool.h>
31 #define NETCP_DRIVER_NAME "TI KeyStone Ethernet Driver"
32 #define NETCP_DRIVER_VERSION "v1.0"
34 #define GBE_IDENT(reg) ((reg >> 16) & 0xffff)
35 #define GBE_MAJOR_VERSION(reg) (reg >> 8 & 0x7)
36 #define GBE_MINOR_VERSION(reg) (reg & 0xff)
37 #define GBE_RTL_VERSION(reg) ((reg >> 11) & 0x1f)
39 /* 1G Ethernet SS defines */
40 #define GBE_MODULE_NAME "netcp-gbe"
41 #define GBE_SS_VERSION_14 0x4ed21104
43 #define GBE_SS_REG_INDEX 0
44 #define GBE_SGMII34_REG_INDEX 1
45 #define GBE_SM_REG_INDEX 2
46 /* offset relative to base of GBE_SS_REG_INDEX */
47 #define GBE13_SGMII_MODULE_OFFSET 0x100
48 /* offset relative to base of GBE_SM_REG_INDEX */
49 #define GBE13_HOST_PORT_OFFSET 0x34
50 #define GBE13_SLAVE_PORT_OFFSET 0x60
51 #define GBE13_EMAC_OFFSET 0x100
52 #define GBE13_SLAVE_PORT2_OFFSET 0x200
53 #define GBE13_HW_STATS_OFFSET 0x300
54 #define GBE13_ALE_OFFSET 0x600
55 #define GBE13_HOST_PORT_NUM 0
56 #define GBE13_NUM_ALE_ENTRIES 1024
58 /* 1G Ethernet NU SS defines */
59 #define GBENU_MODULE_NAME "netcp-gbenu"
60 #define GBE_SS_ID_NU 0x4ee6
61 #define GBE_SS_ID_2U 0x4ee8
63 #define IS_SS_ID_MU(d) \
64 ((GBE_IDENT((d)->ss_version) == GBE_SS_ID_NU) || \
65 (GBE_IDENT((d)->ss_version) == GBE_SS_ID_2U))
67 #define IS_SS_ID_NU(d) \
68 (GBE_IDENT((d)->ss_version) == GBE_SS_ID_NU)
70 #define GBENU_SS_REG_INDEX 0
71 #define GBENU_SM_REG_INDEX 1
72 #define GBENU_SGMII_MODULE_OFFSET 0x100
73 #define GBENU_HOST_PORT_OFFSET 0x1000
74 #define GBENU_SLAVE_PORT_OFFSET 0x2000
75 #define GBENU_EMAC_OFFSET 0x2330
76 #define GBENU_HW_STATS_OFFSET 0x1a000
77 #define GBENU_ALE_OFFSET 0x1e000
78 #define GBENU_HOST_PORT_NUM 0
79 #define GBENU_NUM_ALE_ENTRIES 1024
81 /* 10G Ethernet SS defines */
82 #define XGBE_MODULE_NAME "netcp-xgbe"
83 #define XGBE_SS_VERSION_10 0x4ee42100
85 #define XGBE_SS_REG_INDEX 0
86 #define XGBE_SM_REG_INDEX 1
87 #define XGBE_SERDES_REG_INDEX 2
89 /* offset relative to base of XGBE_SS_REG_INDEX */
90 #define XGBE10_SGMII_MODULE_OFFSET 0x100
91 /* offset relative to base of XGBE_SM_REG_INDEX */
92 #define XGBE10_HOST_PORT_OFFSET 0x34
93 #define XGBE10_SLAVE_PORT_OFFSET 0x64
94 #define XGBE10_EMAC_OFFSET 0x400
95 #define XGBE10_ALE_OFFSET 0x700
96 #define XGBE10_HW_STATS_OFFSET 0x800
97 #define XGBE10_HOST_PORT_NUM 0
98 #define XGBE10_NUM_ALE_ENTRIES 1024
100 #define GBE_TIMER_INTERVAL (HZ / 2)
102 /* Soft reset register values */
103 #define SOFT_RESET_MASK BIT(0)
104 #define SOFT_RESET BIT(0)
105 #define DEVICE_EMACSL_RESET_POLL_COUNT 100
106 #define GMACSL_RET_WARN_RESET_INCOMPLETE -2
108 #define MACSL_RX_ENABLE_CSF BIT(23)
109 #define MACSL_ENABLE_EXT_CTL BIT(18)
110 #define MACSL_XGMII_ENABLE BIT(13)
111 #define MACSL_XGIG_MODE BIT(8)
112 #define MACSL_GIG_MODE BIT(7)
113 #define MACSL_GMII_ENABLE BIT(5)
114 #define MACSL_FULLDUPLEX BIT(0)
116 #define GBE_CTL_P0_ENABLE BIT(2)
117 #define GBE13_REG_VAL_STAT_ENABLE_ALL 0xff
118 #define XGBE_REG_VAL_STAT_ENABLE_ALL 0xf
119 #define GBE_STATS_CD_SEL BIT(28)
121 #define GBE_PORT_MASK(x) (BIT(x) - 1)
122 #define GBE_MASK_NO_PORTS 0
124 #define GBE_DEF_1G_MAC_CONTROL \
125 (MACSL_GIG_MODE | MACSL_GMII_ENABLE | \
126 MACSL_ENABLE_EXT_CTL | MACSL_RX_ENABLE_CSF)
128 #define GBE_DEF_10G_MAC_CONTROL \
129 (MACSL_XGIG_MODE | MACSL_XGMII_ENABLE | \
130 MACSL_ENABLE_EXT_CTL | MACSL_RX_ENABLE_CSF)
132 #define GBE_STATSA_MODULE 0
133 #define GBE_STATSB_MODULE 1
134 #define GBE_STATSC_MODULE 2
135 #define GBE_STATSD_MODULE 3
137 #define GBENU_STATS0_MODULE 0
138 #define GBENU_STATS1_MODULE 1
139 #define GBENU_STATS2_MODULE 2
140 #define GBENU_STATS3_MODULE 3
141 #define GBENU_STATS4_MODULE 4
142 #define GBENU_STATS5_MODULE 5
143 #define GBENU_STATS6_MODULE 6
144 #define GBENU_STATS7_MODULE 7
145 #define GBENU_STATS8_MODULE 8
147 #define XGBE_STATS0_MODULE 0
148 #define XGBE_STATS1_MODULE 1
149 #define XGBE_STATS2_MODULE 2
151 /* s: 0-based slave_port */
152 #define SGMII_BASE(s) \
153 (((s) < 2) ? gbe_dev->sgmii_port_regs : gbe_dev->sgmii_port34_regs)
155 #define GBE_TX_QUEUE 648
156 #define GBE_TXHOOK_ORDER 0
157 #define GBE_DEFAULT_ALE_AGEOUT 30
158 #define SLAVE_LINK_IS_XGMII(s) ((s)->link_interface >= XGMII_LINK_MAC_PHY)
159 #define NETCP_LINK_STATE_INVALID -1
161 #define GBE_SET_REG_OFS(p, rb, rn) p->rb##_ofs.rn = \
162 offsetof(struct gbe##_##rb, rn)
163 #define GBENU_SET_REG_OFS(p, rb, rn) p->rb##_ofs.rn = \
164 offsetof(struct gbenu##_##rb, rn)
165 #define XGBE_SET_REG_OFS(p, rb, rn) p->rb##_ofs.rn = \
166 offsetof(struct xgbe##_##rb, rn)
167 #define GBE_REG_ADDR(p, rb, rn) (p->rb + p->rb##_ofs.rn)
169 #define HOST_TX_PRI_MAP_DEFAULT 0x00000000
171 struct xgbe_ss_regs
{
178 struct xgbe_switch_regs
{
192 struct xgbe_port_regs
{
206 struct xgbe_host_port_regs
{
215 struct xgbe_emac_regs
{
230 struct xgbe_host_hw_stats
{
232 u32 rx_broadcast_frames
;
233 u32 rx_multicast_frames
;
235 u32 rx_oversized_frames
;
237 u32 rx_undersized_frames
;
243 u32 tx_broadcast_frames
;
244 u32 tx_multicast_frames
;
247 u32 tx_64byte_frames
;
248 u32 tx_65_to_127byte_frames
;
249 u32 tx_128_to_255byte_frames
;
250 u32 tx_256_to_511byte_frames
;
251 u32 tx_512_to_1023byte_frames
;
252 u32 tx_1024byte_frames
;
259 struct xgbe_hw_stats
{
261 u32 rx_broadcast_frames
;
262 u32 rx_multicast_frames
;
265 u32 rx_align_code_errors
;
266 u32 rx_oversized_frames
;
267 u32 rx_jabber_frames
;
268 u32 rx_undersized_frames
;
274 u32 tx_broadcast_frames
;
275 u32 tx_multicast_frames
;
277 u32 tx_deferred_frames
;
278 u32 tx_collision_frames
;
279 u32 tx_single_coll_frames
;
280 u32 tx_mult_coll_frames
;
281 u32 tx_excessive_collisions
;
282 u32 tx_late_collisions
;
284 u32 tx_carrier_sense_errors
;
286 u32 tx_64byte_frames
;
287 u32 tx_65_to_127byte_frames
;
288 u32 tx_128_to_255byte_frames
;
289 u32 tx_256_to_511byte_frames
;
290 u32 tx_512_to_1023byte_frames
;
291 u32 tx_1024byte_frames
;
298 struct gbenu_ss_regs
{
300 u32 synce_count
; /* NU */
301 u32 synce_mux
; /* NU */
302 u32 control
; /* 2U */
303 u32 __rsvd_0
[2]; /* 2U */
304 u32 rgmii_status
; /* 2U */
305 u32 ss_status
; /* 2U */
308 struct gbenu_switch_regs
{
316 u32 thru_rate
; /* NU */
317 u32 gap_thresh
; /* NU */
318 u32 tx_start_wds
; /* NU */
319 u32 eee_prescale
; /* 2U */
320 u32 tx_g_oflow_thresh_set
; /* NU */
321 u32 tx_g_oflow_thresh_clr
; /* NU */
322 u32 tx_g_buf_thresh_set_l
; /* NU */
323 u32 tx_g_buf_thresh_set_h
; /* NU */
324 u32 tx_g_buf_thresh_clr_l
; /* NU */
325 u32 tx_g_buf_thresh_clr_h
; /* NU */
328 struct gbenu_port_regs
{
331 u32 max_blks
; /* 2U */
335 u32 tx_pri_map
; /* NU */
336 u32 pri_ctl
; /* 2U */
339 u32 tx_blks_pri
; /* NU */
341 u32 idle2lpi
; /* 2U */
342 u32 lpi2idle
; /* 2U */
343 u32 eee_status
; /* 2U */
345 u32 __rsvd_3
[176]; /* NU: more to add */
356 struct gbenu_host_port_regs
{
359 u32 flow_id_offset
; /* 2U */
363 u32 tx_pri_map
; /* NU */
367 u32 tx_blks_pri
; /* NU */
369 u32 idle2lpi
; /* 2U */
370 u32 lpi2wake
; /* 2U */
371 u32 eee_status
; /* 2U */
373 u32 __rsvd_4
[184]; /* NU */
374 u32 host_blks_pri
; /* NU */
377 struct gbenu_emac_regs
{
383 u32 __rsvd_0
[11]; /* NU */
385 u32 __rsvd_1
[11]; /* NU */
390 /* Some hw stat regs are applicable to slave port only.
391 * This is handled by gbenu_et_stats struct. Also some
392 * are for SS version NU and some are for 2U.
394 struct gbenu_hw_stats
{
396 u32 rx_broadcast_frames
;
397 u32 rx_multicast_frames
;
398 u32 rx_pause_frames
; /* slave */
400 u32 rx_align_code_errors
; /* slave */
401 u32 rx_oversized_frames
;
402 u32 rx_jabber_frames
; /* slave */
403 u32 rx_undersized_frames
;
404 u32 rx_fragments
; /* slave */
406 u32 ale_overrun_drop
;
409 u32 tx_broadcast_frames
;
410 u32 tx_multicast_frames
;
411 u32 tx_pause_frames
; /* slave */
412 u32 tx_deferred_frames
; /* slave */
413 u32 tx_collision_frames
; /* slave */
414 u32 tx_single_coll_frames
; /* slave */
415 u32 tx_mult_coll_frames
; /* slave */
416 u32 tx_excessive_collisions
; /* slave */
417 u32 tx_late_collisions
; /* slave */
418 u32 rx_ipg_error
; /* slave 10G only */
419 u32 tx_carrier_sense_errors
; /* slave */
422 u32 tx_65_to_127B_frames
;
423 u32 tx_128_to_255B_frames
;
424 u32 tx_256_to_511B_frames
;
425 u32 tx_512_to_1023B_frames
;
428 u32 rx_bottom_fifo_drop
;
429 u32 rx_port_mask_drop
;
430 u32 rx_top_fifo_drop
;
431 u32 ale_rate_limit_drop
;
432 u32 ale_vid_ingress_drop
;
433 u32 ale_da_eq_sa_drop
;
435 u32 ale_unknown_ucast
;
436 u32 ale_unknown_ucast_bytes
;
437 u32 ale_unknown_mcast
;
438 u32 ale_unknown_mcast_bytes
;
439 u32 ale_unknown_bcast
;
440 u32 ale_unknown_bcast_bytes
;
442 u32 ale_pol_match_red
; /* NU */
443 u32 ale_pol_match_yellow
; /* NU */
445 u32 tx_mem_protect_err
;
446 /* following NU only */
471 u32 tx_pri0_drop_bcnt
;
472 u32 tx_pri1_drop_bcnt
;
473 u32 tx_pri2_drop_bcnt
;
474 u32 tx_pri3_drop_bcnt
;
475 u32 tx_pri4_drop_bcnt
;
476 u32 tx_pri5_drop_bcnt
;
477 u32 tx_pri6_drop_bcnt
;
478 u32 tx_pri7_drop_bcnt
;
481 #define GBENU_HW_STATS_REG_MAP_SZ 0x200
489 struct gbe_ss_regs_ofs
{
494 struct gbe_switch_regs
{
507 struct gbe_switch_regs_ofs
{
517 struct gbe_port_regs
{
531 struct gbe_port_regs_ofs
{
541 u16 rx_maxlen
; /* 2U, NU */
544 struct gbe_host_port_regs
{
551 struct gbe_host_port_regs_ofs
{
557 struct gbe_emac_regs
{
571 struct gbe_emac_regs_ofs
{
577 struct gbe_hw_stats
{
579 u32 rx_broadcast_frames
;
580 u32 rx_multicast_frames
;
583 u32 rx_align_code_errors
;
584 u32 rx_oversized_frames
;
585 u32 rx_jabber_frames
;
586 u32 rx_undersized_frames
;
591 u32 tx_broadcast_frames
;
592 u32 tx_multicast_frames
;
594 u32 tx_deferred_frames
;
595 u32 tx_collision_frames
;
596 u32 tx_single_coll_frames
;
597 u32 tx_mult_coll_frames
;
598 u32 tx_excessive_collisions
;
599 u32 tx_late_collisions
;
601 u32 tx_carrier_sense_errors
;
603 u32 tx_64byte_frames
;
604 u32 tx_65_to_127byte_frames
;
605 u32 tx_128_to_255byte_frames
;
606 u32 tx_256_to_511byte_frames
;
607 u32 tx_512_to_1023byte_frames
;
608 u32 tx_1024byte_frames
;
615 #define GBE_MAX_HW_STAT_MODS 9
616 #define GBE_HW_STATS_REG_MAP_SZ 0x100
619 void __iomem
*port_regs
;
620 void __iomem
*emac_regs
;
621 struct gbe_port_regs_ofs port_regs_ofs
;
622 struct gbe_emac_regs_ofs emac_regs_ofs
;
623 int slave_num
; /* 0 based logical number */
624 int port_num
; /* actual port number */
627 struct phy_device
*phy
;
631 struct device_node
*phy_node
;
632 struct list_head slave_list
;
637 struct netcp_device
*netcp_device
;
638 struct timer_list timer
;
644 u8 max_num_ports
; /* max_num_slaves + 1 */
646 struct netcp_tx_pipe tx_pipe
;
653 void __iomem
*ss_regs
;
654 void __iomem
*switch_regs
;
655 void __iomem
*host_port_regs
;
656 void __iomem
*ale_reg
;
657 void __iomem
*sgmii_port_regs
;
658 void __iomem
*sgmii_port34_regs
;
659 void __iomem
*xgbe_serdes_regs
;
660 void __iomem
*hw_stats_regs
[GBE_MAX_HW_STAT_MODS
];
662 struct gbe_ss_regs_ofs ss_regs_ofs
;
663 struct gbe_switch_regs_ofs switch_regs_ofs
;
664 struct gbe_host_port_regs_ofs host_port_regs_ofs
;
666 struct cpsw_ale
*ale
;
667 unsigned int tx_queue_id
;
668 const char *dma_chan_name
;
670 struct list_head gbe_intf_head
;
671 struct list_head secondary_slaves
;
672 struct net_device
*dummy_ndev
;
676 const struct netcp_ethtool_stat
*et_stats
;
678 /* Lock for updating the hwstats */
679 spinlock_t hw_stats_lock
;
683 struct net_device
*ndev
;
685 struct gbe_priv
*gbe_dev
;
686 struct netcp_tx_pipe tx_pipe
;
687 struct gbe_slave
*slave
;
688 struct list_head gbe_intf_list
;
689 unsigned long active_vlans
[BITS_TO_LONGS(VLAN_N_VID
)];
692 static struct netcp_module gbe_module
;
693 static struct netcp_module xgbe_module
;
695 /* Statistic management */
696 struct netcp_ethtool_stat
{
697 char desc
[ETH_GSTRING_LEN
];
703 #define GBE_STATSA_INFO(field) \
705 "GBE_A:"#field, GBE_STATSA_MODULE, \
706 FIELD_SIZEOF(struct gbe_hw_stats, field), \
707 offsetof(struct gbe_hw_stats, field) \
710 #define GBE_STATSB_INFO(field) \
712 "GBE_B:"#field, GBE_STATSB_MODULE, \
713 FIELD_SIZEOF(struct gbe_hw_stats, field), \
714 offsetof(struct gbe_hw_stats, field) \
717 #define GBE_STATSC_INFO(field) \
719 "GBE_C:"#field, GBE_STATSC_MODULE, \
720 FIELD_SIZEOF(struct gbe_hw_stats, field), \
721 offsetof(struct gbe_hw_stats, field) \
724 #define GBE_STATSD_INFO(field) \
726 "GBE_D:"#field, GBE_STATSD_MODULE, \
727 FIELD_SIZEOF(struct gbe_hw_stats, field), \
728 offsetof(struct gbe_hw_stats, field) \
731 static const struct netcp_ethtool_stat gbe13_et_stats
[] = {
733 GBE_STATSA_INFO(rx_good_frames
),
734 GBE_STATSA_INFO(rx_broadcast_frames
),
735 GBE_STATSA_INFO(rx_multicast_frames
),
736 GBE_STATSA_INFO(rx_pause_frames
),
737 GBE_STATSA_INFO(rx_crc_errors
),
738 GBE_STATSA_INFO(rx_align_code_errors
),
739 GBE_STATSA_INFO(rx_oversized_frames
),
740 GBE_STATSA_INFO(rx_jabber_frames
),
741 GBE_STATSA_INFO(rx_undersized_frames
),
742 GBE_STATSA_INFO(rx_fragments
),
743 GBE_STATSA_INFO(rx_bytes
),
744 GBE_STATSA_INFO(tx_good_frames
),
745 GBE_STATSA_INFO(tx_broadcast_frames
),
746 GBE_STATSA_INFO(tx_multicast_frames
),
747 GBE_STATSA_INFO(tx_pause_frames
),
748 GBE_STATSA_INFO(tx_deferred_frames
),
749 GBE_STATSA_INFO(tx_collision_frames
),
750 GBE_STATSA_INFO(tx_single_coll_frames
),
751 GBE_STATSA_INFO(tx_mult_coll_frames
),
752 GBE_STATSA_INFO(tx_excessive_collisions
),
753 GBE_STATSA_INFO(tx_late_collisions
),
754 GBE_STATSA_INFO(tx_underrun
),
755 GBE_STATSA_INFO(tx_carrier_sense_errors
),
756 GBE_STATSA_INFO(tx_bytes
),
757 GBE_STATSA_INFO(tx_64byte_frames
),
758 GBE_STATSA_INFO(tx_65_to_127byte_frames
),
759 GBE_STATSA_INFO(tx_128_to_255byte_frames
),
760 GBE_STATSA_INFO(tx_256_to_511byte_frames
),
761 GBE_STATSA_INFO(tx_512_to_1023byte_frames
),
762 GBE_STATSA_INFO(tx_1024byte_frames
),
763 GBE_STATSA_INFO(net_bytes
),
764 GBE_STATSA_INFO(rx_sof_overruns
),
765 GBE_STATSA_INFO(rx_mof_overruns
),
766 GBE_STATSA_INFO(rx_dma_overruns
),
768 GBE_STATSB_INFO(rx_good_frames
),
769 GBE_STATSB_INFO(rx_broadcast_frames
),
770 GBE_STATSB_INFO(rx_multicast_frames
),
771 GBE_STATSB_INFO(rx_pause_frames
),
772 GBE_STATSB_INFO(rx_crc_errors
),
773 GBE_STATSB_INFO(rx_align_code_errors
),
774 GBE_STATSB_INFO(rx_oversized_frames
),
775 GBE_STATSB_INFO(rx_jabber_frames
),
776 GBE_STATSB_INFO(rx_undersized_frames
),
777 GBE_STATSB_INFO(rx_fragments
),
778 GBE_STATSB_INFO(rx_bytes
),
779 GBE_STATSB_INFO(tx_good_frames
),
780 GBE_STATSB_INFO(tx_broadcast_frames
),
781 GBE_STATSB_INFO(tx_multicast_frames
),
782 GBE_STATSB_INFO(tx_pause_frames
),
783 GBE_STATSB_INFO(tx_deferred_frames
),
784 GBE_STATSB_INFO(tx_collision_frames
),
785 GBE_STATSB_INFO(tx_single_coll_frames
),
786 GBE_STATSB_INFO(tx_mult_coll_frames
),
787 GBE_STATSB_INFO(tx_excessive_collisions
),
788 GBE_STATSB_INFO(tx_late_collisions
),
789 GBE_STATSB_INFO(tx_underrun
),
790 GBE_STATSB_INFO(tx_carrier_sense_errors
),
791 GBE_STATSB_INFO(tx_bytes
),
792 GBE_STATSB_INFO(tx_64byte_frames
),
793 GBE_STATSB_INFO(tx_65_to_127byte_frames
),
794 GBE_STATSB_INFO(tx_128_to_255byte_frames
),
795 GBE_STATSB_INFO(tx_256_to_511byte_frames
),
796 GBE_STATSB_INFO(tx_512_to_1023byte_frames
),
797 GBE_STATSB_INFO(tx_1024byte_frames
),
798 GBE_STATSB_INFO(net_bytes
),
799 GBE_STATSB_INFO(rx_sof_overruns
),
800 GBE_STATSB_INFO(rx_mof_overruns
),
801 GBE_STATSB_INFO(rx_dma_overruns
),
803 GBE_STATSC_INFO(rx_good_frames
),
804 GBE_STATSC_INFO(rx_broadcast_frames
),
805 GBE_STATSC_INFO(rx_multicast_frames
),
806 GBE_STATSC_INFO(rx_pause_frames
),
807 GBE_STATSC_INFO(rx_crc_errors
),
808 GBE_STATSC_INFO(rx_align_code_errors
),
809 GBE_STATSC_INFO(rx_oversized_frames
),
810 GBE_STATSC_INFO(rx_jabber_frames
),
811 GBE_STATSC_INFO(rx_undersized_frames
),
812 GBE_STATSC_INFO(rx_fragments
),
813 GBE_STATSC_INFO(rx_bytes
),
814 GBE_STATSC_INFO(tx_good_frames
),
815 GBE_STATSC_INFO(tx_broadcast_frames
),
816 GBE_STATSC_INFO(tx_multicast_frames
),
817 GBE_STATSC_INFO(tx_pause_frames
),
818 GBE_STATSC_INFO(tx_deferred_frames
),
819 GBE_STATSC_INFO(tx_collision_frames
),
820 GBE_STATSC_INFO(tx_single_coll_frames
),
821 GBE_STATSC_INFO(tx_mult_coll_frames
),
822 GBE_STATSC_INFO(tx_excessive_collisions
),
823 GBE_STATSC_INFO(tx_late_collisions
),
824 GBE_STATSC_INFO(tx_underrun
),
825 GBE_STATSC_INFO(tx_carrier_sense_errors
),
826 GBE_STATSC_INFO(tx_bytes
),
827 GBE_STATSC_INFO(tx_64byte_frames
),
828 GBE_STATSC_INFO(tx_65_to_127byte_frames
),
829 GBE_STATSC_INFO(tx_128_to_255byte_frames
),
830 GBE_STATSC_INFO(tx_256_to_511byte_frames
),
831 GBE_STATSC_INFO(tx_512_to_1023byte_frames
),
832 GBE_STATSC_INFO(tx_1024byte_frames
),
833 GBE_STATSC_INFO(net_bytes
),
834 GBE_STATSC_INFO(rx_sof_overruns
),
835 GBE_STATSC_INFO(rx_mof_overruns
),
836 GBE_STATSC_INFO(rx_dma_overruns
),
838 GBE_STATSD_INFO(rx_good_frames
),
839 GBE_STATSD_INFO(rx_broadcast_frames
),
840 GBE_STATSD_INFO(rx_multicast_frames
),
841 GBE_STATSD_INFO(rx_pause_frames
),
842 GBE_STATSD_INFO(rx_crc_errors
),
843 GBE_STATSD_INFO(rx_align_code_errors
),
844 GBE_STATSD_INFO(rx_oversized_frames
),
845 GBE_STATSD_INFO(rx_jabber_frames
),
846 GBE_STATSD_INFO(rx_undersized_frames
),
847 GBE_STATSD_INFO(rx_fragments
),
848 GBE_STATSD_INFO(rx_bytes
),
849 GBE_STATSD_INFO(tx_good_frames
),
850 GBE_STATSD_INFO(tx_broadcast_frames
),
851 GBE_STATSD_INFO(tx_multicast_frames
),
852 GBE_STATSD_INFO(tx_pause_frames
),
853 GBE_STATSD_INFO(tx_deferred_frames
),
854 GBE_STATSD_INFO(tx_collision_frames
),
855 GBE_STATSD_INFO(tx_single_coll_frames
),
856 GBE_STATSD_INFO(tx_mult_coll_frames
),
857 GBE_STATSD_INFO(tx_excessive_collisions
),
858 GBE_STATSD_INFO(tx_late_collisions
),
859 GBE_STATSD_INFO(tx_underrun
),
860 GBE_STATSD_INFO(tx_carrier_sense_errors
),
861 GBE_STATSD_INFO(tx_bytes
),
862 GBE_STATSD_INFO(tx_64byte_frames
),
863 GBE_STATSD_INFO(tx_65_to_127byte_frames
),
864 GBE_STATSD_INFO(tx_128_to_255byte_frames
),
865 GBE_STATSD_INFO(tx_256_to_511byte_frames
),
866 GBE_STATSD_INFO(tx_512_to_1023byte_frames
),
867 GBE_STATSD_INFO(tx_1024byte_frames
),
868 GBE_STATSD_INFO(net_bytes
),
869 GBE_STATSD_INFO(rx_sof_overruns
),
870 GBE_STATSD_INFO(rx_mof_overruns
),
871 GBE_STATSD_INFO(rx_dma_overruns
),
874 /* This is the size of entries in GBENU_STATS_HOST */
875 #define GBENU_ET_STATS_HOST_SIZE 52
877 #define GBENU_STATS_HOST(field) \
879 "GBE_HOST:"#field, GBENU_STATS0_MODULE, \
880 FIELD_SIZEOF(struct gbenu_hw_stats, field), \
881 offsetof(struct gbenu_hw_stats, field) \
884 /* This is the size of entries in GBENU_STATS_PORT */
885 #define GBENU_ET_STATS_PORT_SIZE 65
887 #define GBENU_STATS_P1(field) \
889 "GBE_P1:"#field, GBENU_STATS1_MODULE, \
890 FIELD_SIZEOF(struct gbenu_hw_stats, field), \
891 offsetof(struct gbenu_hw_stats, field) \
894 #define GBENU_STATS_P2(field) \
896 "GBE_P2:"#field, GBENU_STATS2_MODULE, \
897 FIELD_SIZEOF(struct gbenu_hw_stats, field), \
898 offsetof(struct gbenu_hw_stats, field) \
901 #define GBENU_STATS_P3(field) \
903 "GBE_P3:"#field, GBENU_STATS3_MODULE, \
904 FIELD_SIZEOF(struct gbenu_hw_stats, field), \
905 offsetof(struct gbenu_hw_stats, field) \
908 #define GBENU_STATS_P4(field) \
910 "GBE_P4:"#field, GBENU_STATS4_MODULE, \
911 FIELD_SIZEOF(struct gbenu_hw_stats, field), \
912 offsetof(struct gbenu_hw_stats, field) \
915 #define GBENU_STATS_P5(field) \
917 "GBE_P5:"#field, GBENU_STATS5_MODULE, \
918 FIELD_SIZEOF(struct gbenu_hw_stats, field), \
919 offsetof(struct gbenu_hw_stats, field) \
922 #define GBENU_STATS_P6(field) \
924 "GBE_P6:"#field, GBENU_STATS6_MODULE, \
925 FIELD_SIZEOF(struct gbenu_hw_stats, field), \
926 offsetof(struct gbenu_hw_stats, field) \
929 #define GBENU_STATS_P7(field) \
931 "GBE_P7:"#field, GBENU_STATS7_MODULE, \
932 FIELD_SIZEOF(struct gbenu_hw_stats, field), \
933 offsetof(struct gbenu_hw_stats, field) \
936 #define GBENU_STATS_P8(field) \
938 "GBE_P8:"#field, GBENU_STATS8_MODULE, \
939 FIELD_SIZEOF(struct gbenu_hw_stats, field), \
940 offsetof(struct gbenu_hw_stats, field) \
943 static const struct netcp_ethtool_stat gbenu_et_stats
[] = {
944 /* GBENU Host Module */
945 GBENU_STATS_HOST(rx_good_frames
),
946 GBENU_STATS_HOST(rx_broadcast_frames
),
947 GBENU_STATS_HOST(rx_multicast_frames
),
948 GBENU_STATS_HOST(rx_crc_errors
),
949 GBENU_STATS_HOST(rx_oversized_frames
),
950 GBENU_STATS_HOST(rx_undersized_frames
),
951 GBENU_STATS_HOST(ale_drop
),
952 GBENU_STATS_HOST(ale_overrun_drop
),
953 GBENU_STATS_HOST(rx_bytes
),
954 GBENU_STATS_HOST(tx_good_frames
),
955 GBENU_STATS_HOST(tx_broadcast_frames
),
956 GBENU_STATS_HOST(tx_multicast_frames
),
957 GBENU_STATS_HOST(tx_bytes
),
958 GBENU_STATS_HOST(tx_64B_frames
),
959 GBENU_STATS_HOST(tx_65_to_127B_frames
),
960 GBENU_STATS_HOST(tx_128_to_255B_frames
),
961 GBENU_STATS_HOST(tx_256_to_511B_frames
),
962 GBENU_STATS_HOST(tx_512_to_1023B_frames
),
963 GBENU_STATS_HOST(tx_1024B_frames
),
964 GBENU_STATS_HOST(net_bytes
),
965 GBENU_STATS_HOST(rx_bottom_fifo_drop
),
966 GBENU_STATS_HOST(rx_port_mask_drop
),
967 GBENU_STATS_HOST(rx_top_fifo_drop
),
968 GBENU_STATS_HOST(ale_rate_limit_drop
),
969 GBENU_STATS_HOST(ale_vid_ingress_drop
),
970 GBENU_STATS_HOST(ale_da_eq_sa_drop
),
971 GBENU_STATS_HOST(ale_unknown_ucast
),
972 GBENU_STATS_HOST(ale_unknown_ucast_bytes
),
973 GBENU_STATS_HOST(ale_unknown_mcast
),
974 GBENU_STATS_HOST(ale_unknown_mcast_bytes
),
975 GBENU_STATS_HOST(ale_unknown_bcast
),
976 GBENU_STATS_HOST(ale_unknown_bcast_bytes
),
977 GBENU_STATS_HOST(ale_pol_match
),
978 GBENU_STATS_HOST(ale_pol_match_red
),
979 GBENU_STATS_HOST(ale_pol_match_yellow
),
980 GBENU_STATS_HOST(tx_mem_protect_err
),
981 GBENU_STATS_HOST(tx_pri0_drop
),
982 GBENU_STATS_HOST(tx_pri1_drop
),
983 GBENU_STATS_HOST(tx_pri2_drop
),
984 GBENU_STATS_HOST(tx_pri3_drop
),
985 GBENU_STATS_HOST(tx_pri4_drop
),
986 GBENU_STATS_HOST(tx_pri5_drop
),
987 GBENU_STATS_HOST(tx_pri6_drop
),
988 GBENU_STATS_HOST(tx_pri7_drop
),
989 GBENU_STATS_HOST(tx_pri0_drop_bcnt
),
990 GBENU_STATS_HOST(tx_pri1_drop_bcnt
),
991 GBENU_STATS_HOST(tx_pri2_drop_bcnt
),
992 GBENU_STATS_HOST(tx_pri3_drop_bcnt
),
993 GBENU_STATS_HOST(tx_pri4_drop_bcnt
),
994 GBENU_STATS_HOST(tx_pri5_drop_bcnt
),
995 GBENU_STATS_HOST(tx_pri6_drop_bcnt
),
996 GBENU_STATS_HOST(tx_pri7_drop_bcnt
),
998 GBENU_STATS_P1(rx_good_frames
),
999 GBENU_STATS_P1(rx_broadcast_frames
),
1000 GBENU_STATS_P1(rx_multicast_frames
),
1001 GBENU_STATS_P1(rx_pause_frames
),
1002 GBENU_STATS_P1(rx_crc_errors
),
1003 GBENU_STATS_P1(rx_align_code_errors
),
1004 GBENU_STATS_P1(rx_oversized_frames
),
1005 GBENU_STATS_P1(rx_jabber_frames
),
1006 GBENU_STATS_P1(rx_undersized_frames
),
1007 GBENU_STATS_P1(rx_fragments
),
1008 GBENU_STATS_P1(ale_drop
),
1009 GBENU_STATS_P1(ale_overrun_drop
),
1010 GBENU_STATS_P1(rx_bytes
),
1011 GBENU_STATS_P1(tx_good_frames
),
1012 GBENU_STATS_P1(tx_broadcast_frames
),
1013 GBENU_STATS_P1(tx_multicast_frames
),
1014 GBENU_STATS_P1(tx_pause_frames
),
1015 GBENU_STATS_P1(tx_deferred_frames
),
1016 GBENU_STATS_P1(tx_collision_frames
),
1017 GBENU_STATS_P1(tx_single_coll_frames
),
1018 GBENU_STATS_P1(tx_mult_coll_frames
),
1019 GBENU_STATS_P1(tx_excessive_collisions
),
1020 GBENU_STATS_P1(tx_late_collisions
),
1021 GBENU_STATS_P1(rx_ipg_error
),
1022 GBENU_STATS_P1(tx_carrier_sense_errors
),
1023 GBENU_STATS_P1(tx_bytes
),
1024 GBENU_STATS_P1(tx_64B_frames
),
1025 GBENU_STATS_P1(tx_65_to_127B_frames
),
1026 GBENU_STATS_P1(tx_128_to_255B_frames
),
1027 GBENU_STATS_P1(tx_256_to_511B_frames
),
1028 GBENU_STATS_P1(tx_512_to_1023B_frames
),
1029 GBENU_STATS_P1(tx_1024B_frames
),
1030 GBENU_STATS_P1(net_bytes
),
1031 GBENU_STATS_P1(rx_bottom_fifo_drop
),
1032 GBENU_STATS_P1(rx_port_mask_drop
),
1033 GBENU_STATS_P1(rx_top_fifo_drop
),
1034 GBENU_STATS_P1(ale_rate_limit_drop
),
1035 GBENU_STATS_P1(ale_vid_ingress_drop
),
1036 GBENU_STATS_P1(ale_da_eq_sa_drop
),
1037 GBENU_STATS_P1(ale_unknown_ucast
),
1038 GBENU_STATS_P1(ale_unknown_ucast_bytes
),
1039 GBENU_STATS_P1(ale_unknown_mcast
),
1040 GBENU_STATS_P1(ale_unknown_mcast_bytes
),
1041 GBENU_STATS_P1(ale_unknown_bcast
),
1042 GBENU_STATS_P1(ale_unknown_bcast_bytes
),
1043 GBENU_STATS_P1(ale_pol_match
),
1044 GBENU_STATS_P1(ale_pol_match_red
),
1045 GBENU_STATS_P1(ale_pol_match_yellow
),
1046 GBENU_STATS_P1(tx_mem_protect_err
),
1047 GBENU_STATS_P1(tx_pri0_drop
),
1048 GBENU_STATS_P1(tx_pri1_drop
),
1049 GBENU_STATS_P1(tx_pri2_drop
),
1050 GBENU_STATS_P1(tx_pri3_drop
),
1051 GBENU_STATS_P1(tx_pri4_drop
),
1052 GBENU_STATS_P1(tx_pri5_drop
),
1053 GBENU_STATS_P1(tx_pri6_drop
),
1054 GBENU_STATS_P1(tx_pri7_drop
),
1055 GBENU_STATS_P1(tx_pri0_drop_bcnt
),
1056 GBENU_STATS_P1(tx_pri1_drop_bcnt
),
1057 GBENU_STATS_P1(tx_pri2_drop_bcnt
),
1058 GBENU_STATS_P1(tx_pri3_drop_bcnt
),
1059 GBENU_STATS_P1(tx_pri4_drop_bcnt
),
1060 GBENU_STATS_P1(tx_pri5_drop_bcnt
),
1061 GBENU_STATS_P1(tx_pri6_drop_bcnt
),
1062 GBENU_STATS_P1(tx_pri7_drop_bcnt
),
1063 /* GBENU Module 2 */
1064 GBENU_STATS_P2(rx_good_frames
),
1065 GBENU_STATS_P2(rx_broadcast_frames
),
1066 GBENU_STATS_P2(rx_multicast_frames
),
1067 GBENU_STATS_P2(rx_pause_frames
),
1068 GBENU_STATS_P2(rx_crc_errors
),
1069 GBENU_STATS_P2(rx_align_code_errors
),
1070 GBENU_STATS_P2(rx_oversized_frames
),
1071 GBENU_STATS_P2(rx_jabber_frames
),
1072 GBENU_STATS_P2(rx_undersized_frames
),
1073 GBENU_STATS_P2(rx_fragments
),
1074 GBENU_STATS_P2(ale_drop
),
1075 GBENU_STATS_P2(ale_overrun_drop
),
1076 GBENU_STATS_P2(rx_bytes
),
1077 GBENU_STATS_P2(tx_good_frames
),
1078 GBENU_STATS_P2(tx_broadcast_frames
),
1079 GBENU_STATS_P2(tx_multicast_frames
),
1080 GBENU_STATS_P2(tx_pause_frames
),
1081 GBENU_STATS_P2(tx_deferred_frames
),
1082 GBENU_STATS_P2(tx_collision_frames
),
1083 GBENU_STATS_P2(tx_single_coll_frames
),
1084 GBENU_STATS_P2(tx_mult_coll_frames
),
1085 GBENU_STATS_P2(tx_excessive_collisions
),
1086 GBENU_STATS_P2(tx_late_collisions
),
1087 GBENU_STATS_P2(rx_ipg_error
),
1088 GBENU_STATS_P2(tx_carrier_sense_errors
),
1089 GBENU_STATS_P2(tx_bytes
),
1090 GBENU_STATS_P2(tx_64B_frames
),
1091 GBENU_STATS_P2(tx_65_to_127B_frames
),
1092 GBENU_STATS_P2(tx_128_to_255B_frames
),
1093 GBENU_STATS_P2(tx_256_to_511B_frames
),
1094 GBENU_STATS_P2(tx_512_to_1023B_frames
),
1095 GBENU_STATS_P2(tx_1024B_frames
),
1096 GBENU_STATS_P2(net_bytes
),
1097 GBENU_STATS_P2(rx_bottom_fifo_drop
),
1098 GBENU_STATS_P2(rx_port_mask_drop
),
1099 GBENU_STATS_P2(rx_top_fifo_drop
),
1100 GBENU_STATS_P2(ale_rate_limit_drop
),
1101 GBENU_STATS_P2(ale_vid_ingress_drop
),
1102 GBENU_STATS_P2(ale_da_eq_sa_drop
),
1103 GBENU_STATS_P2(ale_unknown_ucast
),
1104 GBENU_STATS_P2(ale_unknown_ucast_bytes
),
1105 GBENU_STATS_P2(ale_unknown_mcast
),
1106 GBENU_STATS_P2(ale_unknown_mcast_bytes
),
1107 GBENU_STATS_P2(ale_unknown_bcast
),
1108 GBENU_STATS_P2(ale_unknown_bcast_bytes
),
1109 GBENU_STATS_P2(ale_pol_match
),
1110 GBENU_STATS_P2(ale_pol_match_red
),
1111 GBENU_STATS_P2(ale_pol_match_yellow
),
1112 GBENU_STATS_P2(tx_mem_protect_err
),
1113 GBENU_STATS_P2(tx_pri0_drop
),
1114 GBENU_STATS_P2(tx_pri1_drop
),
1115 GBENU_STATS_P2(tx_pri2_drop
),
1116 GBENU_STATS_P2(tx_pri3_drop
),
1117 GBENU_STATS_P2(tx_pri4_drop
),
1118 GBENU_STATS_P2(tx_pri5_drop
),
1119 GBENU_STATS_P2(tx_pri6_drop
),
1120 GBENU_STATS_P2(tx_pri7_drop
),
1121 GBENU_STATS_P2(tx_pri0_drop_bcnt
),
1122 GBENU_STATS_P2(tx_pri1_drop_bcnt
),
1123 GBENU_STATS_P2(tx_pri2_drop_bcnt
),
1124 GBENU_STATS_P2(tx_pri3_drop_bcnt
),
1125 GBENU_STATS_P2(tx_pri4_drop_bcnt
),
1126 GBENU_STATS_P2(tx_pri5_drop_bcnt
),
1127 GBENU_STATS_P2(tx_pri6_drop_bcnt
),
1128 GBENU_STATS_P2(tx_pri7_drop_bcnt
),
1129 /* GBENU Module 3 */
1130 GBENU_STATS_P3(rx_good_frames
),
1131 GBENU_STATS_P3(rx_broadcast_frames
),
1132 GBENU_STATS_P3(rx_multicast_frames
),
1133 GBENU_STATS_P3(rx_pause_frames
),
1134 GBENU_STATS_P3(rx_crc_errors
),
1135 GBENU_STATS_P3(rx_align_code_errors
),
1136 GBENU_STATS_P3(rx_oversized_frames
),
1137 GBENU_STATS_P3(rx_jabber_frames
),
1138 GBENU_STATS_P3(rx_undersized_frames
),
1139 GBENU_STATS_P3(rx_fragments
),
1140 GBENU_STATS_P3(ale_drop
),
1141 GBENU_STATS_P3(ale_overrun_drop
),
1142 GBENU_STATS_P3(rx_bytes
),
1143 GBENU_STATS_P3(tx_good_frames
),
1144 GBENU_STATS_P3(tx_broadcast_frames
),
1145 GBENU_STATS_P3(tx_multicast_frames
),
1146 GBENU_STATS_P3(tx_pause_frames
),
1147 GBENU_STATS_P3(tx_deferred_frames
),
1148 GBENU_STATS_P3(tx_collision_frames
),
1149 GBENU_STATS_P3(tx_single_coll_frames
),
1150 GBENU_STATS_P3(tx_mult_coll_frames
),
1151 GBENU_STATS_P3(tx_excessive_collisions
),
1152 GBENU_STATS_P3(tx_late_collisions
),
1153 GBENU_STATS_P3(rx_ipg_error
),
1154 GBENU_STATS_P3(tx_carrier_sense_errors
),
1155 GBENU_STATS_P3(tx_bytes
),
1156 GBENU_STATS_P3(tx_64B_frames
),
1157 GBENU_STATS_P3(tx_65_to_127B_frames
),
1158 GBENU_STATS_P3(tx_128_to_255B_frames
),
1159 GBENU_STATS_P3(tx_256_to_511B_frames
),
1160 GBENU_STATS_P3(tx_512_to_1023B_frames
),
1161 GBENU_STATS_P3(tx_1024B_frames
),
1162 GBENU_STATS_P3(net_bytes
),
1163 GBENU_STATS_P3(rx_bottom_fifo_drop
),
1164 GBENU_STATS_P3(rx_port_mask_drop
),
1165 GBENU_STATS_P3(rx_top_fifo_drop
),
1166 GBENU_STATS_P3(ale_rate_limit_drop
),
1167 GBENU_STATS_P3(ale_vid_ingress_drop
),
1168 GBENU_STATS_P3(ale_da_eq_sa_drop
),
1169 GBENU_STATS_P3(ale_unknown_ucast
),
1170 GBENU_STATS_P3(ale_unknown_ucast_bytes
),
1171 GBENU_STATS_P3(ale_unknown_mcast
),
1172 GBENU_STATS_P3(ale_unknown_mcast_bytes
),
1173 GBENU_STATS_P3(ale_unknown_bcast
),
1174 GBENU_STATS_P3(ale_unknown_bcast_bytes
),
1175 GBENU_STATS_P3(ale_pol_match
),
1176 GBENU_STATS_P3(ale_pol_match_red
),
1177 GBENU_STATS_P3(ale_pol_match_yellow
),
1178 GBENU_STATS_P3(tx_mem_protect_err
),
1179 GBENU_STATS_P3(tx_pri0_drop
),
1180 GBENU_STATS_P3(tx_pri1_drop
),
1181 GBENU_STATS_P3(tx_pri2_drop
),
1182 GBENU_STATS_P3(tx_pri3_drop
),
1183 GBENU_STATS_P3(tx_pri4_drop
),
1184 GBENU_STATS_P3(tx_pri5_drop
),
1185 GBENU_STATS_P3(tx_pri6_drop
),
1186 GBENU_STATS_P3(tx_pri7_drop
),
1187 GBENU_STATS_P3(tx_pri0_drop_bcnt
),
1188 GBENU_STATS_P3(tx_pri1_drop_bcnt
),
1189 GBENU_STATS_P3(tx_pri2_drop_bcnt
),
1190 GBENU_STATS_P3(tx_pri3_drop_bcnt
),
1191 GBENU_STATS_P3(tx_pri4_drop_bcnt
),
1192 GBENU_STATS_P3(tx_pri5_drop_bcnt
),
1193 GBENU_STATS_P3(tx_pri6_drop_bcnt
),
1194 GBENU_STATS_P3(tx_pri7_drop_bcnt
),
1195 /* GBENU Module 4 */
1196 GBENU_STATS_P4(rx_good_frames
),
1197 GBENU_STATS_P4(rx_broadcast_frames
),
1198 GBENU_STATS_P4(rx_multicast_frames
),
1199 GBENU_STATS_P4(rx_pause_frames
),
1200 GBENU_STATS_P4(rx_crc_errors
),
1201 GBENU_STATS_P4(rx_align_code_errors
),
1202 GBENU_STATS_P4(rx_oversized_frames
),
1203 GBENU_STATS_P4(rx_jabber_frames
),
1204 GBENU_STATS_P4(rx_undersized_frames
),
1205 GBENU_STATS_P4(rx_fragments
),
1206 GBENU_STATS_P4(ale_drop
),
1207 GBENU_STATS_P4(ale_overrun_drop
),
1208 GBENU_STATS_P4(rx_bytes
),
1209 GBENU_STATS_P4(tx_good_frames
),
1210 GBENU_STATS_P4(tx_broadcast_frames
),
1211 GBENU_STATS_P4(tx_multicast_frames
),
1212 GBENU_STATS_P4(tx_pause_frames
),
1213 GBENU_STATS_P4(tx_deferred_frames
),
1214 GBENU_STATS_P4(tx_collision_frames
),
1215 GBENU_STATS_P4(tx_single_coll_frames
),
1216 GBENU_STATS_P4(tx_mult_coll_frames
),
1217 GBENU_STATS_P4(tx_excessive_collisions
),
1218 GBENU_STATS_P4(tx_late_collisions
),
1219 GBENU_STATS_P4(rx_ipg_error
),
1220 GBENU_STATS_P4(tx_carrier_sense_errors
),
1221 GBENU_STATS_P4(tx_bytes
),
1222 GBENU_STATS_P4(tx_64B_frames
),
1223 GBENU_STATS_P4(tx_65_to_127B_frames
),
1224 GBENU_STATS_P4(tx_128_to_255B_frames
),
1225 GBENU_STATS_P4(tx_256_to_511B_frames
),
1226 GBENU_STATS_P4(tx_512_to_1023B_frames
),
1227 GBENU_STATS_P4(tx_1024B_frames
),
1228 GBENU_STATS_P4(net_bytes
),
1229 GBENU_STATS_P4(rx_bottom_fifo_drop
),
1230 GBENU_STATS_P4(rx_port_mask_drop
),
1231 GBENU_STATS_P4(rx_top_fifo_drop
),
1232 GBENU_STATS_P4(ale_rate_limit_drop
),
1233 GBENU_STATS_P4(ale_vid_ingress_drop
),
1234 GBENU_STATS_P4(ale_da_eq_sa_drop
),
1235 GBENU_STATS_P4(ale_unknown_ucast
),
1236 GBENU_STATS_P4(ale_unknown_ucast_bytes
),
1237 GBENU_STATS_P4(ale_unknown_mcast
),
1238 GBENU_STATS_P4(ale_unknown_mcast_bytes
),
1239 GBENU_STATS_P4(ale_unknown_bcast
),
1240 GBENU_STATS_P4(ale_unknown_bcast_bytes
),
1241 GBENU_STATS_P4(ale_pol_match
),
1242 GBENU_STATS_P4(ale_pol_match_red
),
1243 GBENU_STATS_P4(ale_pol_match_yellow
),
1244 GBENU_STATS_P4(tx_mem_protect_err
),
1245 GBENU_STATS_P4(tx_pri0_drop
),
1246 GBENU_STATS_P4(tx_pri1_drop
),
1247 GBENU_STATS_P4(tx_pri2_drop
),
1248 GBENU_STATS_P4(tx_pri3_drop
),
1249 GBENU_STATS_P4(tx_pri4_drop
),
1250 GBENU_STATS_P4(tx_pri5_drop
),
1251 GBENU_STATS_P4(tx_pri6_drop
),
1252 GBENU_STATS_P4(tx_pri7_drop
),
1253 GBENU_STATS_P4(tx_pri0_drop_bcnt
),
1254 GBENU_STATS_P4(tx_pri1_drop_bcnt
),
1255 GBENU_STATS_P4(tx_pri2_drop_bcnt
),
1256 GBENU_STATS_P4(tx_pri3_drop_bcnt
),
1257 GBENU_STATS_P4(tx_pri4_drop_bcnt
),
1258 GBENU_STATS_P4(tx_pri5_drop_bcnt
),
1259 GBENU_STATS_P4(tx_pri6_drop_bcnt
),
1260 GBENU_STATS_P4(tx_pri7_drop_bcnt
),
1261 /* GBENU Module 5 */
1262 GBENU_STATS_P5(rx_good_frames
),
1263 GBENU_STATS_P5(rx_broadcast_frames
),
1264 GBENU_STATS_P5(rx_multicast_frames
),
1265 GBENU_STATS_P5(rx_pause_frames
),
1266 GBENU_STATS_P5(rx_crc_errors
),
1267 GBENU_STATS_P5(rx_align_code_errors
),
1268 GBENU_STATS_P5(rx_oversized_frames
),
1269 GBENU_STATS_P5(rx_jabber_frames
),
1270 GBENU_STATS_P5(rx_undersized_frames
),
1271 GBENU_STATS_P5(rx_fragments
),
1272 GBENU_STATS_P5(ale_drop
),
1273 GBENU_STATS_P5(ale_overrun_drop
),
1274 GBENU_STATS_P5(rx_bytes
),
1275 GBENU_STATS_P5(tx_good_frames
),
1276 GBENU_STATS_P5(tx_broadcast_frames
),
1277 GBENU_STATS_P5(tx_multicast_frames
),
1278 GBENU_STATS_P5(tx_pause_frames
),
1279 GBENU_STATS_P5(tx_deferred_frames
),
1280 GBENU_STATS_P5(tx_collision_frames
),
1281 GBENU_STATS_P5(tx_single_coll_frames
),
1282 GBENU_STATS_P5(tx_mult_coll_frames
),
1283 GBENU_STATS_P5(tx_excessive_collisions
),
1284 GBENU_STATS_P5(tx_late_collisions
),
1285 GBENU_STATS_P5(rx_ipg_error
),
1286 GBENU_STATS_P5(tx_carrier_sense_errors
),
1287 GBENU_STATS_P5(tx_bytes
),
1288 GBENU_STATS_P5(tx_64B_frames
),
1289 GBENU_STATS_P5(tx_65_to_127B_frames
),
1290 GBENU_STATS_P5(tx_128_to_255B_frames
),
1291 GBENU_STATS_P5(tx_256_to_511B_frames
),
1292 GBENU_STATS_P5(tx_512_to_1023B_frames
),
1293 GBENU_STATS_P5(tx_1024B_frames
),
1294 GBENU_STATS_P5(net_bytes
),
1295 GBENU_STATS_P5(rx_bottom_fifo_drop
),
1296 GBENU_STATS_P5(rx_port_mask_drop
),
1297 GBENU_STATS_P5(rx_top_fifo_drop
),
1298 GBENU_STATS_P5(ale_rate_limit_drop
),
1299 GBENU_STATS_P5(ale_vid_ingress_drop
),
1300 GBENU_STATS_P5(ale_da_eq_sa_drop
),
1301 GBENU_STATS_P5(ale_unknown_ucast
),
1302 GBENU_STATS_P5(ale_unknown_ucast_bytes
),
1303 GBENU_STATS_P5(ale_unknown_mcast
),
1304 GBENU_STATS_P5(ale_unknown_mcast_bytes
),
1305 GBENU_STATS_P5(ale_unknown_bcast
),
1306 GBENU_STATS_P5(ale_unknown_bcast_bytes
),
1307 GBENU_STATS_P5(ale_pol_match
),
1308 GBENU_STATS_P5(ale_pol_match_red
),
1309 GBENU_STATS_P5(ale_pol_match_yellow
),
1310 GBENU_STATS_P5(tx_mem_protect_err
),
1311 GBENU_STATS_P5(tx_pri0_drop
),
1312 GBENU_STATS_P5(tx_pri1_drop
),
1313 GBENU_STATS_P5(tx_pri2_drop
),
1314 GBENU_STATS_P5(tx_pri3_drop
),
1315 GBENU_STATS_P5(tx_pri4_drop
),
1316 GBENU_STATS_P5(tx_pri5_drop
),
1317 GBENU_STATS_P5(tx_pri6_drop
),
1318 GBENU_STATS_P5(tx_pri7_drop
),
1319 GBENU_STATS_P5(tx_pri0_drop_bcnt
),
1320 GBENU_STATS_P5(tx_pri1_drop_bcnt
),
1321 GBENU_STATS_P5(tx_pri2_drop_bcnt
),
1322 GBENU_STATS_P5(tx_pri3_drop_bcnt
),
1323 GBENU_STATS_P5(tx_pri4_drop_bcnt
),
1324 GBENU_STATS_P5(tx_pri5_drop_bcnt
),
1325 GBENU_STATS_P5(tx_pri6_drop_bcnt
),
1326 GBENU_STATS_P5(tx_pri7_drop_bcnt
),
1327 /* GBENU Module 6 */
1328 GBENU_STATS_P6(rx_good_frames
),
1329 GBENU_STATS_P6(rx_broadcast_frames
),
1330 GBENU_STATS_P6(rx_multicast_frames
),
1331 GBENU_STATS_P6(rx_pause_frames
),
1332 GBENU_STATS_P6(rx_crc_errors
),
1333 GBENU_STATS_P6(rx_align_code_errors
),
1334 GBENU_STATS_P6(rx_oversized_frames
),
1335 GBENU_STATS_P6(rx_jabber_frames
),
1336 GBENU_STATS_P6(rx_undersized_frames
),
1337 GBENU_STATS_P6(rx_fragments
),
1338 GBENU_STATS_P6(ale_drop
),
1339 GBENU_STATS_P6(ale_overrun_drop
),
1340 GBENU_STATS_P6(rx_bytes
),
1341 GBENU_STATS_P6(tx_good_frames
),
1342 GBENU_STATS_P6(tx_broadcast_frames
),
1343 GBENU_STATS_P6(tx_multicast_frames
),
1344 GBENU_STATS_P6(tx_pause_frames
),
1345 GBENU_STATS_P6(tx_deferred_frames
),
1346 GBENU_STATS_P6(tx_collision_frames
),
1347 GBENU_STATS_P6(tx_single_coll_frames
),
1348 GBENU_STATS_P6(tx_mult_coll_frames
),
1349 GBENU_STATS_P6(tx_excessive_collisions
),
1350 GBENU_STATS_P6(tx_late_collisions
),
1351 GBENU_STATS_P6(rx_ipg_error
),
1352 GBENU_STATS_P6(tx_carrier_sense_errors
),
1353 GBENU_STATS_P6(tx_bytes
),
1354 GBENU_STATS_P6(tx_64B_frames
),
1355 GBENU_STATS_P6(tx_65_to_127B_frames
),
1356 GBENU_STATS_P6(tx_128_to_255B_frames
),
1357 GBENU_STATS_P6(tx_256_to_511B_frames
),
1358 GBENU_STATS_P6(tx_512_to_1023B_frames
),
1359 GBENU_STATS_P6(tx_1024B_frames
),
1360 GBENU_STATS_P6(net_bytes
),
1361 GBENU_STATS_P6(rx_bottom_fifo_drop
),
1362 GBENU_STATS_P6(rx_port_mask_drop
),
1363 GBENU_STATS_P6(rx_top_fifo_drop
),
1364 GBENU_STATS_P6(ale_rate_limit_drop
),
1365 GBENU_STATS_P6(ale_vid_ingress_drop
),
1366 GBENU_STATS_P6(ale_da_eq_sa_drop
),
1367 GBENU_STATS_P6(ale_unknown_ucast
),
1368 GBENU_STATS_P6(ale_unknown_ucast_bytes
),
1369 GBENU_STATS_P6(ale_unknown_mcast
),
1370 GBENU_STATS_P6(ale_unknown_mcast_bytes
),
1371 GBENU_STATS_P6(ale_unknown_bcast
),
1372 GBENU_STATS_P6(ale_unknown_bcast_bytes
),
1373 GBENU_STATS_P6(ale_pol_match
),
1374 GBENU_STATS_P6(ale_pol_match_red
),
1375 GBENU_STATS_P6(ale_pol_match_yellow
),
1376 GBENU_STATS_P6(tx_mem_protect_err
),
1377 GBENU_STATS_P6(tx_pri0_drop
),
1378 GBENU_STATS_P6(tx_pri1_drop
),
1379 GBENU_STATS_P6(tx_pri2_drop
),
1380 GBENU_STATS_P6(tx_pri3_drop
),
1381 GBENU_STATS_P6(tx_pri4_drop
),
1382 GBENU_STATS_P6(tx_pri5_drop
),
1383 GBENU_STATS_P6(tx_pri6_drop
),
1384 GBENU_STATS_P6(tx_pri7_drop
),
1385 GBENU_STATS_P6(tx_pri0_drop_bcnt
),
1386 GBENU_STATS_P6(tx_pri1_drop_bcnt
),
1387 GBENU_STATS_P6(tx_pri2_drop_bcnt
),
1388 GBENU_STATS_P6(tx_pri3_drop_bcnt
),
1389 GBENU_STATS_P6(tx_pri4_drop_bcnt
),
1390 GBENU_STATS_P6(tx_pri5_drop_bcnt
),
1391 GBENU_STATS_P6(tx_pri6_drop_bcnt
),
1392 GBENU_STATS_P6(tx_pri7_drop_bcnt
),
1393 /* GBENU Module 7 */
1394 GBENU_STATS_P7(rx_good_frames
),
1395 GBENU_STATS_P7(rx_broadcast_frames
),
1396 GBENU_STATS_P7(rx_multicast_frames
),
1397 GBENU_STATS_P7(rx_pause_frames
),
1398 GBENU_STATS_P7(rx_crc_errors
),
1399 GBENU_STATS_P7(rx_align_code_errors
),
1400 GBENU_STATS_P7(rx_oversized_frames
),
1401 GBENU_STATS_P7(rx_jabber_frames
),
1402 GBENU_STATS_P7(rx_undersized_frames
),
1403 GBENU_STATS_P7(rx_fragments
),
1404 GBENU_STATS_P7(ale_drop
),
1405 GBENU_STATS_P7(ale_overrun_drop
),
1406 GBENU_STATS_P7(rx_bytes
),
1407 GBENU_STATS_P7(tx_good_frames
),
1408 GBENU_STATS_P7(tx_broadcast_frames
),
1409 GBENU_STATS_P7(tx_multicast_frames
),
1410 GBENU_STATS_P7(tx_pause_frames
),
1411 GBENU_STATS_P7(tx_deferred_frames
),
1412 GBENU_STATS_P7(tx_collision_frames
),
1413 GBENU_STATS_P7(tx_single_coll_frames
),
1414 GBENU_STATS_P7(tx_mult_coll_frames
),
1415 GBENU_STATS_P7(tx_excessive_collisions
),
1416 GBENU_STATS_P7(tx_late_collisions
),
1417 GBENU_STATS_P7(rx_ipg_error
),
1418 GBENU_STATS_P7(tx_carrier_sense_errors
),
1419 GBENU_STATS_P7(tx_bytes
),
1420 GBENU_STATS_P7(tx_64B_frames
),
1421 GBENU_STATS_P7(tx_65_to_127B_frames
),
1422 GBENU_STATS_P7(tx_128_to_255B_frames
),
1423 GBENU_STATS_P7(tx_256_to_511B_frames
),
1424 GBENU_STATS_P7(tx_512_to_1023B_frames
),
1425 GBENU_STATS_P7(tx_1024B_frames
),
1426 GBENU_STATS_P7(net_bytes
),
1427 GBENU_STATS_P7(rx_bottom_fifo_drop
),
1428 GBENU_STATS_P7(rx_port_mask_drop
),
1429 GBENU_STATS_P7(rx_top_fifo_drop
),
1430 GBENU_STATS_P7(ale_rate_limit_drop
),
1431 GBENU_STATS_P7(ale_vid_ingress_drop
),
1432 GBENU_STATS_P7(ale_da_eq_sa_drop
),
1433 GBENU_STATS_P7(ale_unknown_ucast
),
1434 GBENU_STATS_P7(ale_unknown_ucast_bytes
),
1435 GBENU_STATS_P7(ale_unknown_mcast
),
1436 GBENU_STATS_P7(ale_unknown_mcast_bytes
),
1437 GBENU_STATS_P7(ale_unknown_bcast
),
1438 GBENU_STATS_P7(ale_unknown_bcast_bytes
),
1439 GBENU_STATS_P7(ale_pol_match
),
1440 GBENU_STATS_P7(ale_pol_match_red
),
1441 GBENU_STATS_P7(ale_pol_match_yellow
),
1442 GBENU_STATS_P7(tx_mem_protect_err
),
1443 GBENU_STATS_P7(tx_pri0_drop
),
1444 GBENU_STATS_P7(tx_pri1_drop
),
1445 GBENU_STATS_P7(tx_pri2_drop
),
1446 GBENU_STATS_P7(tx_pri3_drop
),
1447 GBENU_STATS_P7(tx_pri4_drop
),
1448 GBENU_STATS_P7(tx_pri5_drop
),
1449 GBENU_STATS_P7(tx_pri6_drop
),
1450 GBENU_STATS_P7(tx_pri7_drop
),
1451 GBENU_STATS_P7(tx_pri0_drop_bcnt
),
1452 GBENU_STATS_P7(tx_pri1_drop_bcnt
),
1453 GBENU_STATS_P7(tx_pri2_drop_bcnt
),
1454 GBENU_STATS_P7(tx_pri3_drop_bcnt
),
1455 GBENU_STATS_P7(tx_pri4_drop_bcnt
),
1456 GBENU_STATS_P7(tx_pri5_drop_bcnt
),
1457 GBENU_STATS_P7(tx_pri6_drop_bcnt
),
1458 GBENU_STATS_P7(tx_pri7_drop_bcnt
),
1459 /* GBENU Module 8 */
1460 GBENU_STATS_P8(rx_good_frames
),
1461 GBENU_STATS_P8(rx_broadcast_frames
),
1462 GBENU_STATS_P8(rx_multicast_frames
),
1463 GBENU_STATS_P8(rx_pause_frames
),
1464 GBENU_STATS_P8(rx_crc_errors
),
1465 GBENU_STATS_P8(rx_align_code_errors
),
1466 GBENU_STATS_P8(rx_oversized_frames
),
1467 GBENU_STATS_P8(rx_jabber_frames
),
1468 GBENU_STATS_P8(rx_undersized_frames
),
1469 GBENU_STATS_P8(rx_fragments
),
1470 GBENU_STATS_P8(ale_drop
),
1471 GBENU_STATS_P8(ale_overrun_drop
),
1472 GBENU_STATS_P8(rx_bytes
),
1473 GBENU_STATS_P8(tx_good_frames
),
1474 GBENU_STATS_P8(tx_broadcast_frames
),
1475 GBENU_STATS_P8(tx_multicast_frames
),
1476 GBENU_STATS_P8(tx_pause_frames
),
1477 GBENU_STATS_P8(tx_deferred_frames
),
1478 GBENU_STATS_P8(tx_collision_frames
),
1479 GBENU_STATS_P8(tx_single_coll_frames
),
1480 GBENU_STATS_P8(tx_mult_coll_frames
),
1481 GBENU_STATS_P8(tx_excessive_collisions
),
1482 GBENU_STATS_P8(tx_late_collisions
),
1483 GBENU_STATS_P8(rx_ipg_error
),
1484 GBENU_STATS_P8(tx_carrier_sense_errors
),
1485 GBENU_STATS_P8(tx_bytes
),
1486 GBENU_STATS_P8(tx_64B_frames
),
1487 GBENU_STATS_P8(tx_65_to_127B_frames
),
1488 GBENU_STATS_P8(tx_128_to_255B_frames
),
1489 GBENU_STATS_P8(tx_256_to_511B_frames
),
1490 GBENU_STATS_P8(tx_512_to_1023B_frames
),
1491 GBENU_STATS_P8(tx_1024B_frames
),
1492 GBENU_STATS_P8(net_bytes
),
1493 GBENU_STATS_P8(rx_bottom_fifo_drop
),
1494 GBENU_STATS_P8(rx_port_mask_drop
),
1495 GBENU_STATS_P8(rx_top_fifo_drop
),
1496 GBENU_STATS_P8(ale_rate_limit_drop
),
1497 GBENU_STATS_P8(ale_vid_ingress_drop
),
1498 GBENU_STATS_P8(ale_da_eq_sa_drop
),
1499 GBENU_STATS_P8(ale_unknown_ucast
),
1500 GBENU_STATS_P8(ale_unknown_ucast_bytes
),
1501 GBENU_STATS_P8(ale_unknown_mcast
),
1502 GBENU_STATS_P8(ale_unknown_mcast_bytes
),
1503 GBENU_STATS_P8(ale_unknown_bcast
),
1504 GBENU_STATS_P8(ale_unknown_bcast_bytes
),
1505 GBENU_STATS_P8(ale_pol_match
),
1506 GBENU_STATS_P8(ale_pol_match_red
),
1507 GBENU_STATS_P8(ale_pol_match_yellow
),
1508 GBENU_STATS_P8(tx_mem_protect_err
),
1509 GBENU_STATS_P8(tx_pri0_drop
),
1510 GBENU_STATS_P8(tx_pri1_drop
),
1511 GBENU_STATS_P8(tx_pri2_drop
),
1512 GBENU_STATS_P8(tx_pri3_drop
),
1513 GBENU_STATS_P8(tx_pri4_drop
),
1514 GBENU_STATS_P8(tx_pri5_drop
),
1515 GBENU_STATS_P8(tx_pri6_drop
),
1516 GBENU_STATS_P8(tx_pri7_drop
),
1517 GBENU_STATS_P8(tx_pri0_drop_bcnt
),
1518 GBENU_STATS_P8(tx_pri1_drop_bcnt
),
1519 GBENU_STATS_P8(tx_pri2_drop_bcnt
),
1520 GBENU_STATS_P8(tx_pri3_drop_bcnt
),
1521 GBENU_STATS_P8(tx_pri4_drop_bcnt
),
1522 GBENU_STATS_P8(tx_pri5_drop_bcnt
),
1523 GBENU_STATS_P8(tx_pri6_drop_bcnt
),
1524 GBENU_STATS_P8(tx_pri7_drop_bcnt
),
1527 #define XGBE_STATS0_INFO(field) \
1529 "GBE_0:"#field, XGBE_STATS0_MODULE, \
1530 FIELD_SIZEOF(struct xgbe_hw_stats, field), \
1531 offsetof(struct xgbe_hw_stats, field) \
1534 #define XGBE_STATS1_INFO(field) \
1536 "GBE_1:"#field, XGBE_STATS1_MODULE, \
1537 FIELD_SIZEOF(struct xgbe_hw_stats, field), \
1538 offsetof(struct xgbe_hw_stats, field) \
1541 #define XGBE_STATS2_INFO(field) \
1543 "GBE_2:"#field, XGBE_STATS2_MODULE, \
1544 FIELD_SIZEOF(struct xgbe_hw_stats, field), \
1545 offsetof(struct xgbe_hw_stats, field) \
1548 static const struct netcp_ethtool_stat xgbe10_et_stats
[] = {
1550 XGBE_STATS0_INFO(rx_good_frames
),
1551 XGBE_STATS0_INFO(rx_broadcast_frames
),
1552 XGBE_STATS0_INFO(rx_multicast_frames
),
1553 XGBE_STATS0_INFO(rx_oversized_frames
),
1554 XGBE_STATS0_INFO(rx_undersized_frames
),
1555 XGBE_STATS0_INFO(overrun_type4
),
1556 XGBE_STATS0_INFO(overrun_type5
),
1557 XGBE_STATS0_INFO(rx_bytes
),
1558 XGBE_STATS0_INFO(tx_good_frames
),
1559 XGBE_STATS0_INFO(tx_broadcast_frames
),
1560 XGBE_STATS0_INFO(tx_multicast_frames
),
1561 XGBE_STATS0_INFO(tx_bytes
),
1562 XGBE_STATS0_INFO(tx_64byte_frames
),
1563 XGBE_STATS0_INFO(tx_65_to_127byte_frames
),
1564 XGBE_STATS0_INFO(tx_128_to_255byte_frames
),
1565 XGBE_STATS0_INFO(tx_256_to_511byte_frames
),
1566 XGBE_STATS0_INFO(tx_512_to_1023byte_frames
),
1567 XGBE_STATS0_INFO(tx_1024byte_frames
),
1568 XGBE_STATS0_INFO(net_bytes
),
1569 XGBE_STATS0_INFO(rx_sof_overruns
),
1570 XGBE_STATS0_INFO(rx_mof_overruns
),
1571 XGBE_STATS0_INFO(rx_dma_overruns
),
1573 XGBE_STATS1_INFO(rx_good_frames
),
1574 XGBE_STATS1_INFO(rx_broadcast_frames
),
1575 XGBE_STATS1_INFO(rx_multicast_frames
),
1576 XGBE_STATS1_INFO(rx_pause_frames
),
1577 XGBE_STATS1_INFO(rx_crc_errors
),
1578 XGBE_STATS1_INFO(rx_align_code_errors
),
1579 XGBE_STATS1_INFO(rx_oversized_frames
),
1580 XGBE_STATS1_INFO(rx_jabber_frames
),
1581 XGBE_STATS1_INFO(rx_undersized_frames
),
1582 XGBE_STATS1_INFO(rx_fragments
),
1583 XGBE_STATS1_INFO(overrun_type4
),
1584 XGBE_STATS1_INFO(overrun_type5
),
1585 XGBE_STATS1_INFO(rx_bytes
),
1586 XGBE_STATS1_INFO(tx_good_frames
),
1587 XGBE_STATS1_INFO(tx_broadcast_frames
),
1588 XGBE_STATS1_INFO(tx_multicast_frames
),
1589 XGBE_STATS1_INFO(tx_pause_frames
),
1590 XGBE_STATS1_INFO(tx_deferred_frames
),
1591 XGBE_STATS1_INFO(tx_collision_frames
),
1592 XGBE_STATS1_INFO(tx_single_coll_frames
),
1593 XGBE_STATS1_INFO(tx_mult_coll_frames
),
1594 XGBE_STATS1_INFO(tx_excessive_collisions
),
1595 XGBE_STATS1_INFO(tx_late_collisions
),
1596 XGBE_STATS1_INFO(tx_underrun
),
1597 XGBE_STATS1_INFO(tx_carrier_sense_errors
),
1598 XGBE_STATS1_INFO(tx_bytes
),
1599 XGBE_STATS1_INFO(tx_64byte_frames
),
1600 XGBE_STATS1_INFO(tx_65_to_127byte_frames
),
1601 XGBE_STATS1_INFO(tx_128_to_255byte_frames
),
1602 XGBE_STATS1_INFO(tx_256_to_511byte_frames
),
1603 XGBE_STATS1_INFO(tx_512_to_1023byte_frames
),
1604 XGBE_STATS1_INFO(tx_1024byte_frames
),
1605 XGBE_STATS1_INFO(net_bytes
),
1606 XGBE_STATS1_INFO(rx_sof_overruns
),
1607 XGBE_STATS1_INFO(rx_mof_overruns
),
1608 XGBE_STATS1_INFO(rx_dma_overruns
),
1610 XGBE_STATS2_INFO(rx_good_frames
),
1611 XGBE_STATS2_INFO(rx_broadcast_frames
),
1612 XGBE_STATS2_INFO(rx_multicast_frames
),
1613 XGBE_STATS2_INFO(rx_pause_frames
),
1614 XGBE_STATS2_INFO(rx_crc_errors
),
1615 XGBE_STATS2_INFO(rx_align_code_errors
),
1616 XGBE_STATS2_INFO(rx_oversized_frames
),
1617 XGBE_STATS2_INFO(rx_jabber_frames
),
1618 XGBE_STATS2_INFO(rx_undersized_frames
),
1619 XGBE_STATS2_INFO(rx_fragments
),
1620 XGBE_STATS2_INFO(overrun_type4
),
1621 XGBE_STATS2_INFO(overrun_type5
),
1622 XGBE_STATS2_INFO(rx_bytes
),
1623 XGBE_STATS2_INFO(tx_good_frames
),
1624 XGBE_STATS2_INFO(tx_broadcast_frames
),
1625 XGBE_STATS2_INFO(tx_multicast_frames
),
1626 XGBE_STATS2_INFO(tx_pause_frames
),
1627 XGBE_STATS2_INFO(tx_deferred_frames
),
1628 XGBE_STATS2_INFO(tx_collision_frames
),
1629 XGBE_STATS2_INFO(tx_single_coll_frames
),
1630 XGBE_STATS2_INFO(tx_mult_coll_frames
),
1631 XGBE_STATS2_INFO(tx_excessive_collisions
),
1632 XGBE_STATS2_INFO(tx_late_collisions
),
1633 XGBE_STATS2_INFO(tx_underrun
),
1634 XGBE_STATS2_INFO(tx_carrier_sense_errors
),
1635 XGBE_STATS2_INFO(tx_bytes
),
1636 XGBE_STATS2_INFO(tx_64byte_frames
),
1637 XGBE_STATS2_INFO(tx_65_to_127byte_frames
),
1638 XGBE_STATS2_INFO(tx_128_to_255byte_frames
),
1639 XGBE_STATS2_INFO(tx_256_to_511byte_frames
),
1640 XGBE_STATS2_INFO(tx_512_to_1023byte_frames
),
1641 XGBE_STATS2_INFO(tx_1024byte_frames
),
1642 XGBE_STATS2_INFO(net_bytes
),
1643 XGBE_STATS2_INFO(rx_sof_overruns
),
1644 XGBE_STATS2_INFO(rx_mof_overruns
),
1645 XGBE_STATS2_INFO(rx_dma_overruns
),
1648 #define for_each_intf(i, priv) \
1649 list_for_each_entry((i), &(priv)->gbe_intf_head, gbe_intf_list)
1651 #define for_each_sec_slave(slave, priv) \
1652 list_for_each_entry((slave), &(priv)->secondary_slaves, slave_list)
1654 #define first_sec_slave(priv) \
1655 list_first_entry(&priv->secondary_slaves, \
1656 struct gbe_slave, slave_list)
1658 static void keystone_get_drvinfo(struct net_device
*ndev
,
1659 struct ethtool_drvinfo
*info
)
1661 strncpy(info
->driver
, NETCP_DRIVER_NAME
, sizeof(info
->driver
));
1662 strncpy(info
->version
, NETCP_DRIVER_VERSION
, sizeof(info
->version
));
1665 static u32
keystone_get_msglevel(struct net_device
*ndev
)
1667 struct netcp_intf
*netcp
= netdev_priv(ndev
);
1669 return netcp
->msg_enable
;
1672 static void keystone_set_msglevel(struct net_device
*ndev
, u32 value
)
1674 struct netcp_intf
*netcp
= netdev_priv(ndev
);
1676 netcp
->msg_enable
= value
;
1679 static void keystone_get_stat_strings(struct net_device
*ndev
,
1680 uint32_t stringset
, uint8_t *data
)
1682 struct netcp_intf
*netcp
= netdev_priv(ndev
);
1683 struct gbe_intf
*gbe_intf
;
1684 struct gbe_priv
*gbe_dev
;
1687 gbe_intf
= netcp_module_get_intf_data(&gbe_module
, netcp
);
1690 gbe_dev
= gbe_intf
->gbe_dev
;
1692 switch (stringset
) {
1694 for (i
= 0; i
< gbe_dev
->num_et_stats
; i
++) {
1695 memcpy(data
, gbe_dev
->et_stats
[i
].desc
,
1697 data
+= ETH_GSTRING_LEN
;
1705 static int keystone_get_sset_count(struct net_device
*ndev
, int stringset
)
1707 struct netcp_intf
*netcp
= netdev_priv(ndev
);
1708 struct gbe_intf
*gbe_intf
;
1709 struct gbe_priv
*gbe_dev
;
1711 gbe_intf
= netcp_module_get_intf_data(&gbe_module
, netcp
);
1714 gbe_dev
= gbe_intf
->gbe_dev
;
1716 switch (stringset
) {
1720 return gbe_dev
->num_et_stats
;
1726 static void gbe_reset_mod_stats(struct gbe_priv
*gbe_dev
, int stats_mod
)
1728 void __iomem
*base
= gbe_dev
->hw_stats_regs
[stats_mod
];
1729 u32 __iomem
*p_stats_entry
;
1732 for (i
= 0; i
< gbe_dev
->num_et_stats
; i
++) {
1733 if (gbe_dev
->et_stats
[i
].type
== stats_mod
) {
1734 p_stats_entry
= base
+ gbe_dev
->et_stats
[i
].offset
;
1735 gbe_dev
->hw_stats
[i
] = 0;
1736 gbe_dev
->hw_stats_prev
[i
] = readl(p_stats_entry
);
1741 static inline void gbe_update_hw_stats_entry(struct gbe_priv
*gbe_dev
,
1744 void __iomem
*base
= NULL
;
1745 u32 __iomem
*p_stats_entry
;
1748 /* The hw_stats_regs pointers are already
1749 * properly set to point to the right base:
1751 base
= gbe_dev
->hw_stats_regs
[gbe_dev
->et_stats
[et_stats_entry
].type
];
1752 p_stats_entry
= base
+ gbe_dev
->et_stats
[et_stats_entry
].offset
;
1753 curr
= readl(p_stats_entry
);
1754 delta
= curr
- gbe_dev
->hw_stats_prev
[et_stats_entry
];
1755 gbe_dev
->hw_stats_prev
[et_stats_entry
] = curr
;
1756 gbe_dev
->hw_stats
[et_stats_entry
] += delta
;
1759 static void gbe_update_stats(struct gbe_priv
*gbe_dev
, uint64_t *data
)
1763 for (i
= 0; i
< gbe_dev
->num_et_stats
; i
++) {
1764 gbe_update_hw_stats_entry(gbe_dev
, i
);
1767 data
[i
] = gbe_dev
->hw_stats
[i
];
1771 static inline void gbe_stats_mod_visible_ver14(struct gbe_priv
*gbe_dev
,
1776 val
= readl(GBE_REG_ADDR(gbe_dev
, switch_regs
, stat_port_en
));
1778 switch (stats_mod
) {
1779 case GBE_STATSA_MODULE
:
1780 case GBE_STATSB_MODULE
:
1781 val
&= ~GBE_STATS_CD_SEL
;
1783 case GBE_STATSC_MODULE
:
1784 case GBE_STATSD_MODULE
:
1785 val
|= GBE_STATS_CD_SEL
;
1791 /* make the stat module visible */
1792 writel(val
, GBE_REG_ADDR(gbe_dev
, switch_regs
, stat_port_en
));
1795 static void gbe_reset_mod_stats_ver14(struct gbe_priv
*gbe_dev
, int stats_mod
)
1797 gbe_stats_mod_visible_ver14(gbe_dev
, stats_mod
);
1798 gbe_reset_mod_stats(gbe_dev
, stats_mod
);
1801 static void gbe_update_stats_ver14(struct gbe_priv
*gbe_dev
, uint64_t *data
)
1803 u32 half_num_et_stats
= (gbe_dev
->num_et_stats
/ 2);
1804 int et_entry
, j
, pair
;
1806 for (pair
= 0; pair
< 2; pair
++) {
1807 gbe_stats_mod_visible_ver14(gbe_dev
, (pair
?
1809 GBE_STATSA_MODULE
));
1811 for (j
= 0; j
< half_num_et_stats
; j
++) {
1812 et_entry
= pair
* half_num_et_stats
+ j
;
1813 gbe_update_hw_stats_entry(gbe_dev
, et_entry
);
1816 data
[et_entry
] = gbe_dev
->hw_stats
[et_entry
];
1821 static void keystone_get_ethtool_stats(struct net_device
*ndev
,
1822 struct ethtool_stats
*stats
,
1825 struct netcp_intf
*netcp
= netdev_priv(ndev
);
1826 struct gbe_intf
*gbe_intf
;
1827 struct gbe_priv
*gbe_dev
;
1829 gbe_intf
= netcp_module_get_intf_data(&gbe_module
, netcp
);
1833 gbe_dev
= gbe_intf
->gbe_dev
;
1834 spin_lock_bh(&gbe_dev
->hw_stats_lock
);
1835 if (gbe_dev
->ss_version
== GBE_SS_VERSION_14
)
1836 gbe_update_stats_ver14(gbe_dev
, data
);
1838 gbe_update_stats(gbe_dev
, data
);
1839 spin_unlock_bh(&gbe_dev
->hw_stats_lock
);
1842 static int keystone_get_settings(struct net_device
*ndev
,
1843 struct ethtool_cmd
*cmd
)
1845 struct netcp_intf
*netcp
= netdev_priv(ndev
);
1846 struct phy_device
*phy
= ndev
->phydev
;
1847 struct gbe_intf
*gbe_intf
;
1853 gbe_intf
= netcp_module_get_intf_data(&gbe_module
, netcp
);
1857 if (!gbe_intf
->slave
)
1860 ret
= phy_ethtool_gset(phy
, cmd
);
1862 cmd
->port
= gbe_intf
->slave
->phy_port_t
;
1867 static int keystone_set_settings(struct net_device
*ndev
,
1868 struct ethtool_cmd
*cmd
)
1870 struct netcp_intf
*netcp
= netdev_priv(ndev
);
1871 struct phy_device
*phy
= ndev
->phydev
;
1872 struct gbe_intf
*gbe_intf
;
1873 u32 features
= cmd
->advertising
& cmd
->supported
;
1878 gbe_intf
= netcp_module_get_intf_data(&gbe_module
, netcp
);
1882 if (!gbe_intf
->slave
)
1885 if (cmd
->port
!= gbe_intf
->slave
->phy_port_t
) {
1886 if ((cmd
->port
== PORT_TP
) && !(features
& ADVERTISED_TP
))
1889 if ((cmd
->port
== PORT_AUI
) && !(features
& ADVERTISED_AUI
))
1892 if ((cmd
->port
== PORT_BNC
) && !(features
& ADVERTISED_BNC
))
1895 if ((cmd
->port
== PORT_MII
) && !(features
& ADVERTISED_MII
))
1898 if ((cmd
->port
== PORT_FIBRE
) && !(features
& ADVERTISED_FIBRE
))
1902 gbe_intf
->slave
->phy_port_t
= cmd
->port
;
1903 return phy_ethtool_sset(phy
, cmd
);
1906 static const struct ethtool_ops keystone_ethtool_ops
= {
1907 .get_drvinfo
= keystone_get_drvinfo
,
1908 .get_link
= ethtool_op_get_link
,
1909 .get_msglevel
= keystone_get_msglevel
,
1910 .set_msglevel
= keystone_set_msglevel
,
1911 .get_strings
= keystone_get_stat_strings
,
1912 .get_sset_count
= keystone_get_sset_count
,
1913 .get_ethtool_stats
= keystone_get_ethtool_stats
,
1914 .get_settings
= keystone_get_settings
,
1915 .set_settings
= keystone_set_settings
,
1918 #define mac_hi(mac) (((mac)[0] << 0) | ((mac)[1] << 8) | \
1919 ((mac)[2] << 16) | ((mac)[3] << 24))
1920 #define mac_lo(mac) (((mac)[4] << 0) | ((mac)[5] << 8))
1922 static void gbe_set_slave_mac(struct gbe_slave
*slave
,
1923 struct gbe_intf
*gbe_intf
)
1925 struct net_device
*ndev
= gbe_intf
->ndev
;
1927 writel(mac_hi(ndev
->dev_addr
), GBE_REG_ADDR(slave
, port_regs
, sa_hi
));
1928 writel(mac_lo(ndev
->dev_addr
), GBE_REG_ADDR(slave
, port_regs
, sa_lo
));
1931 static int gbe_get_slave_port(struct gbe_priv
*priv
, u32 slave_num
)
1933 if (priv
->host_port
== 0)
1934 return slave_num
+ 1;
1939 static void netcp_ethss_link_state_action(struct gbe_priv
*gbe_dev
,
1940 struct net_device
*ndev
,
1941 struct gbe_slave
*slave
,
1944 struct phy_device
*phy
= slave
->phy
;
1945 u32 mac_control
= 0;
1948 mac_control
= slave
->mac_control
;
1949 if (phy
&& (phy
->speed
== SPEED_1000
)) {
1950 mac_control
|= MACSL_GIG_MODE
;
1951 mac_control
&= ~MACSL_XGIG_MODE
;
1952 } else if (phy
&& (phy
->speed
== SPEED_10000
)) {
1953 mac_control
|= MACSL_XGIG_MODE
;
1954 mac_control
&= ~MACSL_GIG_MODE
;
1957 writel(mac_control
, GBE_REG_ADDR(slave
, emac_regs
,
1960 cpsw_ale_control_set(gbe_dev
->ale
, slave
->port_num
,
1962 ALE_PORT_STATE_FORWARD
);
1964 if (ndev
&& slave
->open
&&
1965 slave
->link_interface
!= SGMII_LINK_MAC_PHY
&&
1966 slave
->link_interface
!= XGMII_LINK_MAC_PHY
)
1967 netif_carrier_on(ndev
);
1969 writel(mac_control
, GBE_REG_ADDR(slave
, emac_regs
,
1971 cpsw_ale_control_set(gbe_dev
->ale
, slave
->port_num
,
1973 ALE_PORT_STATE_DISABLE
);
1975 slave
->link_interface
!= SGMII_LINK_MAC_PHY
&&
1976 slave
->link_interface
!= XGMII_LINK_MAC_PHY
)
1977 netif_carrier_off(ndev
);
1981 phy_print_status(phy
);
1984 static bool gbe_phy_link_status(struct gbe_slave
*slave
)
1986 return !slave
->phy
|| slave
->phy
->link
;
1989 static void netcp_ethss_update_link_state(struct gbe_priv
*gbe_dev
,
1990 struct gbe_slave
*slave
,
1991 struct net_device
*ndev
)
1993 int sp
= slave
->slave_num
;
1994 int phy_link_state
, sgmii_link_state
= 1, link_state
;
1999 if (!SLAVE_LINK_IS_XGMII(slave
)) {
2000 if (gbe_dev
->ss_version
== GBE_SS_VERSION_14
)
2002 netcp_sgmii_get_port_link(SGMII_BASE(sp
), sp
);
2005 netcp_sgmii_get_port_link(
2006 gbe_dev
->sgmii_port_regs
, sp
);
2009 phy_link_state
= gbe_phy_link_status(slave
);
2010 link_state
= phy_link_state
& sgmii_link_state
;
2012 if (atomic_xchg(&slave
->link_state
, link_state
) != link_state
)
2013 netcp_ethss_link_state_action(gbe_dev
, ndev
, slave
,
2017 static void xgbe_adjust_link(struct net_device
*ndev
)
2019 struct netcp_intf
*netcp
= netdev_priv(ndev
);
2020 struct gbe_intf
*gbe_intf
;
2022 gbe_intf
= netcp_module_get_intf_data(&xgbe_module
, netcp
);
2026 netcp_ethss_update_link_state(gbe_intf
->gbe_dev
, gbe_intf
->slave
,
2030 static void gbe_adjust_link(struct net_device
*ndev
)
2032 struct netcp_intf
*netcp
= netdev_priv(ndev
);
2033 struct gbe_intf
*gbe_intf
;
2035 gbe_intf
= netcp_module_get_intf_data(&gbe_module
, netcp
);
2039 netcp_ethss_update_link_state(gbe_intf
->gbe_dev
, gbe_intf
->slave
,
2043 static void gbe_adjust_link_sec_slaves(struct net_device
*ndev
)
2045 struct gbe_priv
*gbe_dev
= netdev_priv(ndev
);
2046 struct gbe_slave
*slave
;
2048 for_each_sec_slave(slave
, gbe_dev
)
2049 netcp_ethss_update_link_state(gbe_dev
, slave
, NULL
);
2053 * Soft reset is set and polled until clear, or until a timeout occurs
2055 static int gbe_port_reset(struct gbe_slave
*slave
)
2059 /* Set the soft reset bit */
2060 writel(SOFT_RESET
, GBE_REG_ADDR(slave
, emac_regs
, soft_reset
));
2062 /* Wait for the bit to clear */
2063 for (i
= 0; i
< DEVICE_EMACSL_RESET_POLL_COUNT
; i
++) {
2064 v
= readl(GBE_REG_ADDR(slave
, emac_regs
, soft_reset
));
2065 if ((v
& SOFT_RESET_MASK
) != SOFT_RESET
)
2069 /* Timeout on the reset */
2070 return GMACSL_RET_WARN_RESET_INCOMPLETE
;
2073 /* Configure EMAC */
2074 static void gbe_port_config(struct gbe_priv
*gbe_dev
, struct gbe_slave
*slave
,
2077 void __iomem
*rx_maxlen_reg
;
2080 if (max_rx_len
> NETCP_MAX_FRAME_SIZE
)
2081 max_rx_len
= NETCP_MAX_FRAME_SIZE
;
2083 /* Enable correct MII mode at SS level */
2084 if ((gbe_dev
->ss_version
== XGBE_SS_VERSION_10
) &&
2085 (slave
->link_interface
>= XGMII_LINK_MAC_PHY
)) {
2086 xgmii_mode
= readl(GBE_REG_ADDR(gbe_dev
, ss_regs
, control
));
2087 xgmii_mode
|= (1 << slave
->slave_num
);
2088 writel(xgmii_mode
, GBE_REG_ADDR(gbe_dev
, ss_regs
, control
));
2091 if (IS_SS_ID_MU(gbe_dev
))
2092 rx_maxlen_reg
= GBE_REG_ADDR(slave
, port_regs
, rx_maxlen
);
2094 rx_maxlen_reg
= GBE_REG_ADDR(slave
, emac_regs
, rx_maxlen
);
2096 writel(max_rx_len
, rx_maxlen_reg
);
2097 writel(slave
->mac_control
, GBE_REG_ADDR(slave
, emac_regs
, mac_control
));
2100 static void gbe_sgmii_rtreset(struct gbe_priv
*priv
,
2101 struct gbe_slave
*slave
, bool set
)
2103 void __iomem
*sgmii_port_regs
;
2105 if (SLAVE_LINK_IS_XGMII(slave
))
2108 if ((priv
->ss_version
== GBE_SS_VERSION_14
) && (slave
->slave_num
>= 2))
2109 sgmii_port_regs
= priv
->sgmii_port34_regs
;
2111 sgmii_port_regs
= priv
->sgmii_port_regs
;
2113 netcp_sgmii_rtreset(sgmii_port_regs
, slave
->slave_num
, set
);
2116 static void gbe_slave_stop(struct gbe_intf
*intf
)
2118 struct gbe_priv
*gbe_dev
= intf
->gbe_dev
;
2119 struct gbe_slave
*slave
= intf
->slave
;
2121 gbe_sgmii_rtreset(gbe_dev
, slave
, true);
2122 gbe_port_reset(slave
);
2123 /* Disable forwarding */
2124 cpsw_ale_control_set(gbe_dev
->ale
, slave
->port_num
,
2125 ALE_PORT_STATE
, ALE_PORT_STATE_DISABLE
);
2126 cpsw_ale_del_mcast(gbe_dev
->ale
, intf
->ndev
->broadcast
,
2127 1 << slave
->port_num
, 0, 0);
2132 phy_stop(slave
->phy
);
2133 phy_disconnect(slave
->phy
);
2137 static void gbe_sgmii_config(struct gbe_priv
*priv
, struct gbe_slave
*slave
)
2139 void __iomem
*sgmii_port_regs
;
2141 sgmii_port_regs
= priv
->sgmii_port_regs
;
2142 if ((priv
->ss_version
== GBE_SS_VERSION_14
) && (slave
->slave_num
>= 2))
2143 sgmii_port_regs
= priv
->sgmii_port34_regs
;
2145 if (!SLAVE_LINK_IS_XGMII(slave
)) {
2146 netcp_sgmii_reset(sgmii_port_regs
, slave
->slave_num
);
2147 netcp_sgmii_config(sgmii_port_regs
, slave
->slave_num
,
2148 slave
->link_interface
);
2152 static int gbe_slave_open(struct gbe_intf
*gbe_intf
)
2154 struct gbe_priv
*priv
= gbe_intf
->gbe_dev
;
2155 struct gbe_slave
*slave
= gbe_intf
->slave
;
2156 phy_interface_t phy_mode
;
2157 bool has_phy
= false;
2159 void (*hndlr
)(struct net_device
*) = gbe_adjust_link
;
2161 gbe_sgmii_config(priv
, slave
);
2162 gbe_port_reset(slave
);
2163 gbe_sgmii_rtreset(priv
, slave
, false);
2164 gbe_port_config(priv
, slave
, priv
->rx_packet_max
);
2165 gbe_set_slave_mac(slave
, gbe_intf
);
2166 /* enable forwarding */
2167 cpsw_ale_control_set(priv
->ale
, slave
->port_num
,
2168 ALE_PORT_STATE
, ALE_PORT_STATE_FORWARD
);
2169 cpsw_ale_add_mcast(priv
->ale
, gbe_intf
->ndev
->broadcast
,
2170 1 << slave
->port_num
, 0, 0, ALE_MCAST_FWD_2
);
2172 if (slave
->link_interface
== SGMII_LINK_MAC_PHY
) {
2174 phy_mode
= PHY_INTERFACE_MODE_SGMII
;
2175 slave
->phy_port_t
= PORT_MII
;
2176 } else if (slave
->link_interface
== XGMII_LINK_MAC_PHY
) {
2178 phy_mode
= PHY_INTERFACE_MODE_NA
;
2179 slave
->phy_port_t
= PORT_FIBRE
;
2183 if (priv
->ss_version
== XGBE_SS_VERSION_10
)
2184 hndlr
= xgbe_adjust_link
;
2186 slave
->phy
= of_phy_connect(gbe_intf
->ndev
,
2191 dev_err(priv
->dev
, "phy not found on slave %d\n",
2195 dev_dbg(priv
->dev
, "phy found: id is: 0x%s\n",
2196 dev_name(&slave
->phy
->dev
));
2197 phy_start(slave
->phy
);
2198 phy_read_status(slave
->phy
);
2203 static void gbe_init_host_port(struct gbe_priv
*priv
)
2208 if (IS_SS_ID_NU(priv
))
2209 writel(HOST_TX_PRI_MAP_DEFAULT
,
2210 GBE_REG_ADDR(priv
, host_port_regs
, tx_pri_map
));
2212 /* Max length register */
2213 writel(NETCP_MAX_FRAME_SIZE
, GBE_REG_ADDR(priv
, host_port_regs
,
2216 cpsw_ale_start(priv
->ale
);
2218 if (priv
->enable_ale
)
2221 cpsw_ale_control_set(priv
->ale
, 0, ALE_BYPASS
, bypass_en
);
2223 cpsw_ale_control_set(priv
->ale
, 0, ALE_NO_PORT_VLAN
, 1);
2225 cpsw_ale_control_set(priv
->ale
, priv
->host_port
,
2226 ALE_PORT_STATE
, ALE_PORT_STATE_FORWARD
);
2228 cpsw_ale_control_set(priv
->ale
, 0,
2229 ALE_PORT_UNKNOWN_VLAN_MEMBER
,
2230 GBE_PORT_MASK(priv
->ale_ports
));
2232 cpsw_ale_control_set(priv
->ale
, 0,
2233 ALE_PORT_UNKNOWN_MCAST_FLOOD
,
2234 GBE_PORT_MASK(priv
->ale_ports
- 1));
2236 cpsw_ale_control_set(priv
->ale
, 0,
2237 ALE_PORT_UNKNOWN_REG_MCAST_FLOOD
,
2238 GBE_PORT_MASK(priv
->ale_ports
));
2240 cpsw_ale_control_set(priv
->ale
, 0,
2241 ALE_PORT_UNTAGGED_EGRESS
,
2242 GBE_PORT_MASK(priv
->ale_ports
));
2245 static void gbe_add_mcast_addr(struct gbe_intf
*gbe_intf
, u8
*addr
)
2247 struct gbe_priv
*gbe_dev
= gbe_intf
->gbe_dev
;
2250 cpsw_ale_add_mcast(gbe_dev
->ale
, addr
,
2251 GBE_PORT_MASK(gbe_dev
->ale_ports
), 0, 0,
2253 for_each_set_bit(vlan_id
, gbe_intf
->active_vlans
, VLAN_N_VID
) {
2254 cpsw_ale_add_mcast(gbe_dev
->ale
, addr
,
2255 GBE_PORT_MASK(gbe_dev
->ale_ports
),
2256 ALE_VLAN
, vlan_id
, ALE_MCAST_FWD_2
);
2260 static void gbe_add_ucast_addr(struct gbe_intf
*gbe_intf
, u8
*addr
)
2262 struct gbe_priv
*gbe_dev
= gbe_intf
->gbe_dev
;
2265 cpsw_ale_add_ucast(gbe_dev
->ale
, addr
, gbe_dev
->host_port
, 0, 0);
2267 for_each_set_bit(vlan_id
, gbe_intf
->active_vlans
, VLAN_N_VID
)
2268 cpsw_ale_add_ucast(gbe_dev
->ale
, addr
, gbe_dev
->host_port
,
2272 static void gbe_del_mcast_addr(struct gbe_intf
*gbe_intf
, u8
*addr
)
2274 struct gbe_priv
*gbe_dev
= gbe_intf
->gbe_dev
;
2277 cpsw_ale_del_mcast(gbe_dev
->ale
, addr
, 0, 0, 0);
2279 for_each_set_bit(vlan_id
, gbe_intf
->active_vlans
, VLAN_N_VID
) {
2280 cpsw_ale_del_mcast(gbe_dev
->ale
, addr
, 0, ALE_VLAN
, vlan_id
);
2284 static void gbe_del_ucast_addr(struct gbe_intf
*gbe_intf
, u8
*addr
)
2286 struct gbe_priv
*gbe_dev
= gbe_intf
->gbe_dev
;
2289 cpsw_ale_del_ucast(gbe_dev
->ale
, addr
, gbe_dev
->host_port
, 0, 0);
2291 for_each_set_bit(vlan_id
, gbe_intf
->active_vlans
, VLAN_N_VID
) {
2292 cpsw_ale_del_ucast(gbe_dev
->ale
, addr
, gbe_dev
->host_port
,
2297 static int gbe_add_addr(void *intf_priv
, struct netcp_addr
*naddr
)
2299 struct gbe_intf
*gbe_intf
= intf_priv
;
2300 struct gbe_priv
*gbe_dev
= gbe_intf
->gbe_dev
;
2302 dev_dbg(gbe_dev
->dev
, "ethss adding address %pM, type %d\n",
2303 naddr
->addr
, naddr
->type
);
2305 switch (naddr
->type
) {
2308 gbe_add_mcast_addr(gbe_intf
, naddr
->addr
);
2312 gbe_add_ucast_addr(gbe_intf
, naddr
->addr
);
2315 /* nothing to do for promiscuous */
2323 static int gbe_del_addr(void *intf_priv
, struct netcp_addr
*naddr
)
2325 struct gbe_intf
*gbe_intf
= intf_priv
;
2326 struct gbe_priv
*gbe_dev
= gbe_intf
->gbe_dev
;
2328 dev_dbg(gbe_dev
->dev
, "ethss deleting address %pM, type %d\n",
2329 naddr
->addr
, naddr
->type
);
2331 switch (naddr
->type
) {
2334 gbe_del_mcast_addr(gbe_intf
, naddr
->addr
);
2338 gbe_del_ucast_addr(gbe_intf
, naddr
->addr
);
2341 /* nothing to do for promiscuous */
2349 static int gbe_add_vid(void *intf_priv
, int vid
)
2351 struct gbe_intf
*gbe_intf
= intf_priv
;
2352 struct gbe_priv
*gbe_dev
= gbe_intf
->gbe_dev
;
2354 set_bit(vid
, gbe_intf
->active_vlans
);
2356 cpsw_ale_add_vlan(gbe_dev
->ale
, vid
,
2357 GBE_PORT_MASK(gbe_dev
->ale_ports
),
2359 GBE_PORT_MASK(gbe_dev
->ale_ports
),
2360 GBE_PORT_MASK(gbe_dev
->ale_ports
- 1));
2365 static int gbe_del_vid(void *intf_priv
, int vid
)
2367 struct gbe_intf
*gbe_intf
= intf_priv
;
2368 struct gbe_priv
*gbe_dev
= gbe_intf
->gbe_dev
;
2370 cpsw_ale_del_vlan(gbe_dev
->ale
, vid
, 0);
2371 clear_bit(vid
, gbe_intf
->active_vlans
);
2375 static int gbe_ioctl(void *intf_priv
, struct ifreq
*req
, int cmd
)
2377 struct gbe_intf
*gbe_intf
= intf_priv
;
2378 struct phy_device
*phy
= gbe_intf
->slave
->phy
;
2379 int ret
= -EOPNOTSUPP
;
2382 ret
= phy_mii_ioctl(phy
, req
, cmd
);
2387 static void netcp_ethss_timer(unsigned long arg
)
2389 struct gbe_priv
*gbe_dev
= (struct gbe_priv
*)arg
;
2390 struct gbe_intf
*gbe_intf
;
2391 struct gbe_slave
*slave
;
2393 /* Check & update SGMII link state of interfaces */
2394 for_each_intf(gbe_intf
, gbe_dev
) {
2395 if (!gbe_intf
->slave
->open
)
2397 netcp_ethss_update_link_state(gbe_dev
, gbe_intf
->slave
,
2401 /* Check & update SGMII link state of secondary ports */
2402 for_each_sec_slave(slave
, gbe_dev
) {
2403 netcp_ethss_update_link_state(gbe_dev
, slave
, NULL
);
2406 /* A timer runs as a BH, no need to block them */
2407 spin_lock(&gbe_dev
->hw_stats_lock
);
2409 if (gbe_dev
->ss_version
== GBE_SS_VERSION_14
)
2410 gbe_update_stats_ver14(gbe_dev
, NULL
);
2412 gbe_update_stats(gbe_dev
, NULL
);
2414 spin_unlock(&gbe_dev
->hw_stats_lock
);
2416 gbe_dev
->timer
.expires
= jiffies
+ GBE_TIMER_INTERVAL
;
2417 add_timer(&gbe_dev
->timer
);
2420 static int gbe_tx_hook(int order
, void *data
, struct netcp_packet
*p_info
)
2422 struct gbe_intf
*gbe_intf
= data
;
2424 p_info
->tx_pipe
= &gbe_intf
->tx_pipe
;
2428 static int gbe_open(void *intf_priv
, struct net_device
*ndev
)
2430 struct gbe_intf
*gbe_intf
= intf_priv
;
2431 struct gbe_priv
*gbe_dev
= gbe_intf
->gbe_dev
;
2432 struct netcp_intf
*netcp
= netdev_priv(ndev
);
2433 struct gbe_slave
*slave
= gbe_intf
->slave
;
2434 int port_num
= slave
->port_num
;
2438 reg
= readl(GBE_REG_ADDR(gbe_dev
, switch_regs
, id_ver
));
2439 dev_dbg(gbe_dev
->dev
, "initializing gbe version %d.%d (%d) GBE identification value 0x%x\n",
2440 GBE_MAJOR_VERSION(reg
), GBE_MINOR_VERSION(reg
),
2441 GBE_RTL_VERSION(reg
), GBE_IDENT(reg
));
2443 /* For 10G and on NetCP 1.5, use directed to port */
2444 if ((gbe_dev
->ss_version
== XGBE_SS_VERSION_10
) || IS_SS_ID_MU(gbe_dev
))
2445 gbe_intf
->tx_pipe
.flags
= SWITCH_TO_PORT_IN_TAGINFO
;
2447 if (gbe_dev
->enable_ale
)
2448 gbe_intf
->tx_pipe
.switch_to_port
= 0;
2450 gbe_intf
->tx_pipe
.switch_to_port
= port_num
;
2452 dev_dbg(gbe_dev
->dev
,
2453 "opened TX channel %s: %p with to port %d, flags %d\n",
2454 gbe_intf
->tx_pipe
.dma_chan_name
,
2455 gbe_intf
->tx_pipe
.dma_channel
,
2456 gbe_intf
->tx_pipe
.switch_to_port
,
2457 gbe_intf
->tx_pipe
.flags
);
2459 gbe_slave_stop(gbe_intf
);
2461 /* disable priority elevation and enable statistics on all ports */
2462 writel(0, GBE_REG_ADDR(gbe_dev
, switch_regs
, ptype
));
2464 /* Control register */
2465 writel(GBE_CTL_P0_ENABLE
, GBE_REG_ADDR(gbe_dev
, switch_regs
, control
));
2467 /* All statistics enabled and STAT AB visible by default */
2468 writel(gbe_dev
->stats_en_mask
, GBE_REG_ADDR(gbe_dev
, switch_regs
,
2471 ret
= gbe_slave_open(gbe_intf
);
2475 netcp_register_txhook(netcp
, GBE_TXHOOK_ORDER
, gbe_tx_hook
,
2479 netcp_ethss_update_link_state(gbe_dev
, slave
, ndev
);
2483 gbe_slave_stop(gbe_intf
);
2487 static int gbe_close(void *intf_priv
, struct net_device
*ndev
)
2489 struct gbe_intf
*gbe_intf
= intf_priv
;
2490 struct netcp_intf
*netcp
= netdev_priv(ndev
);
2492 gbe_slave_stop(gbe_intf
);
2493 netcp_unregister_txhook(netcp
, GBE_TXHOOK_ORDER
, gbe_tx_hook
,
2496 gbe_intf
->slave
->open
= false;
2497 atomic_set(&gbe_intf
->slave
->link_state
, NETCP_LINK_STATE_INVALID
);
2501 static int init_slave(struct gbe_priv
*gbe_dev
, struct gbe_slave
*slave
,
2502 struct device_node
*node
)
2505 u32 port_reg_ofs
, emac_reg_ofs
;
2506 u32 port_reg_blk_sz
, emac_reg_blk_sz
;
2508 if (of_property_read_u32(node
, "slave-port", &slave
->slave_num
)) {
2509 dev_err(gbe_dev
->dev
, "missing slave-port parameter\n");
2513 if (of_property_read_u32(node
, "link-interface",
2514 &slave
->link_interface
)) {
2515 dev_warn(gbe_dev
->dev
,
2516 "missing link-interface value defaulting to 1G mac-phy link\n");
2517 slave
->link_interface
= SGMII_LINK_MAC_PHY
;
2520 slave
->open
= false;
2521 slave
->phy_node
= of_parse_phandle(node
, "phy-handle", 0);
2522 slave
->port_num
= gbe_get_slave_port(gbe_dev
, slave
->slave_num
);
2524 if (slave
->link_interface
>= XGMII_LINK_MAC_PHY
)
2525 slave
->mac_control
= GBE_DEF_10G_MAC_CONTROL
;
2527 slave
->mac_control
= GBE_DEF_1G_MAC_CONTROL
;
2529 /* Emac regs memmap are contiguous but port regs are not */
2530 port_reg_num
= slave
->slave_num
;
2531 if (gbe_dev
->ss_version
== GBE_SS_VERSION_14
) {
2532 if (slave
->slave_num
> 1) {
2533 port_reg_ofs
= GBE13_SLAVE_PORT2_OFFSET
;
2536 port_reg_ofs
= GBE13_SLAVE_PORT_OFFSET
;
2538 emac_reg_ofs
= GBE13_EMAC_OFFSET
;
2539 port_reg_blk_sz
= 0x30;
2540 emac_reg_blk_sz
= 0x40;
2541 } else if (IS_SS_ID_MU(gbe_dev
)) {
2542 port_reg_ofs
= GBENU_SLAVE_PORT_OFFSET
;
2543 emac_reg_ofs
= GBENU_EMAC_OFFSET
;
2544 port_reg_blk_sz
= 0x1000;
2545 emac_reg_blk_sz
= 0x1000;
2546 } else if (gbe_dev
->ss_version
== XGBE_SS_VERSION_10
) {
2547 port_reg_ofs
= XGBE10_SLAVE_PORT_OFFSET
;
2548 emac_reg_ofs
= XGBE10_EMAC_OFFSET
;
2549 port_reg_blk_sz
= 0x30;
2550 emac_reg_blk_sz
= 0x40;
2552 dev_err(gbe_dev
->dev
, "unknown ethss(0x%x)\n",
2553 gbe_dev
->ss_version
);
2557 slave
->port_regs
= gbe_dev
->switch_regs
+ port_reg_ofs
+
2558 (port_reg_blk_sz
* port_reg_num
);
2559 slave
->emac_regs
= gbe_dev
->switch_regs
+ emac_reg_ofs
+
2560 (emac_reg_blk_sz
* slave
->slave_num
);
2562 if (gbe_dev
->ss_version
== GBE_SS_VERSION_14
) {
2563 /* Initialize slave port register offsets */
2564 GBE_SET_REG_OFS(slave
, port_regs
, port_vlan
);
2565 GBE_SET_REG_OFS(slave
, port_regs
, tx_pri_map
);
2566 GBE_SET_REG_OFS(slave
, port_regs
, sa_lo
);
2567 GBE_SET_REG_OFS(slave
, port_regs
, sa_hi
);
2568 GBE_SET_REG_OFS(slave
, port_regs
, ts_ctl
);
2569 GBE_SET_REG_OFS(slave
, port_regs
, ts_seq_ltype
);
2570 GBE_SET_REG_OFS(slave
, port_regs
, ts_vlan
);
2571 GBE_SET_REG_OFS(slave
, port_regs
, ts_ctl_ltype2
);
2572 GBE_SET_REG_OFS(slave
, port_regs
, ts_ctl2
);
2574 /* Initialize EMAC register offsets */
2575 GBE_SET_REG_OFS(slave
, emac_regs
, mac_control
);
2576 GBE_SET_REG_OFS(slave
, emac_regs
, soft_reset
);
2577 GBE_SET_REG_OFS(slave
, emac_regs
, rx_maxlen
);
2579 } else if (IS_SS_ID_MU(gbe_dev
)) {
2580 /* Initialize slave port register offsets */
2581 GBENU_SET_REG_OFS(slave
, port_regs
, port_vlan
);
2582 GBENU_SET_REG_OFS(slave
, port_regs
, tx_pri_map
);
2583 GBENU_SET_REG_OFS(slave
, port_regs
, sa_lo
);
2584 GBENU_SET_REG_OFS(slave
, port_regs
, sa_hi
);
2585 GBENU_SET_REG_OFS(slave
, port_regs
, ts_ctl
);
2586 GBENU_SET_REG_OFS(slave
, port_regs
, ts_seq_ltype
);
2587 GBENU_SET_REG_OFS(slave
, port_regs
, ts_vlan
);
2588 GBENU_SET_REG_OFS(slave
, port_regs
, ts_ctl_ltype2
);
2589 GBENU_SET_REG_OFS(slave
, port_regs
, ts_ctl2
);
2590 GBENU_SET_REG_OFS(slave
, port_regs
, rx_maxlen
);
2592 /* Initialize EMAC register offsets */
2593 GBENU_SET_REG_OFS(slave
, emac_regs
, mac_control
);
2594 GBENU_SET_REG_OFS(slave
, emac_regs
, soft_reset
);
2596 } else if (gbe_dev
->ss_version
== XGBE_SS_VERSION_10
) {
2597 /* Initialize slave port register offsets */
2598 XGBE_SET_REG_OFS(slave
, port_regs
, port_vlan
);
2599 XGBE_SET_REG_OFS(slave
, port_regs
, tx_pri_map
);
2600 XGBE_SET_REG_OFS(slave
, port_regs
, sa_lo
);
2601 XGBE_SET_REG_OFS(slave
, port_regs
, sa_hi
);
2602 XGBE_SET_REG_OFS(slave
, port_regs
, ts_ctl
);
2603 XGBE_SET_REG_OFS(slave
, port_regs
, ts_seq_ltype
);
2604 XGBE_SET_REG_OFS(slave
, port_regs
, ts_vlan
);
2605 XGBE_SET_REG_OFS(slave
, port_regs
, ts_ctl_ltype2
);
2606 XGBE_SET_REG_OFS(slave
, port_regs
, ts_ctl2
);
2608 /* Initialize EMAC register offsets */
2609 XGBE_SET_REG_OFS(slave
, emac_regs
, mac_control
);
2610 XGBE_SET_REG_OFS(slave
, emac_regs
, soft_reset
);
2611 XGBE_SET_REG_OFS(slave
, emac_regs
, rx_maxlen
);
2614 atomic_set(&slave
->link_state
, NETCP_LINK_STATE_INVALID
);
2618 static void init_secondary_ports(struct gbe_priv
*gbe_dev
,
2619 struct device_node
*node
)
2621 struct device
*dev
= gbe_dev
->dev
;
2622 phy_interface_t phy_mode
;
2623 struct gbe_priv
**priv
;
2624 struct device_node
*port
;
2625 struct gbe_slave
*slave
;
2626 bool mac_phy_link
= false;
2628 for_each_child_of_node(node
, port
) {
2629 slave
= devm_kzalloc(dev
, sizeof(*slave
), GFP_KERNEL
);
2632 "memomry alloc failed for secondary port(%s), skipping...\n",
2637 if (init_slave(gbe_dev
, slave
, port
)) {
2639 "Failed to initialize secondary port(%s), skipping...\n",
2641 devm_kfree(dev
, slave
);
2645 gbe_sgmii_config(gbe_dev
, slave
);
2646 gbe_port_reset(slave
);
2647 gbe_port_config(gbe_dev
, slave
, gbe_dev
->rx_packet_max
);
2648 list_add_tail(&slave
->slave_list
, &gbe_dev
->secondary_slaves
);
2649 gbe_dev
->num_slaves
++;
2650 if ((slave
->link_interface
== SGMII_LINK_MAC_PHY
) ||
2651 (slave
->link_interface
== XGMII_LINK_MAC_PHY
))
2652 mac_phy_link
= true;
2655 if (gbe_dev
->num_slaves
>= gbe_dev
->max_num_slaves
)
2659 /* of_phy_connect() is needed only for MAC-PHY interface */
2663 /* Allocate dummy netdev device for attaching to phy device */
2664 gbe_dev
->dummy_ndev
= alloc_netdev(sizeof(gbe_dev
), "dummy",
2665 NET_NAME_UNKNOWN
, ether_setup
);
2666 if (!gbe_dev
->dummy_ndev
) {
2668 "Failed to allocate dummy netdev for secondary ports, skipping phy_connect()...\n");
2671 priv
= netdev_priv(gbe_dev
->dummy_ndev
);
2674 if (slave
->link_interface
== SGMII_LINK_MAC_PHY
) {
2675 phy_mode
= PHY_INTERFACE_MODE_SGMII
;
2676 slave
->phy_port_t
= PORT_MII
;
2678 phy_mode
= PHY_INTERFACE_MODE_NA
;
2679 slave
->phy_port_t
= PORT_FIBRE
;
2682 for_each_sec_slave(slave
, gbe_dev
) {
2683 if ((slave
->link_interface
!= SGMII_LINK_MAC_PHY
) &&
2684 (slave
->link_interface
!= XGMII_LINK_MAC_PHY
))
2687 of_phy_connect(gbe_dev
->dummy_ndev
,
2689 gbe_adjust_link_sec_slaves
,
2692 dev_err(dev
, "phy not found for slave %d\n",
2696 dev_dbg(dev
, "phy found: id is: 0x%s\n",
2697 dev_name(&slave
->phy
->dev
));
2698 phy_start(slave
->phy
);
2699 phy_read_status(slave
->phy
);
2704 static void free_secondary_ports(struct gbe_priv
*gbe_dev
)
2706 struct gbe_slave
*slave
;
2708 while (!list_empty(&gbe_dev
->secondary_slaves
)) {
2709 slave
= first_sec_slave(gbe_dev
);
2712 phy_disconnect(slave
->phy
);
2713 list_del(&slave
->slave_list
);
2715 if (gbe_dev
->dummy_ndev
)
2716 free_netdev(gbe_dev
->dummy_ndev
);
2719 static int set_xgbe_ethss10_priv(struct gbe_priv
*gbe_dev
,
2720 struct device_node
*node
)
2722 struct resource res
;
2726 ret
= of_address_to_resource(node
, XGBE_SS_REG_INDEX
, &res
);
2728 dev_err(gbe_dev
->dev
,
2729 "Can't xlate xgbe of node(%s) ss address at %d\n",
2730 node
->name
, XGBE_SS_REG_INDEX
);
2734 regs
= devm_ioremap_resource(gbe_dev
->dev
, &res
);
2736 dev_err(gbe_dev
->dev
, "Failed to map xgbe ss register base\n");
2737 return PTR_ERR(regs
);
2739 gbe_dev
->ss_regs
= regs
;
2741 ret
= of_address_to_resource(node
, XGBE_SM_REG_INDEX
, &res
);
2743 dev_err(gbe_dev
->dev
,
2744 "Can't xlate xgbe of node(%s) sm address at %d\n",
2745 node
->name
, XGBE_SM_REG_INDEX
);
2749 regs
= devm_ioremap_resource(gbe_dev
->dev
, &res
);
2751 dev_err(gbe_dev
->dev
, "Failed to map xgbe sm register base\n");
2752 return PTR_ERR(regs
);
2754 gbe_dev
->switch_regs
= regs
;
2756 ret
= of_address_to_resource(node
, XGBE_SERDES_REG_INDEX
, &res
);
2758 dev_err(gbe_dev
->dev
,
2759 "Can't xlate xgbe serdes of node(%s) address at %d\n",
2760 node
->name
, XGBE_SERDES_REG_INDEX
);
2764 regs
= devm_ioremap_resource(gbe_dev
->dev
, &res
);
2766 dev_err(gbe_dev
->dev
, "Failed to map xgbe serdes register base\n");
2767 return PTR_ERR(regs
);
2769 gbe_dev
->xgbe_serdes_regs
= regs
;
2771 gbe_dev
->num_stats_mods
= gbe_dev
->max_num_ports
;
2772 gbe_dev
->et_stats
= xgbe10_et_stats
;
2773 gbe_dev
->num_et_stats
= ARRAY_SIZE(xgbe10_et_stats
);
2775 gbe_dev
->hw_stats
= devm_kzalloc(gbe_dev
->dev
,
2776 gbe_dev
->num_et_stats
* sizeof(u64
),
2778 if (!gbe_dev
->hw_stats
) {
2779 dev_err(gbe_dev
->dev
, "hw_stats memory allocation failed\n");
2783 gbe_dev
->hw_stats_prev
=
2784 devm_kzalloc(gbe_dev
->dev
,
2785 gbe_dev
->num_et_stats
* sizeof(u32
),
2787 if (!gbe_dev
->hw_stats_prev
) {
2788 dev_err(gbe_dev
->dev
,
2789 "hw_stats_prev memory allocation failed\n");
2793 gbe_dev
->ss_version
= XGBE_SS_VERSION_10
;
2794 gbe_dev
->sgmii_port_regs
= gbe_dev
->ss_regs
+
2795 XGBE10_SGMII_MODULE_OFFSET
;
2796 gbe_dev
->host_port_regs
= gbe_dev
->ss_regs
+ XGBE10_HOST_PORT_OFFSET
;
2798 for (i
= 0; i
< gbe_dev
->max_num_ports
; i
++)
2799 gbe_dev
->hw_stats_regs
[i
] = gbe_dev
->switch_regs
+
2800 XGBE10_HW_STATS_OFFSET
+ (GBE_HW_STATS_REG_MAP_SZ
* i
);
2802 gbe_dev
->ale_reg
= gbe_dev
->switch_regs
+ XGBE10_ALE_OFFSET
;
2803 gbe_dev
->ale_ports
= gbe_dev
->max_num_ports
;
2804 gbe_dev
->host_port
= XGBE10_HOST_PORT_NUM
;
2805 gbe_dev
->ale_entries
= XGBE10_NUM_ALE_ENTRIES
;
2806 gbe_dev
->stats_en_mask
= (1 << (gbe_dev
->max_num_ports
)) - 1;
2808 /* Subsystem registers */
2809 XGBE_SET_REG_OFS(gbe_dev
, ss_regs
, id_ver
);
2810 XGBE_SET_REG_OFS(gbe_dev
, ss_regs
, control
);
2812 /* Switch module registers */
2813 XGBE_SET_REG_OFS(gbe_dev
, switch_regs
, id_ver
);
2814 XGBE_SET_REG_OFS(gbe_dev
, switch_regs
, control
);
2815 XGBE_SET_REG_OFS(gbe_dev
, switch_regs
, ptype
);
2816 XGBE_SET_REG_OFS(gbe_dev
, switch_regs
, stat_port_en
);
2817 XGBE_SET_REG_OFS(gbe_dev
, switch_regs
, flow_control
);
2819 /* Host port registers */
2820 XGBE_SET_REG_OFS(gbe_dev
, host_port_regs
, port_vlan
);
2821 XGBE_SET_REG_OFS(gbe_dev
, host_port_regs
, tx_pri_map
);
2822 XGBE_SET_REG_OFS(gbe_dev
, host_port_regs
, rx_maxlen
);
2826 static int get_gbe_resource_version(struct gbe_priv
*gbe_dev
,
2827 struct device_node
*node
)
2829 struct resource res
;
2833 ret
= of_address_to_resource(node
, GBE_SS_REG_INDEX
, &res
);
2835 dev_err(gbe_dev
->dev
,
2836 "Can't translate of node(%s) of gbe ss address at %d\n",
2837 node
->name
, GBE_SS_REG_INDEX
);
2841 regs
= devm_ioremap_resource(gbe_dev
->dev
, &res
);
2843 dev_err(gbe_dev
->dev
, "Failed to map gbe register base\n");
2844 return PTR_ERR(regs
);
2846 gbe_dev
->ss_regs
= regs
;
2847 gbe_dev
->ss_version
= readl(gbe_dev
->ss_regs
);
2851 static int set_gbe_ethss14_priv(struct gbe_priv
*gbe_dev
,
2852 struct device_node
*node
)
2854 struct resource res
;
2858 ret
= of_address_to_resource(node
, GBE_SGMII34_REG_INDEX
, &res
);
2860 dev_err(gbe_dev
->dev
,
2861 "Can't translate of gbe node(%s) address at index %d\n",
2862 node
->name
, GBE_SGMII34_REG_INDEX
);
2866 regs
= devm_ioremap_resource(gbe_dev
->dev
, &res
);
2868 dev_err(gbe_dev
->dev
,
2869 "Failed to map gbe sgmii port34 register base\n");
2870 return PTR_ERR(regs
);
2872 gbe_dev
->sgmii_port34_regs
= regs
;
2874 ret
= of_address_to_resource(node
, GBE_SM_REG_INDEX
, &res
);
2876 dev_err(gbe_dev
->dev
,
2877 "Can't translate of gbe node(%s) address at index %d\n",
2878 node
->name
, GBE_SM_REG_INDEX
);
2882 regs
= devm_ioremap_resource(gbe_dev
->dev
, &res
);
2884 dev_err(gbe_dev
->dev
,
2885 "Failed to map gbe switch module register base\n");
2886 return PTR_ERR(regs
);
2888 gbe_dev
->switch_regs
= regs
;
2890 gbe_dev
->num_stats_mods
= gbe_dev
->max_num_slaves
;
2891 gbe_dev
->et_stats
= gbe13_et_stats
;
2892 gbe_dev
->num_et_stats
= ARRAY_SIZE(gbe13_et_stats
);
2894 gbe_dev
->hw_stats
= devm_kzalloc(gbe_dev
->dev
,
2895 gbe_dev
->num_et_stats
* sizeof(u64
),
2897 if (!gbe_dev
->hw_stats
) {
2898 dev_err(gbe_dev
->dev
, "hw_stats memory allocation failed\n");
2902 gbe_dev
->hw_stats_prev
=
2903 devm_kzalloc(gbe_dev
->dev
,
2904 gbe_dev
->num_et_stats
* sizeof(u32
),
2906 if (!gbe_dev
->hw_stats_prev
) {
2907 dev_err(gbe_dev
->dev
,
2908 "hw_stats_prev memory allocation failed\n");
2912 gbe_dev
->sgmii_port_regs
= gbe_dev
->ss_regs
+ GBE13_SGMII_MODULE_OFFSET
;
2913 gbe_dev
->host_port_regs
= gbe_dev
->switch_regs
+ GBE13_HOST_PORT_OFFSET
;
2915 /* K2HK has only 2 hw stats modules visible at a time, so
2916 * module 0 & 2 points to one base and
2917 * module 1 & 3 points to the other base
2919 for (i
= 0; i
< gbe_dev
->max_num_slaves
; i
++) {
2920 gbe_dev
->hw_stats_regs
[i
] =
2921 gbe_dev
->switch_regs
+ GBE13_HW_STATS_OFFSET
+
2922 (GBE_HW_STATS_REG_MAP_SZ
* (i
& 0x1));
2925 gbe_dev
->ale_reg
= gbe_dev
->switch_regs
+ GBE13_ALE_OFFSET
;
2926 gbe_dev
->ale_ports
= gbe_dev
->max_num_ports
;
2927 gbe_dev
->host_port
= GBE13_HOST_PORT_NUM
;
2928 gbe_dev
->ale_entries
= GBE13_NUM_ALE_ENTRIES
;
2929 gbe_dev
->stats_en_mask
= GBE13_REG_VAL_STAT_ENABLE_ALL
;
2931 /* Subsystem registers */
2932 GBE_SET_REG_OFS(gbe_dev
, ss_regs
, id_ver
);
2934 /* Switch module registers */
2935 GBE_SET_REG_OFS(gbe_dev
, switch_regs
, id_ver
);
2936 GBE_SET_REG_OFS(gbe_dev
, switch_regs
, control
);
2937 GBE_SET_REG_OFS(gbe_dev
, switch_regs
, soft_reset
);
2938 GBE_SET_REG_OFS(gbe_dev
, switch_regs
, stat_port_en
);
2939 GBE_SET_REG_OFS(gbe_dev
, switch_regs
, ptype
);
2940 GBE_SET_REG_OFS(gbe_dev
, switch_regs
, flow_control
);
2942 /* Host port registers */
2943 GBE_SET_REG_OFS(gbe_dev
, host_port_regs
, port_vlan
);
2944 GBE_SET_REG_OFS(gbe_dev
, host_port_regs
, rx_maxlen
);
2948 static int set_gbenu_ethss_priv(struct gbe_priv
*gbe_dev
,
2949 struct device_node
*node
)
2951 struct resource res
;
2955 gbe_dev
->num_stats_mods
= gbe_dev
->max_num_ports
;
2956 gbe_dev
->et_stats
= gbenu_et_stats
;
2958 if (IS_SS_ID_NU(gbe_dev
))
2959 gbe_dev
->num_et_stats
= GBENU_ET_STATS_HOST_SIZE
+
2960 (gbe_dev
->max_num_slaves
* GBENU_ET_STATS_PORT_SIZE
);
2962 gbe_dev
->num_et_stats
= GBENU_ET_STATS_HOST_SIZE
+
2963 GBENU_ET_STATS_PORT_SIZE
;
2965 gbe_dev
->hw_stats
= devm_kzalloc(gbe_dev
->dev
,
2966 gbe_dev
->num_et_stats
* sizeof(u64
),
2968 if (!gbe_dev
->hw_stats
) {
2969 dev_err(gbe_dev
->dev
, "hw_stats memory allocation failed\n");
2973 gbe_dev
->hw_stats_prev
=
2974 devm_kzalloc(gbe_dev
->dev
,
2975 gbe_dev
->num_et_stats
* sizeof(u32
),
2977 if (!gbe_dev
->hw_stats_prev
) {
2978 dev_err(gbe_dev
->dev
,
2979 "hw_stats_prev memory allocation failed\n");
2983 ret
= of_address_to_resource(node
, GBENU_SM_REG_INDEX
, &res
);
2985 dev_err(gbe_dev
->dev
,
2986 "Can't translate of gbenu node(%s) addr at index %d\n",
2987 node
->name
, GBENU_SM_REG_INDEX
);
2991 regs
= devm_ioremap_resource(gbe_dev
->dev
, &res
);
2993 dev_err(gbe_dev
->dev
,
2994 "Failed to map gbenu switch module register base\n");
2995 return PTR_ERR(regs
);
2997 gbe_dev
->switch_regs
= regs
;
2999 gbe_dev
->sgmii_port_regs
= gbe_dev
->ss_regs
+ GBENU_SGMII_MODULE_OFFSET
;
3000 gbe_dev
->host_port_regs
= gbe_dev
->switch_regs
+ GBENU_HOST_PORT_OFFSET
;
3002 for (i
= 0; i
< (gbe_dev
->max_num_ports
); i
++)
3003 gbe_dev
->hw_stats_regs
[i
] = gbe_dev
->switch_regs
+
3004 GBENU_HW_STATS_OFFSET
+ (GBENU_HW_STATS_REG_MAP_SZ
* i
);
3006 gbe_dev
->ale_reg
= gbe_dev
->switch_regs
+ GBENU_ALE_OFFSET
;
3007 gbe_dev
->ale_ports
= gbe_dev
->max_num_ports
;
3008 gbe_dev
->host_port
= GBENU_HOST_PORT_NUM
;
3009 gbe_dev
->ale_entries
= GBE13_NUM_ALE_ENTRIES
;
3010 gbe_dev
->stats_en_mask
= (1 << (gbe_dev
->max_num_ports
)) - 1;
3012 /* Subsystem registers */
3013 GBENU_SET_REG_OFS(gbe_dev
, ss_regs
, id_ver
);
3015 /* Switch module registers */
3016 GBENU_SET_REG_OFS(gbe_dev
, switch_regs
, id_ver
);
3017 GBENU_SET_REG_OFS(gbe_dev
, switch_regs
, control
);
3018 GBENU_SET_REG_OFS(gbe_dev
, switch_regs
, stat_port_en
);
3019 GBENU_SET_REG_OFS(gbe_dev
, switch_regs
, ptype
);
3021 /* Host port registers */
3022 GBENU_SET_REG_OFS(gbe_dev
, host_port_regs
, port_vlan
);
3023 GBENU_SET_REG_OFS(gbe_dev
, host_port_regs
, rx_maxlen
);
3025 /* For NU only. 2U does not need tx_pri_map.
3026 * NU cppi port 0 tx pkt streaming interface has (n-1)*8 egress threads
3027 * while 2U has only 1 such thread
3029 GBENU_SET_REG_OFS(gbe_dev
, host_port_regs
, tx_pri_map
);
3033 static int gbe_probe(struct netcp_device
*netcp_device
, struct device
*dev
,
3034 struct device_node
*node
, void **inst_priv
)
3036 struct device_node
*interfaces
, *interface
;
3037 struct device_node
*secondary_ports
;
3038 struct cpsw_ale_params ale_params
;
3039 struct gbe_priv
*gbe_dev
;
3044 dev_err(dev
, "device tree info unavailable\n");
3048 gbe_dev
= devm_kzalloc(dev
, sizeof(struct gbe_priv
), GFP_KERNEL
);
3052 if (of_device_is_compatible(node
, "ti,netcp-gbe-5") ||
3053 of_device_is_compatible(node
, "ti,netcp-gbe")) {
3054 gbe_dev
->max_num_slaves
= 4;
3055 } else if (of_device_is_compatible(node
, "ti,netcp-gbe-9")) {
3056 gbe_dev
->max_num_slaves
= 8;
3057 } else if (of_device_is_compatible(node
, "ti,netcp-gbe-2")) {
3058 gbe_dev
->max_num_slaves
= 1;
3059 } else if (of_device_is_compatible(node
, "ti,netcp-xgbe")) {
3060 gbe_dev
->max_num_slaves
= 2;
3062 dev_err(dev
, "device tree node for unknown device\n");
3065 gbe_dev
->max_num_ports
= gbe_dev
->max_num_slaves
+ 1;
3068 gbe_dev
->netcp_device
= netcp_device
;
3069 gbe_dev
->rx_packet_max
= NETCP_MAX_FRAME_SIZE
;
3071 /* init the hw stats lock */
3072 spin_lock_init(&gbe_dev
->hw_stats_lock
);
3074 if (of_find_property(node
, "enable-ale", NULL
)) {
3075 gbe_dev
->enable_ale
= true;
3076 dev_info(dev
, "ALE enabled\n");
3078 gbe_dev
->enable_ale
= false;
3079 dev_dbg(dev
, "ALE bypass enabled*\n");
3082 ret
= of_property_read_u32(node
, "tx-queue",
3083 &gbe_dev
->tx_queue_id
);
3085 dev_err(dev
, "missing tx_queue parameter\n");
3086 gbe_dev
->tx_queue_id
= GBE_TX_QUEUE
;
3089 ret
= of_property_read_string(node
, "tx-channel",
3090 &gbe_dev
->dma_chan_name
);
3092 dev_err(dev
, "missing \"tx-channel\" parameter\n");
3096 if (!strcmp(node
->name
, "gbe")) {
3097 ret
= get_gbe_resource_version(gbe_dev
, node
);
3101 dev_dbg(dev
, "ss_version: 0x%08x\n", gbe_dev
->ss_version
);
3103 if (gbe_dev
->ss_version
== GBE_SS_VERSION_14
)
3104 ret
= set_gbe_ethss14_priv(gbe_dev
, node
);
3105 else if (IS_SS_ID_MU(gbe_dev
))
3106 ret
= set_gbenu_ethss_priv(gbe_dev
, node
);
3110 } else if (!strcmp(node
->name
, "xgbe")) {
3111 ret
= set_xgbe_ethss10_priv(gbe_dev
, node
);
3114 ret
= netcp_xgbe_serdes_init(gbe_dev
->xgbe_serdes_regs
,
3117 dev_err(dev
, "unknown GBE node(%s)\n", node
->name
);
3124 interfaces
= of_get_child_by_name(node
, "interfaces");
3126 dev_err(dev
, "could not find interfaces\n");
3128 ret
= netcp_txpipe_init(&gbe_dev
->tx_pipe
, netcp_device
,
3129 gbe_dev
->dma_chan_name
, gbe_dev
->tx_queue_id
);
3133 ret
= netcp_txpipe_open(&gbe_dev
->tx_pipe
);
3137 /* Create network interfaces */
3138 INIT_LIST_HEAD(&gbe_dev
->gbe_intf_head
);
3139 for_each_child_of_node(interfaces
, interface
) {
3140 ret
= of_property_read_u32(interface
, "slave-port", &slave_num
);
3142 dev_err(dev
, "missing slave-port parameter, skipping interface configuration for %s\n",
3146 gbe_dev
->num_slaves
++;
3147 if (gbe_dev
->num_slaves
>= gbe_dev
->max_num_slaves
)
3150 of_node_put(interfaces
);
3152 if (!gbe_dev
->num_slaves
)
3153 dev_warn(dev
, "No network interface configured\n");
3155 /* Initialize Secondary slave ports */
3156 secondary_ports
= of_get_child_by_name(node
, "secondary-slave-ports");
3157 INIT_LIST_HEAD(&gbe_dev
->secondary_slaves
);
3158 if (secondary_ports
&& (gbe_dev
->num_slaves
< gbe_dev
->max_num_slaves
))
3159 init_secondary_ports(gbe_dev
, secondary_ports
);
3160 of_node_put(secondary_ports
);
3162 if (!gbe_dev
->num_slaves
) {
3164 "No network interface or secondary ports configured\n");
3166 goto free_sec_ports
;
3169 memset(&ale_params
, 0, sizeof(ale_params
));
3170 ale_params
.dev
= gbe_dev
->dev
;
3171 ale_params
.ale_regs
= gbe_dev
->ale_reg
;
3172 ale_params
.ale_ageout
= GBE_DEFAULT_ALE_AGEOUT
;
3173 ale_params
.ale_entries
= gbe_dev
->ale_entries
;
3174 ale_params
.ale_ports
= gbe_dev
->ale_ports
;
3176 gbe_dev
->ale
= cpsw_ale_create(&ale_params
);
3177 if (!gbe_dev
->ale
) {
3178 dev_err(gbe_dev
->dev
, "error initializing ale engine\n");
3180 goto free_sec_ports
;
3182 dev_dbg(gbe_dev
->dev
, "Created a gbe ale engine\n");
3185 /* initialize host port */
3186 gbe_init_host_port(gbe_dev
);
3188 spin_lock_bh(&gbe_dev
->hw_stats_lock
);
3189 for (i
= 0; i
< gbe_dev
->num_stats_mods
; i
++) {
3190 if (gbe_dev
->ss_version
== GBE_SS_VERSION_14
)
3191 gbe_reset_mod_stats_ver14(gbe_dev
, i
);
3193 gbe_reset_mod_stats(gbe_dev
, i
);
3195 spin_unlock_bh(&gbe_dev
->hw_stats_lock
);
3197 init_timer(&gbe_dev
->timer
);
3198 gbe_dev
->timer
.data
= (unsigned long)gbe_dev
;
3199 gbe_dev
->timer
.function
= netcp_ethss_timer
;
3200 gbe_dev
->timer
.expires
= jiffies
+ GBE_TIMER_INTERVAL
;
3201 add_timer(&gbe_dev
->timer
);
3202 *inst_priv
= gbe_dev
;
3206 free_secondary_ports(gbe_dev
);
3210 static int gbe_attach(void *inst_priv
, struct net_device
*ndev
,
3211 struct device_node
*node
, void **intf_priv
)
3213 struct gbe_priv
*gbe_dev
= inst_priv
;
3214 struct gbe_intf
*gbe_intf
;
3218 dev_err(gbe_dev
->dev
, "interface node not available\n");
3222 gbe_intf
= devm_kzalloc(gbe_dev
->dev
, sizeof(*gbe_intf
), GFP_KERNEL
);
3226 gbe_intf
->ndev
= ndev
;
3227 gbe_intf
->dev
= gbe_dev
->dev
;
3228 gbe_intf
->gbe_dev
= gbe_dev
;
3230 gbe_intf
->slave
= devm_kzalloc(gbe_dev
->dev
,
3231 sizeof(*gbe_intf
->slave
),
3233 if (!gbe_intf
->slave
) {
3238 if (init_slave(gbe_dev
, gbe_intf
->slave
, node
)) {
3243 gbe_intf
->tx_pipe
= gbe_dev
->tx_pipe
;
3244 ndev
->ethtool_ops
= &keystone_ethtool_ops
;
3245 list_add_tail(&gbe_intf
->gbe_intf_list
, &gbe_dev
->gbe_intf_head
);
3246 *intf_priv
= gbe_intf
;
3250 if (gbe_intf
->slave
)
3251 devm_kfree(gbe_dev
->dev
, gbe_intf
->slave
);
3253 devm_kfree(gbe_dev
->dev
, gbe_intf
);
3257 static int gbe_release(void *intf_priv
)
3259 struct gbe_intf
*gbe_intf
= intf_priv
;
3261 gbe_intf
->ndev
->ethtool_ops
= NULL
;
3262 list_del(&gbe_intf
->gbe_intf_list
);
3263 devm_kfree(gbe_intf
->dev
, gbe_intf
->slave
);
3264 devm_kfree(gbe_intf
->dev
, gbe_intf
);
3268 static int gbe_remove(struct netcp_device
*netcp_device
, void *inst_priv
)
3270 struct gbe_priv
*gbe_dev
= inst_priv
;
3272 del_timer_sync(&gbe_dev
->timer
);
3273 cpsw_ale_stop(gbe_dev
->ale
);
3274 cpsw_ale_destroy(gbe_dev
->ale
);
3275 netcp_txpipe_close(&gbe_dev
->tx_pipe
);
3276 free_secondary_ports(gbe_dev
);
3278 if (!list_empty(&gbe_dev
->gbe_intf_head
))
3279 dev_alert(gbe_dev
->dev
,
3280 "unreleased ethss interfaces present\n");
3285 static struct netcp_module gbe_module
= {
3286 .name
= GBE_MODULE_NAME
,
3287 .owner
= THIS_MODULE
,
3292 .remove
= gbe_remove
,
3293 .attach
= gbe_attach
,
3294 .release
= gbe_release
,
3295 .add_addr
= gbe_add_addr
,
3296 .del_addr
= gbe_del_addr
,
3297 .add_vid
= gbe_add_vid
,
3298 .del_vid
= gbe_del_vid
,
3302 static struct netcp_module xgbe_module
= {
3303 .name
= XGBE_MODULE_NAME
,
3304 .owner
= THIS_MODULE
,
3309 .remove
= gbe_remove
,
3310 .attach
= gbe_attach
,
3311 .release
= gbe_release
,
3312 .add_addr
= gbe_add_addr
,
3313 .del_addr
= gbe_del_addr
,
3314 .add_vid
= gbe_add_vid
,
3315 .del_vid
= gbe_del_vid
,
3319 static int __init
keystone_gbe_init(void)
3323 ret
= netcp_register_module(&gbe_module
);
3327 ret
= netcp_register_module(&xgbe_module
);
3333 module_init(keystone_gbe_init
);
3335 static void __exit
keystone_gbe_exit(void)
3337 netcp_unregister_module(&gbe_module
);
3338 netcp_unregister_module(&xgbe_module
);
3340 module_exit(keystone_gbe_exit
);
3342 MODULE_LICENSE("GPL v2");
3343 MODULE_DESCRIPTION("TI NETCP ETHSS driver for Keystone SOCs");
3344 MODULE_AUTHOR("Sandeep Nair <sandeep_n@ti.com");