1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
28a3b7a25Sdanborkmann@iogearbox.net /*
38a3b7a25Sdanborkmann@iogearbox.net * Definitions for Xilinx Axi Ethernet device driver.
48a3b7a25Sdanborkmann@iogearbox.net *
58a3b7a25Sdanborkmann@iogearbox.net * Copyright (c) 2009 Secret Lab Technologies, Ltd.
659a54f30SMichal Simek * Copyright (c) 2010 - 2012 Xilinx, Inc. All rights reserved.
78a3b7a25Sdanborkmann@iogearbox.net */
88a3b7a25Sdanborkmann@iogearbox.net
98a3b7a25Sdanborkmann@iogearbox.net #ifndef XILINX_AXIENET_H
108a3b7a25Sdanborkmann@iogearbox.net #define XILINX_AXIENET_H
118a3b7a25Sdanborkmann@iogearbox.net
128a3b7a25Sdanborkmann@iogearbox.net #include <linux/netdevice.h>
138a3b7a25Sdanborkmann@iogearbox.net #include <linux/spinlock.h>
148a3b7a25Sdanborkmann@iogearbox.net #include <linux/interrupt.h>
15f080a8c3SSrikanth Thokala #include <linux/if_vlan.h>
16f5203a3dSRobert Hancock #include <linux/phylink.h>
176a91b846SRadhey Shyam Pandey #include <linux/skbuff.h>
188a3b7a25Sdanborkmann@iogearbox.net
198a3b7a25Sdanborkmann@iogearbox.net /* Packet size info */
208a3b7a25Sdanborkmann@iogearbox.net #define XAE_HDR_SIZE 14 /* Size of Ethernet header */
218a3b7a25Sdanborkmann@iogearbox.net #define XAE_TRL_SIZE 4 /* Size of Ethernet trailer (FCS) */
228a3b7a25Sdanborkmann@iogearbox.net #define XAE_MTU 1500 /* Max MTU of an Ethernet frame */
238a3b7a25Sdanborkmann@iogearbox.net #define XAE_JUMBO_MTU 9000 /* Max MTU of a jumbo Eth. frame */
248a3b7a25Sdanborkmann@iogearbox.net
258a3b7a25Sdanborkmann@iogearbox.net #define XAE_MAX_FRAME_SIZE (XAE_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
26f080a8c3SSrikanth Thokala #define XAE_MAX_VLAN_FRAME_SIZE (XAE_MTU + VLAN_ETH_HLEN + XAE_TRL_SIZE)
278a3b7a25Sdanborkmann@iogearbox.net #define XAE_MAX_JUMBO_FRAME_SIZE (XAE_JUMBO_MTU + XAE_HDR_SIZE + XAE_TRL_SIZE)
288a3b7a25Sdanborkmann@iogearbox.net
298a3b7a25Sdanborkmann@iogearbox.net /* Configuration options */
308a3b7a25Sdanborkmann@iogearbox.net
318a3b7a25Sdanborkmann@iogearbox.net /* Accept all incoming packets. Default: disabled (cleared) */
323ff578c9SAppana Durga Kedareswara Rao #define XAE_OPTION_PROMISC BIT(0)
338a3b7a25Sdanborkmann@iogearbox.net
348a3b7a25Sdanborkmann@iogearbox.net /* Jumbo frame support for Tx & Rx. Default: disabled (cleared) */
353ff578c9SAppana Durga Kedareswara Rao #define XAE_OPTION_JUMBO BIT(1)
368a3b7a25Sdanborkmann@iogearbox.net
378a3b7a25Sdanborkmann@iogearbox.net /* VLAN Rx & Tx frame support. Default: disabled (cleared) */
383ff578c9SAppana Durga Kedareswara Rao #define XAE_OPTION_VLAN BIT(2)
398a3b7a25Sdanborkmann@iogearbox.net
408a3b7a25Sdanborkmann@iogearbox.net /* Enable recognition of flow control frames on Rx. Default: enabled (set) */
413ff578c9SAppana Durga Kedareswara Rao #define XAE_OPTION_FLOW_CONTROL BIT(4)
428a3b7a25Sdanborkmann@iogearbox.net
438a3b7a25Sdanborkmann@iogearbox.net /* Strip FCS and PAD from incoming frames. Note: PAD from VLAN frames is not
44850a7503SMichal Simek * stripped. Default: disabled (set)
45850a7503SMichal Simek */
463ff578c9SAppana Durga Kedareswara Rao #define XAE_OPTION_FCS_STRIP BIT(5)
478a3b7a25Sdanborkmann@iogearbox.net
488a3b7a25Sdanborkmann@iogearbox.net /* Generate FCS field and add PAD automatically for outgoing frames.
49850a7503SMichal Simek * Default: enabled (set)
50850a7503SMichal Simek */
513ff578c9SAppana Durga Kedareswara Rao #define XAE_OPTION_FCS_INSERT BIT(6)
528a3b7a25Sdanborkmann@iogearbox.net
538a3b7a25Sdanborkmann@iogearbox.net /* Enable Length/Type error checking for incoming frames. When this option is
548a3b7a25Sdanborkmann@iogearbox.net * set, the MAC will filter frames that have a mismatched type/length field
558a3b7a25Sdanborkmann@iogearbox.net * and if XAE_OPTION_REPORT_RXERR is set, the user is notified when these
568a3b7a25Sdanborkmann@iogearbox.net * types of frames are encountered. When this option is cleared, the MAC will
57850a7503SMichal Simek * allow these types of frames to be received. Default: enabled (set)
58850a7503SMichal Simek */
593ff578c9SAppana Durga Kedareswara Rao #define XAE_OPTION_LENTYPE_ERR BIT(7)
608a3b7a25Sdanborkmann@iogearbox.net
618a3b7a25Sdanborkmann@iogearbox.net /* Enable the transmitter. Default: enabled (set) */
623ff578c9SAppana Durga Kedareswara Rao #define XAE_OPTION_TXEN BIT(11)
638a3b7a25Sdanborkmann@iogearbox.net
648a3b7a25Sdanborkmann@iogearbox.net /* Enable the receiver. Default: enabled (set) */
653ff578c9SAppana Durga Kedareswara Rao #define XAE_OPTION_RXEN BIT(12)
668a3b7a25Sdanborkmann@iogearbox.net
678a3b7a25Sdanborkmann@iogearbox.net /* Default options set when device is initialized or reset */
688a3b7a25Sdanborkmann@iogearbox.net #define XAE_OPTION_DEFAULTS \
698a3b7a25Sdanborkmann@iogearbox.net (XAE_OPTION_TXEN | \
708a3b7a25Sdanborkmann@iogearbox.net XAE_OPTION_FLOW_CONTROL | \
718a3b7a25Sdanborkmann@iogearbox.net XAE_OPTION_RXEN)
728a3b7a25Sdanborkmann@iogearbox.net
738a3b7a25Sdanborkmann@iogearbox.net /* Axi DMA Register definitions */
748a3b7a25Sdanborkmann@iogearbox.net
758a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_TX_CR_OFFSET 0x00000000 /* Channel control */
768a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_TX_SR_OFFSET 0x00000004 /* Status */
778a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_TX_CDESC_OFFSET 0x00000008 /* Current descriptor pointer */
788a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_TX_TDESC_OFFSET 0x00000010 /* Tail descriptor pointer */
798a3b7a25Sdanborkmann@iogearbox.net
808a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_RX_CR_OFFSET 0x00000030 /* Channel control */
818a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_RX_SR_OFFSET 0x00000034 /* Status */
828a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_RX_CDESC_OFFSET 0x00000038 /* Current descriptor pointer */
838a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_RX_TDESC_OFFSET 0x00000040 /* Tail descriptor pointer */
848a3b7a25Sdanborkmann@iogearbox.net
858a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_CR_RUNSTOP_MASK 0x00000001 /* Start/stop DMA channel */
868a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_CR_RESET_MASK 0x00000004 /* Reset DMA engine */
878a3b7a25Sdanborkmann@iogearbox.net
88489d4d77SRobert Hancock #define XAXIDMA_SR_HALT_MASK 0x00000001 /* Indicates DMA channel halted */
89489d4d77SRobert Hancock
908a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_NDESC_OFFSET 0x00 /* Next descriptor pointer */
918a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_BUFA_OFFSET 0x08 /* Buffer address */
928a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_CTRL_LEN_OFFSET 0x18 /* Control/buffer length */
938a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_STS_OFFSET 0x1C /* Status */
948a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_USR0_OFFSET 0x20 /* User IP specific word0 */
958a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_USR1_OFFSET 0x24 /* User IP specific word1 */
968a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_USR2_OFFSET 0x28 /* User IP specific word2 */
978a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_USR3_OFFSET 0x2C /* User IP specific word3 */
988a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_USR4_OFFSET 0x30 /* User IP specific word4 */
998a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_ID_OFFSET 0x34 /* Sw ID */
1008a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_HAS_STSCNTRL_OFFSET 0x38 /* Whether has stscntrl strm */
1018a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_HAS_DRE_OFFSET 0x3C /* Whether has DRE */
1028a3b7a25Sdanborkmann@iogearbox.net
1038a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_HAS_DRE_SHIFT 8 /* Whether has DRE shift */
1048a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_HAS_DRE_MASK 0xF00 /* Whether has DRE mask */
1058a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_WORDLEN_MASK 0xFF /* Whether has DRE mask */
1068a3b7a25Sdanborkmann@iogearbox.net
1078a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_CTRL_LENGTH_MASK 0x007FFFFF /* Requested len */
1088a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */
1098a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */
1108a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */
1118a3b7a25Sdanborkmann@iogearbox.net
1128a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_DELAY_MASK 0xFF000000 /* Delay timeout counter */
1138a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_COALESCE_MASK 0x00FF0000 /* Coalesce counter */
1148a3b7a25Sdanborkmann@iogearbox.net
1158a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_DELAY_SHIFT 24
1168a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_COALESCE_SHIFT 16
1178a3b7a25Sdanborkmann@iogearbox.net
1188a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_IRQ_IOC_MASK 0x00001000 /* Completion intr */
1198a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_IRQ_DELAY_MASK 0x00002000 /* Delay interrupt */
1208a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_IRQ_ERROR_MASK 0x00004000 /* Error interrupt */
1218a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_IRQ_ALL_MASK 0x00007000 /* All interrupts */
1228a3b7a25Sdanborkmann@iogearbox.net
1230b79b8dcSRobert Hancock /* Default TX/RX Threshold and delay timer values for SGDMA mode */
1248a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_DFT_TX_THRESHOLD 24
1250b79b8dcSRobert Hancock #define XAXIDMA_DFT_TX_USEC 50
12640da5d68SRobert Hancock #define XAXIDMA_DFT_RX_THRESHOLD 1
1270b79b8dcSRobert Hancock #define XAXIDMA_DFT_RX_USEC 50
1288a3b7a25Sdanborkmann@iogearbox.net
1298a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_CTRL_TXSOF_MASK 0x08000000 /* First tx packet */
1308a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_CTRL_TXEOF_MASK 0x04000000 /* Last tx packet */
1318a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_CTRL_ALL_MASK 0x0C000000 /* All control bits */
1328a3b7a25Sdanborkmann@iogearbox.net
1338a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_STS_ACTUAL_LEN_MASK 0x007FFFFF /* Actual len */
1348a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_STS_COMPLETE_MASK 0x80000000 /* Completed */
1358a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_STS_DEC_ERR_MASK 0x40000000 /* Decode error */
1368a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_STS_SLV_ERR_MASK 0x20000000 /* Slave error */
1378a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_STS_INT_ERR_MASK 0x10000000 /* Internal err */
1388a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_STS_ALL_ERR_MASK 0x70000000 /* All errors */
1398a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_STS_RXSOF_MASK 0x08000000 /* First rx pkt */
1408a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_STS_RXEOF_MASK 0x04000000 /* Last rx pkt */
1418a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_STS_ALL_MASK 0xFC000000 /* All status bits */
1428a3b7a25Sdanborkmann@iogearbox.net
1438a3b7a25Sdanborkmann@iogearbox.net #define XAXIDMA_BD_MINIMUM_ALIGNMENT 0x40
1448a3b7a25Sdanborkmann@iogearbox.net
1458a3b7a25Sdanborkmann@iogearbox.net /* Axi Ethernet registers definition */
1468a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_OFFSET 0x00000000 /* Reset and Address filter */
1478a3b7a25Sdanborkmann@iogearbox.net #define XAE_TPF_OFFSET 0x00000004 /* Tx Pause Frame */
1488a3b7a25Sdanborkmann@iogearbox.net #define XAE_IFGP_OFFSET 0x00000008 /* Tx Inter-frame gap adjustment*/
1498a3b7a25Sdanborkmann@iogearbox.net #define XAE_IS_OFFSET 0x0000000C /* Interrupt status */
1508a3b7a25Sdanborkmann@iogearbox.net #define XAE_IP_OFFSET 0x00000010 /* Interrupt pending */
1518a3b7a25Sdanborkmann@iogearbox.net #define XAE_IE_OFFSET 0x00000014 /* Interrupt enable */
1528a3b7a25Sdanborkmann@iogearbox.net #define XAE_TTAG_OFFSET 0x00000018 /* Tx VLAN TAG */
1538a3b7a25Sdanborkmann@iogearbox.net #define XAE_RTAG_OFFSET 0x0000001C /* Rx VLAN TAG */
1548a3b7a25Sdanborkmann@iogearbox.net #define XAE_UAWL_OFFSET 0x00000020 /* Unicast address word lower */
1558a3b7a25Sdanborkmann@iogearbox.net #define XAE_UAWU_OFFSET 0x00000024 /* Unicast address word upper */
1568a3b7a25Sdanborkmann@iogearbox.net #define XAE_TPID0_OFFSET 0x00000028 /* VLAN TPID0 register */
1578a3b7a25Sdanborkmann@iogearbox.net #define XAE_TPID1_OFFSET 0x0000002C /* VLAN TPID1 register */
1588a3b7a25Sdanborkmann@iogearbox.net #define XAE_PPST_OFFSET 0x00000030 /* PCS PMA Soft Temac Status Reg */
15976abb5d6SSean Anderson #define XAE_STATS_OFFSET 0x00000200 /* Statistics counters */
1608a3b7a25Sdanborkmann@iogearbox.net #define XAE_RCW0_OFFSET 0x00000400 /* Rx Configuration Word 0 */
1618a3b7a25Sdanborkmann@iogearbox.net #define XAE_RCW1_OFFSET 0x00000404 /* Rx Configuration Word 1 */
1628a3b7a25Sdanborkmann@iogearbox.net #define XAE_TC_OFFSET 0x00000408 /* Tx Configuration */
1638a3b7a25Sdanborkmann@iogearbox.net #define XAE_FCC_OFFSET 0x0000040C /* Flow Control Configuration */
1649ff2f816SRadhey Shyam Pandey #define XAE_EMMC_OFFSET 0x00000410 /* MAC speed configuration */
1659ff2f816SRadhey Shyam Pandey #define XAE_PHYC_OFFSET 0x00000414 /* RX Max Frame Configuration */
166f735c40eSAndre Przywara #define XAE_ID_OFFSET 0x000004F8 /* Identification register */
16776abb5d6SSean Anderson #define XAE_ABILITY_OFFSET 0x000004FC /* Ability Register offset */
1689ff2f816SRadhey Shyam Pandey #define XAE_MDIO_MC_OFFSET 0x00000500 /* MDIO Setup */
1699ff2f816SRadhey Shyam Pandey #define XAE_MDIO_MCR_OFFSET 0x00000504 /* MDIO Control */
1709ff2f816SRadhey Shyam Pandey #define XAE_MDIO_MWD_OFFSET 0x00000508 /* MDIO Write Data */
1719ff2f816SRadhey Shyam Pandey #define XAE_MDIO_MRD_OFFSET 0x0000050C /* MDIO Read Data */
1728a3b7a25Sdanborkmann@iogearbox.net #define XAE_UAW0_OFFSET 0x00000700 /* Unicast address word 0 */
1738a3b7a25Sdanborkmann@iogearbox.net #define XAE_UAW1_OFFSET 0x00000704 /* Unicast address word 1 */
1749ff2f816SRadhey Shyam Pandey #define XAE_FMI_OFFSET 0x00000708 /* Frame Filter Control */
175797a68c9SSean Anderson #define XAE_FFE_OFFSET 0x0000070C /* Frame Filter Enable */
1768a3b7a25Sdanborkmann@iogearbox.net #define XAE_AF0_OFFSET 0x00000710 /* Address Filter 0 */
1778a3b7a25Sdanborkmann@iogearbox.net #define XAE_AF1_OFFSET 0x00000714 /* Address Filter 1 */
178*749e67d5SSean Anderson #define XAE_AM0_OFFSET 0x00000750 /* Frame Filter Mask Value Bytes 3-0 */
179*749e67d5SSean Anderson #define XAE_AM1_OFFSET 0x00000754 /* Frame Filter Mask Value Bytes 7-4 */
1808a3b7a25Sdanborkmann@iogearbox.net
1818a3b7a25Sdanborkmann@iogearbox.net #define XAE_TX_VLAN_DATA_OFFSET 0x00004000 /* TX VLAN data table address */
1828a3b7a25Sdanborkmann@iogearbox.net #define XAE_RX_VLAN_DATA_OFFSET 0x00008000 /* RX VLAN data table address */
1838a3b7a25Sdanborkmann@iogearbox.net #define XAE_MCAST_TABLE_OFFSET 0x00020000 /* Multicast table address */
1848a3b7a25Sdanborkmann@iogearbox.net
1858a3b7a25Sdanborkmann@iogearbox.net /* Bit Masks for Axi Ethernet RAF register */
186850a7503SMichal Simek /* Reject receive multicast destination address */
187850a7503SMichal Simek #define XAE_RAF_MCSTREJ_MASK 0x00000002
188850a7503SMichal Simek /* Reject receive broadcast destination address */
189850a7503SMichal Simek #define XAE_RAF_BCSTREJ_MASK 0x00000004
1908a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_TXVTAGMODE_MASK 0x00000018 /* Tx VLAN TAG mode */
1918a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_RXVTAGMODE_MASK 0x00000060 /* Rx VLAN TAG mode */
1928a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_TXVSTRPMODE_MASK 0x00000180 /* Tx VLAN STRIP mode */
1938a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_RXVSTRPMODE_MASK 0x00000600 /* Rx VLAN STRIP mode */
1948a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_NEWFNCENBL_MASK 0x00000800 /* New function mode */
19535ed87adSColin Ian King /* Extended Multicast Filtering mode */
196850a7503SMichal Simek #define XAE_RAF_EMULTIFLTRENBL_MASK 0x00001000
1978a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_STATSRST_MASK 0x00002000 /* Stats. Counter Reset */
1988a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_RXBADFRMEN_MASK 0x00004000 /* Recv Bad Frame Enable */
1998a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_TXVTAGMODE_SHIFT 3 /* Tx Tag mode shift bits */
2008a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_RXVTAGMODE_SHIFT 5 /* Rx Tag mode shift bits */
2018a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_TXVSTRPMODE_SHIFT 7 /* Tx strip mode shift bits*/
2028a3b7a25Sdanborkmann@iogearbox.net #define XAE_RAF_RXVSTRPMODE_SHIFT 9 /* Rx Strip mode shift bits*/
2038a3b7a25Sdanborkmann@iogearbox.net
2048a3b7a25Sdanborkmann@iogearbox.net /* Bit Masks for Axi Ethernet TPF and IFGP registers */
2058a3b7a25Sdanborkmann@iogearbox.net #define XAE_TPF_TPFV_MASK 0x0000FFFF /* Tx pause frame value */
206850a7503SMichal Simek /* Transmit inter-frame gap adjustment value */
207850a7503SMichal Simek #define XAE_IFGP0_IFGP_MASK 0x0000007F
2088a3b7a25Sdanborkmann@iogearbox.net
2098a3b7a25Sdanborkmann@iogearbox.net /* Bit Masks for Axi Ethernet IS, IE and IP registers, Same masks apply
210850a7503SMichal Simek * for all 3 registers.
211850a7503SMichal Simek */
212850a7503SMichal Simek /* Hard register access complete */
213850a7503SMichal Simek #define XAE_INT_HARDACSCMPLT_MASK 0x00000001
214850a7503SMichal Simek /* Auto negotiation complete */
215850a7503SMichal Simek #define XAE_INT_AUTONEG_MASK 0x00000002
2168a3b7a25Sdanborkmann@iogearbox.net #define XAE_INT_RXCMPIT_MASK 0x00000004 /* Rx complete */
2178a3b7a25Sdanborkmann@iogearbox.net #define XAE_INT_RXRJECT_MASK 0x00000008 /* Rx frame rejected */
2188a3b7a25Sdanborkmann@iogearbox.net #define XAE_INT_RXFIFOOVR_MASK 0x00000010 /* Rx fifo overrun */
2198a3b7a25Sdanborkmann@iogearbox.net #define XAE_INT_TXCMPIT_MASK 0x00000020 /* Tx complete */
2208a3b7a25Sdanborkmann@iogearbox.net #define XAE_INT_RXDCMLOCK_MASK 0x00000040 /* Rx Dcm Lock */
2218a3b7a25Sdanborkmann@iogearbox.net #define XAE_INT_MGTRDY_MASK 0x00000080 /* MGT clock Lock */
2228a3b7a25Sdanborkmann@iogearbox.net #define XAE_INT_PHYRSTCMPLT_MASK 0x00000100 /* Phy Reset complete */
2238a3b7a25Sdanborkmann@iogearbox.net #define XAE_INT_ALL_MASK 0x0000003F /* All the ints */
2248a3b7a25Sdanborkmann@iogearbox.net
225850a7503SMichal Simek /* INT bits that indicate receive errors */
2268a3b7a25Sdanborkmann@iogearbox.net #define XAE_INT_RECV_ERROR_MASK \
227850a7503SMichal Simek (XAE_INT_RXRJECT_MASK | XAE_INT_RXFIFOOVR_MASK)
2288a3b7a25Sdanborkmann@iogearbox.net
2298a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet VLAN TPID Word 0 register */
2308a3b7a25Sdanborkmann@iogearbox.net #define XAE_TPID_0_MASK 0x0000FFFF /* TPID 0 */
2318a3b7a25Sdanborkmann@iogearbox.net #define XAE_TPID_1_MASK 0xFFFF0000 /* TPID 1 */
2328a3b7a25Sdanborkmann@iogearbox.net
2338a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet VLAN TPID Word 1 register */
2348a3b7a25Sdanborkmann@iogearbox.net #define XAE_TPID_2_MASK 0x0000FFFF /* TPID 0 */
2358a3b7a25Sdanborkmann@iogearbox.net #define XAE_TPID_3_MASK 0xFFFF0000 /* TPID 1 */
2368a3b7a25Sdanborkmann@iogearbox.net
2378a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet RCW1 register */
2388a3b7a25Sdanborkmann@iogearbox.net #define XAE_RCW1_RST_MASK 0x80000000 /* Reset */
2398a3b7a25Sdanborkmann@iogearbox.net #define XAE_RCW1_JUM_MASK 0x40000000 /* Jumbo frame enable */
240850a7503SMichal Simek /* In-Band FCS enable (FCS not stripped) */
241850a7503SMichal Simek #define XAE_RCW1_FCS_MASK 0x20000000
2428a3b7a25Sdanborkmann@iogearbox.net #define XAE_RCW1_RX_MASK 0x10000000 /* Receiver enable */
2438a3b7a25Sdanborkmann@iogearbox.net #define XAE_RCW1_VLAN_MASK 0x08000000 /* VLAN frame enable */
244850a7503SMichal Simek /* Length/type field valid check disable */
245850a7503SMichal Simek #define XAE_RCW1_LT_DIS_MASK 0x02000000
246850a7503SMichal Simek /* Control frame Length check disable */
247850a7503SMichal Simek #define XAE_RCW1_CL_DIS_MASK 0x01000000
248850a7503SMichal Simek /* Pause frame source address bits [47:32]. Bits [31:0] are
249850a7503SMichal Simek * stored in register RCW0
250850a7503SMichal Simek */
251850a7503SMichal Simek #define XAE_RCW1_PAUSEADDR_MASK 0x0000FFFF
2528a3b7a25Sdanborkmann@iogearbox.net
2538a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet TC register */
2548a3b7a25Sdanborkmann@iogearbox.net #define XAE_TC_RST_MASK 0x80000000 /* Reset */
2558a3b7a25Sdanborkmann@iogearbox.net #define XAE_TC_JUM_MASK 0x40000000 /* Jumbo frame enable */
256850a7503SMichal Simek /* In-Band FCS enable (FCS not generated) */
257850a7503SMichal Simek #define XAE_TC_FCS_MASK 0x20000000
2588a3b7a25Sdanborkmann@iogearbox.net #define XAE_TC_TX_MASK 0x10000000 /* Transmitter enable */
2598a3b7a25Sdanborkmann@iogearbox.net #define XAE_TC_VLAN_MASK 0x08000000 /* VLAN frame enable */
260850a7503SMichal Simek /* Inter-frame gap adjustment enable */
261850a7503SMichal Simek #define XAE_TC_IFG_MASK 0x02000000
2628a3b7a25Sdanborkmann@iogearbox.net
2638a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet FCC register */
2648a3b7a25Sdanborkmann@iogearbox.net #define XAE_FCC_FCRX_MASK 0x20000000 /* Rx flow control enable */
2658a3b7a25Sdanborkmann@iogearbox.net #define XAE_FCC_FCTX_MASK 0x40000000 /* Tx flow control enable */
2668a3b7a25Sdanborkmann@iogearbox.net
2678a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet EMMC register */
2688a3b7a25Sdanborkmann@iogearbox.net #define XAE_EMMC_LINKSPEED_MASK 0xC0000000 /* Link speed */
2698a3b7a25Sdanborkmann@iogearbox.net #define XAE_EMMC_RGMII_MASK 0x20000000 /* RGMII mode enable */
2708a3b7a25Sdanborkmann@iogearbox.net #define XAE_EMMC_SGMII_MASK 0x10000000 /* SGMII mode enable */
2718a3b7a25Sdanborkmann@iogearbox.net #define XAE_EMMC_GPCS_MASK 0x08000000 /* 1000BaseX mode enable */
2728a3b7a25Sdanborkmann@iogearbox.net #define XAE_EMMC_HOST_MASK 0x04000000 /* Host interface enable */
2738a3b7a25Sdanborkmann@iogearbox.net #define XAE_EMMC_TX16BIT 0x02000000 /* 16 bit Tx client enable */
2748a3b7a25Sdanborkmann@iogearbox.net #define XAE_EMMC_RX16BIT 0x01000000 /* 16 bit Rx client enable */
2758a3b7a25Sdanborkmann@iogearbox.net #define XAE_EMMC_LINKSPD_10 0x00000000 /* Link Speed mask for 10 Mbit */
2768a3b7a25Sdanborkmann@iogearbox.net #define XAE_EMMC_LINKSPD_100 0x40000000 /* Link Speed mask for 100 Mbit */
2778a3b7a25Sdanborkmann@iogearbox.net #define XAE_EMMC_LINKSPD_1000 0x80000000 /* Link Speed mask for 1000 Mbit */
2788a3b7a25Sdanborkmann@iogearbox.net
2798a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet PHYC register */
2808a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHYC_SGMIILINKSPEED_MASK 0xC0000000 /* SGMII link speed mask*/
2818a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHYC_RGMIILINKSPEED_MASK 0x0000000C /* RGMII link speed */
2828a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHYC_RGMIIHD_MASK 0x00000002 /* RGMII Half-duplex */
2838a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHYC_RGMIILINK_MASK 0x00000001 /* RGMII link status */
2848a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHYC_RGLINKSPD_10 0x00000000 /* RGMII link 10 Mbit */
2858a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHYC_RGLINKSPD_100 0x00000004 /* RGMII link 100 Mbit */
2868a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHYC_RGLINKSPD_1000 0x00000008 /* RGMII link 1000 Mbit */
2878a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHYC_SGLINKSPD_10 0x00000000 /* SGMII link 10 Mbit */
2888a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHYC_SGLINKSPD_100 0x40000000 /* SGMII link 100 Mbit */
2898a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHYC_SGLINKSPD_1000 0x80000000 /* SGMII link 1000 Mbit */
2908a3b7a25Sdanborkmann@iogearbox.net
29176abb5d6SSean Anderson /* Bit masks for Axi Ethernet ability register */
29276abb5d6SSean Anderson #define XAE_ABILITY_PFC BIT(16)
29376abb5d6SSean Anderson #define XAE_ABILITY_FRAME_FILTER BIT(10)
29476abb5d6SSean Anderson #define XAE_ABILITY_HALF_DUPLEX BIT(9)
29576abb5d6SSean Anderson #define XAE_ABILITY_STATS BIT(8)
29676abb5d6SSean Anderson #define XAE_ABILITY_2_5G BIT(3)
29776abb5d6SSean Anderson #define XAE_ABILITY_1G BIT(2)
29876abb5d6SSean Anderson #define XAE_ABILITY_100M BIT(1)
29976abb5d6SSean Anderson #define XAE_ABILITY_10M BIT(0)
30076abb5d6SSean Anderson
3018a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet MDIO interface MC register */
3028a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MC_MDIOEN_MASK 0x00000040 /* MII management enable */
3038a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MC_CLOCK_DIVIDE_MAX 0x3F /* Maximum MDIO divisor */
3048a3b7a25Sdanborkmann@iogearbox.net
3058a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet MDIO interface MCR register */
3068a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MCR_PHYAD_MASK 0x1F000000 /* Phy Address Mask */
3078a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MCR_PHYAD_SHIFT 24 /* Phy Address Shift */
3088a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MCR_REGAD_MASK 0x001F0000 /* Reg Address Mask */
3098a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MCR_REGAD_SHIFT 16 /* Reg Address Shift */
3108a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MCR_OP_MASK 0x0000C000 /* Operation Code Mask */
3118a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MCR_OP_SHIFT 13 /* Operation Code Shift */
3128a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MCR_OP_READ_MASK 0x00008000 /* Op Code Read Mask */
3138a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MCR_OP_WRITE_MASK 0x00004000 /* Op Code Write Mask */
3148a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MCR_INITIATE_MASK 0x00000800 /* Ready Mask */
3158a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_MCR_READY_MASK 0x00000080 /* Ready Mask */
3168a3b7a25Sdanborkmann@iogearbox.net
3178a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet MDIO interface MIS, MIP, MIE, MIC registers */
3188a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_INT_MIIM_RDY_MASK 0x00000001 /* MIIM Interrupt */
3198a3b7a25Sdanborkmann@iogearbox.net
3208a3b7a25Sdanborkmann@iogearbox.net /* Bit masks for Axi Ethernet UAW1 register */
321850a7503SMichal Simek /* Station address bits [47:32]; Station address
322850a7503SMichal Simek * bits [31:0] are stored in register UAW0
323850a7503SMichal Simek */
324850a7503SMichal Simek #define XAE_UAW1_UNICASTADDR_MASK 0x0000FFFF
3258a3b7a25Sdanborkmann@iogearbox.net
3269ff2f816SRadhey Shyam Pandey /* Bit masks for Axi Ethernet FMC register */
3278a3b7a25Sdanborkmann@iogearbox.net #define XAE_FMI_PM_MASK 0x80000000 /* Promis. mode enable */
3288a3b7a25Sdanborkmann@iogearbox.net #define XAE_FMI_IND_MASK 0x00000003 /* Index Mask */
3298a3b7a25Sdanborkmann@iogearbox.net
3308a3b7a25Sdanborkmann@iogearbox.net #define XAE_MDIO_DIV_DFT 29 /* Default MDIO clock divisor */
3318a3b7a25Sdanborkmann@iogearbox.net
3328a3b7a25Sdanborkmann@iogearbox.net /* Defines for different options for C_PHY_TYPE parameter in Axi Ethernet IP */
3338a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHY_TYPE_MII 0
3348a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHY_TYPE_GMII 1
3358a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHY_TYPE_RGMII_1_3 2
3368a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHY_TYPE_RGMII_2_0 3
3378a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHY_TYPE_SGMII 4
3388a3b7a25Sdanborkmann@iogearbox.net #define XAE_PHY_TYPE_1000BASE_X 5
3398a3b7a25Sdanborkmann@iogearbox.net
340850a7503SMichal Simek /* Total number of entries in the hardware multicast table. */
341850a7503SMichal Simek #define XAE_MULTICAST_CAM_TABLE_NUM 4
3428a3b7a25Sdanborkmann@iogearbox.net
3438a3b7a25Sdanborkmann@iogearbox.net /* Axi Ethernet Synthesis features */
3443ff578c9SAppana Durga Kedareswara Rao #define XAE_FEATURE_PARTIAL_RX_CSUM BIT(0)
3453ff578c9SAppana Durga Kedareswara Rao #define XAE_FEATURE_PARTIAL_TX_CSUM BIT(1)
3463ff578c9SAppana Durga Kedareswara Rao #define XAE_FEATURE_FULL_RX_CSUM BIT(2)
3473ff578c9SAppana Durga Kedareswara Rao #define XAE_FEATURE_FULL_TX_CSUM BIT(3)
3483ff578c9SAppana Durga Kedareswara Rao #define XAE_FEATURE_DMA_64BIT BIT(4)
34976abb5d6SSean Anderson #define XAE_FEATURE_STATS BIT(5)
3508a3b7a25Sdanborkmann@iogearbox.net
3518a3b7a25Sdanborkmann@iogearbox.net #define XAE_NO_CSUM_OFFLOAD 0
3528a3b7a25Sdanborkmann@iogearbox.net
3538a3b7a25Sdanborkmann@iogearbox.net #define XAE_FULL_CSUM_STATUS_MASK 0x00000038
3548a3b7a25Sdanborkmann@iogearbox.net #define XAE_IP_UDP_CSUM_VALIDATED 0x00000003
3558a3b7a25Sdanborkmann@iogearbox.net #define XAE_IP_TCP_CSUM_VALIDATED 0x00000002
3568a3b7a25Sdanborkmann@iogearbox.net
3578a3b7a25Sdanborkmann@iogearbox.net #define DELAY_OF_ONE_MILLISEC 1000
3588a3b7a25Sdanborkmann@iogearbox.net
3596c8f06bbSRobert Hancock /* Xilinx PCS/PMA PHY register for switching 1000BaseX or SGMII */
3606c8f06bbSRobert Hancock #define XLNX_MII_STD_SELECT_REG 0x11
3616c8f06bbSRobert Hancock #define XLNX_MII_STD_SELECT_SGMII BIT(0)
3626c8f06bbSRobert Hancock
36376abb5d6SSean Anderson /* enum temac_stat - TEMAC statistics counters
36476abb5d6SSean Anderson *
36576abb5d6SSean Anderson * Index of statistics counters within the TEMAC. This must match the
36676abb5d6SSean Anderson * order/offset of hardware registers exactly.
36776abb5d6SSean Anderson */
36876abb5d6SSean Anderson enum temac_stat {
36976abb5d6SSean Anderson STAT_RX_BYTES = 0,
37076abb5d6SSean Anderson STAT_TX_BYTES,
37176abb5d6SSean Anderson STAT_UNDERSIZE_FRAMES,
37276abb5d6SSean Anderson STAT_FRAGMENT_FRAMES,
37376abb5d6SSean Anderson STAT_RX_64_BYTE_FRAMES,
37476abb5d6SSean Anderson STAT_RX_65_127_BYTE_FRAMES,
37576abb5d6SSean Anderson STAT_RX_128_255_BYTE_FRAMES,
37676abb5d6SSean Anderson STAT_RX_256_511_BYTE_FRAMES,
37776abb5d6SSean Anderson STAT_RX_512_1023_BYTE_FRAMES,
37876abb5d6SSean Anderson STAT_RX_1024_MAX_BYTE_FRAMES,
37976abb5d6SSean Anderson STAT_RX_OVERSIZE_FRAMES,
38076abb5d6SSean Anderson STAT_TX_64_BYTE_FRAMES,
38176abb5d6SSean Anderson STAT_TX_65_127_BYTE_FRAMES,
38276abb5d6SSean Anderson STAT_TX_128_255_BYTE_FRAMES,
38376abb5d6SSean Anderson STAT_TX_256_511_BYTE_FRAMES,
38476abb5d6SSean Anderson STAT_TX_512_1023_BYTE_FRAMES,
38576abb5d6SSean Anderson STAT_TX_1024_MAX_BYTE_FRAMES,
38676abb5d6SSean Anderson STAT_TX_OVERSIZE_FRAMES,
38776abb5d6SSean Anderson STAT_RX_GOOD_FRAMES,
38876abb5d6SSean Anderson STAT_RX_FCS_ERRORS,
38976abb5d6SSean Anderson STAT_RX_BROADCAST_FRAMES,
39076abb5d6SSean Anderson STAT_RX_MULTICAST_FRAMES,
39176abb5d6SSean Anderson STAT_RX_CONTROL_FRAMES,
39276abb5d6SSean Anderson STAT_RX_LENGTH_ERRORS,
39376abb5d6SSean Anderson STAT_RX_VLAN_FRAMES,
39476abb5d6SSean Anderson STAT_RX_PAUSE_FRAMES,
39576abb5d6SSean Anderson STAT_RX_CONTROL_OPCODE_ERRORS,
39676abb5d6SSean Anderson STAT_TX_GOOD_FRAMES,
39776abb5d6SSean Anderson STAT_TX_BROADCAST_FRAMES,
39876abb5d6SSean Anderson STAT_TX_MULTICAST_FRAMES,
39976abb5d6SSean Anderson STAT_TX_UNDERRUN_ERRORS,
40076abb5d6SSean Anderson STAT_TX_CONTROL_FRAMES,
40176abb5d6SSean Anderson STAT_TX_VLAN_FRAMES,
40276abb5d6SSean Anderson STAT_TX_PAUSE_FRAMES,
40376abb5d6SSean Anderson STAT_TX_SINGLE_COLLISION_FRAMES,
40476abb5d6SSean Anderson STAT_TX_MULTIPLE_COLLISION_FRAMES,
40576abb5d6SSean Anderson STAT_TX_DEFERRED_FRAMES,
40676abb5d6SSean Anderson STAT_TX_LATE_COLLISIONS,
40776abb5d6SSean Anderson STAT_TX_EXCESS_COLLISIONS,
40876abb5d6SSean Anderson STAT_TX_EXCESS_DEFERRAL,
40976abb5d6SSean Anderson STAT_RX_ALIGNMENT_ERRORS,
41076abb5d6SSean Anderson STAT_TX_PFC_FRAMES,
41176abb5d6SSean Anderson STAT_RX_PFC_FRAMES,
41276abb5d6SSean Anderson STAT_USER_DEFINED0,
41376abb5d6SSean Anderson STAT_USER_DEFINED1,
41476abb5d6SSean Anderson STAT_USER_DEFINED2,
41576abb5d6SSean Anderson STAT_COUNT,
41676abb5d6SSean Anderson };
41776abb5d6SSean Anderson
4188a3b7a25Sdanborkmann@iogearbox.net /**
4198a3b7a25Sdanborkmann@iogearbox.net * struct axidma_bd - Axi Dma buffer descriptor layout
4208a3b7a25Sdanborkmann@iogearbox.net * @next: MM2S/S2MM Next Descriptor Pointer
4214e958f33SAndre Przywara * @next_msb: MM2S/S2MM Next Descriptor Pointer (high 32 bits)
4228a3b7a25Sdanborkmann@iogearbox.net * @phys: MM2S/S2MM Buffer Address
4234e958f33SAndre Przywara * @phys_msb: MM2S/S2MM Buffer Address (high 32 bits)
4248a3b7a25Sdanborkmann@iogearbox.net * @reserved3: Reserved and not used
4258a3b7a25Sdanborkmann@iogearbox.net * @reserved4: Reserved and not used
4268a3b7a25Sdanborkmann@iogearbox.net * @cntrl: MM2S/S2MM Control value
4278a3b7a25Sdanborkmann@iogearbox.net * @status: MM2S/S2MM Status value
4288a3b7a25Sdanborkmann@iogearbox.net * @app0: MM2S/S2MM User Application Field 0.
4298a3b7a25Sdanborkmann@iogearbox.net * @app1: MM2S/S2MM User Application Field 1.
4308a3b7a25Sdanborkmann@iogearbox.net * @app2: MM2S/S2MM User Application Field 2.
4318a3b7a25Sdanborkmann@iogearbox.net * @app3: MM2S/S2MM User Application Field 3.
4328a3b7a25Sdanborkmann@iogearbox.net * @app4: MM2S/S2MM User Application Field 4.
43306c2a5cdSSuraj Gupta * @skb: Pointer to SKB transferred using DMA
4348a3b7a25Sdanborkmann@iogearbox.net */
4358a3b7a25Sdanborkmann@iogearbox.net struct axidma_bd {
4368a3b7a25Sdanborkmann@iogearbox.net u32 next; /* Physical address of next buffer descriptor */
4374e958f33SAndre Przywara u32 next_msb; /* high 32 bits for IP >= v7.1, reserved on older IP */
4388a3b7a25Sdanborkmann@iogearbox.net u32 phys;
4394e958f33SAndre Przywara u32 phys_msb; /* for IP >= v7.1, reserved for older IP */
4408a3b7a25Sdanborkmann@iogearbox.net u32 reserved3;
4418a3b7a25Sdanborkmann@iogearbox.net u32 reserved4;
4428a3b7a25Sdanborkmann@iogearbox.net u32 cntrl;
4438a3b7a25Sdanborkmann@iogearbox.net u32 status;
4448a3b7a25Sdanborkmann@iogearbox.net u32 app0;
4458a3b7a25Sdanborkmann@iogearbox.net u32 app1; /* TX start << 16 | insert */
4468a3b7a25Sdanborkmann@iogearbox.net u32 app2; /* TX csum seed */
4478a3b7a25Sdanborkmann@iogearbox.net u32 app3;
44823e6b2dcSRobert Hancock u32 app4; /* Last field used by HW */
44923e6b2dcSRobert Hancock struct sk_buff *skb;
45023e6b2dcSRobert Hancock } __aligned(XAXIDMA_BD_MINIMUM_ALIGNMENT);
4518a3b7a25Sdanborkmann@iogearbox.net
452b11bfb9aSRobert Hancock #define XAE_NUM_MISC_CLOCKS 3
453b11bfb9aSRobert Hancock
4548a3b7a25Sdanborkmann@iogearbox.net /**
4556a91b846SRadhey Shyam Pandey * struct skbuf_dma_descriptor - skb for each dma descriptor
4566a91b846SRadhey Shyam Pandey * @sgl: Pointer for sglist.
4576a91b846SRadhey Shyam Pandey * @desc: Pointer to dma descriptor.
4586a91b846SRadhey Shyam Pandey * @dma_address: dma address of sglist.
4596a91b846SRadhey Shyam Pandey * @skb: Pointer to SKB transferred using DMA
4606a91b846SRadhey Shyam Pandey * @sg_len: number of entries in the sglist.
4616a91b846SRadhey Shyam Pandey */
4626a91b846SRadhey Shyam Pandey struct skbuf_dma_descriptor {
4636a91b846SRadhey Shyam Pandey struct scatterlist sgl[MAX_SKB_FRAGS + 1];
4646a91b846SRadhey Shyam Pandey struct dma_async_tx_descriptor *desc;
4656a91b846SRadhey Shyam Pandey dma_addr_t dma_address;
4666a91b846SRadhey Shyam Pandey struct sk_buff *skb;
4676a91b846SRadhey Shyam Pandey int sg_len;
4686a91b846SRadhey Shyam Pandey };
4696a91b846SRadhey Shyam Pandey
4706a91b846SRadhey Shyam Pandey /**
4718a3b7a25Sdanborkmann@iogearbox.net * struct axienet_local - axienet private per device data
4728a3b7a25Sdanborkmann@iogearbox.net * @ndev: Pointer for net_device to which it will be attached.
4738a3b7a25Sdanborkmann@iogearbox.net * @dev: Pointer to device structure
4746c8f06bbSRobert Hancock * @phylink: Pointer to phylink instance
4756c8f06bbSRobert Hancock * @phylink_config: phylink configuration settings
4766c8f06bbSRobert Hancock * @pcs_phy: Reference to PCS/PMA PHY if used
4777a86be6aSRussell King (Oracle) * @pcs: phylink pcs structure for PCS PHY
4786c8f06bbSRobert Hancock * @switch_x_sgmii: Whether switchable 1000BaseX/SGMII mode is enabled in the core
479b11bfb9aSRobert Hancock * @axi_clk: AXI4-Lite bus clock
480b11bfb9aSRobert Hancock * @misc_clks: Misc ethernet clocks (AXI4-Stream, Ref, MGT clocks)
4818a3b7a25Sdanborkmann@iogearbox.net * @mii_bus: Pointer to MII bus structure
4826c3cbaa0SRadhey Shyam Pandey * @mii_clk_div: MII bus clock divider value
48388a972d7SRobert Hancock * @regs_start: Resource start for axienet device addresses
4848a3b7a25Sdanborkmann@iogearbox.net * @regs: Base address for the axienet_local device address space
4858a3b7a25Sdanborkmann@iogearbox.net * @dma_regs: Base address for the axidma device address space
4869e2bc267SRobert Hancock * @napi_rx: NAPI RX control structure
487cc37610cSRobert Hancock * @rx_dma_cr: Nominal content of RX DMA control register
4889e2bc267SRobert Hancock * @rx_bd_v: Virtual address of the RX buffer descriptor ring
4899e2bc267SRobert Hancock * @rx_bd_p: Physical address(start address) of the RX buffer descr. ring
4909e2bc267SRobert Hancock * @rx_bd_num: Size of RX buffer descriptor ring
4919e2bc267SRobert Hancock * @rx_bd_ci: Stores the index of the Rx buffer descriptor in the ring being
4929e2bc267SRobert Hancock * accessed currently.
493cb45a8bfSRobert Hancock * @rx_packets: RX packet count for statistics
494cb45a8bfSRobert Hancock * @rx_bytes: RX byte count for statistics
495cb45a8bfSRobert Hancock * @rx_stat_sync: Synchronization object for RX stats
4969e2bc267SRobert Hancock * @napi_tx: NAPI TX control structure
4979e2bc267SRobert Hancock * @tx_dma_cr: Nominal content of TX DMA control register
4989e2bc267SRobert Hancock * @tx_bd_v: Virtual address of the TX buffer descriptor ring
4999e2bc267SRobert Hancock * @tx_bd_p: Physical address(start address) of the TX buffer descr. ring
5009e2bc267SRobert Hancock * @tx_bd_num: Size of TX buffer descriptor ring
5019e2bc267SRobert Hancock * @tx_bd_ci: Stores the next Tx buffer descriptor in the ring that may be
5029e2bc267SRobert Hancock * complete. Only updated at runtime by TX NAPI poll.
5039e2bc267SRobert Hancock * @tx_bd_tail: Stores the index of the next Tx buffer descriptor in the ring
5049e2bc267SRobert Hancock * to be populated.
505cb45a8bfSRobert Hancock * @tx_packets: TX packet count for statistics
506cb45a8bfSRobert Hancock * @tx_bytes: TX byte count for statistics
507cb45a8bfSRobert Hancock * @tx_stat_sync: Synchronization object for TX stats
50876abb5d6SSean Anderson * @hw_stat_base: Base offset for statistics counters. This may be nonzero if
50976abb5d6SSean Anderson * the statistics counteres were reset or wrapped around.
51076abb5d6SSean Anderson * @hw_last_counter: Last-seen value of each statistic counter
51176abb5d6SSean Anderson * @reset_in_progress: Set while we are performing a reset and statistics
51276abb5d6SSean Anderson * counters may be invalid
51376abb5d6SSean Anderson * @hw_stats_seqcount: Sequence counter for @hw_stat_base, @hw_last_counter,
51476abb5d6SSean Anderson * and @reset_in_progress.
51576abb5d6SSean Anderson * @stats_lock: Lock for @hw_stats_seqcount
51676abb5d6SSean Anderson * @stats_work: Work for reading the hardware statistics counters often enough
51776abb5d6SSean Anderson * to catch overflows.
5186c8f06bbSRobert Hancock * @dma_err_task: Work structure to process Axi DMA errors
519858430dbSSean Anderson * @stopping: Set when @dma_err_task shouldn't do anything because we are
520858430dbSSean Anderson * about to stop the device.
5218a3b7a25Sdanborkmann@iogearbox.net * @tx_irq: Axidma TX IRQ number
5228a3b7a25Sdanborkmann@iogearbox.net * @rx_irq: Axidma RX IRQ number
5236c8f06bbSRobert Hancock * @eth_irq: Ethernet core IRQ number
524ee06b172SAlvaro G. M * @phy_mode: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X
5258a3b7a25Sdanborkmann@iogearbox.net * @options: AxiEthernet option word
5268a3b7a25Sdanborkmann@iogearbox.net * @features: Stores the extended features supported by the axienet hw
5278a3b7a25Sdanborkmann@iogearbox.net * @max_frm_size: Stores the maximum size of the frame that can be that
5288a3b7a25Sdanborkmann@iogearbox.net * Txed/Rxed in the existing hardware. If jumbo option is
5298a3b7a25Sdanborkmann@iogearbox.net * supported, the maximum frame size would be 9k. Else it is
5308a3b7a25Sdanborkmann@iogearbox.net * 1522 bytes (assuming support for basic VLAN)
531f080a8c3SSrikanth Thokala * @rxmem: Stores rx memory size for jumbo frame handling.
532b0d081c5SMichal Simek * @coalesce_count_rx: Store the irq coalesce on RX side.
5330b79b8dcSRobert Hancock * @coalesce_usec_rx: IRQ coalesce delay for RX
534b0d081c5SMichal Simek * @coalesce_count_tx: Store the irq coalesce on TX side.
5350b79b8dcSRobert Hancock * @coalesce_usec_tx: IRQ coalesce delay for TX
5366b1b40f7SSarath Babu Naidu Gaddam * @use_dmaengine: flag to check dmaengine framework usage.
5376a91b846SRadhey Shyam Pandey * @tx_chan: TX DMA channel.
5386a91b846SRadhey Shyam Pandey * @rx_chan: RX DMA channel.
5396a91b846SRadhey Shyam Pandey * @tx_skb_ring: Pointer to TX skb ring buffer array.
5406a91b846SRadhey Shyam Pandey * @rx_skb_ring: Pointer to RX skb ring buffer array.
5416a91b846SRadhey Shyam Pandey * @tx_ring_head: TX skb ring buffer head index.
5426a91b846SRadhey Shyam Pandey * @tx_ring_tail: TX skb ring buffer tail index.
5436a91b846SRadhey Shyam Pandey * @rx_ring_head: RX skb ring buffer head index.
5446a91b846SRadhey Shyam Pandey * @rx_ring_tail: RX skb ring buffer tail index.
5458a3b7a25Sdanborkmann@iogearbox.net */
5468a3b7a25Sdanborkmann@iogearbox.net struct axienet_local {
5478a3b7a25Sdanborkmann@iogearbox.net struct net_device *ndev;
5488a3b7a25Sdanborkmann@iogearbox.net struct device *dev;
5498a3b7a25Sdanborkmann@iogearbox.net
550f5203a3dSRobert Hancock struct phylink *phylink;
551f5203a3dSRobert Hancock struct phylink_config phylink_config;
552f5203a3dSRobert Hancock
5531a025560SRobert Hancock struct mdio_device *pcs_phy;
5547a86be6aSRussell King (Oracle) struct phylink_pcs pcs;
5551a025560SRobert Hancock
5566c8f06bbSRobert Hancock bool switch_x_sgmii;
5576c8f06bbSRobert Hancock
558b11bfb9aSRobert Hancock struct clk *axi_clk;
559b11bfb9aSRobert Hancock struct clk_bulk_data misc_clks[XAE_NUM_MISC_CLOCKS];
56009a0354cSRobert Hancock
5616c8f06bbSRobert Hancock struct mii_bus *mii_bus;
5626c8f06bbSRobert Hancock u8 mii_clk_div;
5638a3b7a25Sdanborkmann@iogearbox.net
56488a972d7SRobert Hancock resource_size_t regs_start;
5658a3b7a25Sdanborkmann@iogearbox.net void __iomem *regs;
5668a3b7a25Sdanborkmann@iogearbox.net void __iomem *dma_regs;
5678a3b7a25Sdanborkmann@iogearbox.net
5689e2bc267SRobert Hancock struct napi_struct napi_rx;
569cc37610cSRobert Hancock u32 rx_dma_cr;
5709e2bc267SRobert Hancock struct axidma_bd *rx_bd_v;
5719e2bc267SRobert Hancock dma_addr_t rx_bd_p;
5729e2bc267SRobert Hancock u32 rx_bd_num;
5739e2bc267SRobert Hancock u32 rx_bd_ci;
574cb45a8bfSRobert Hancock u64_stats_t rx_packets;
575cb45a8bfSRobert Hancock u64_stats_t rx_bytes;
576cb45a8bfSRobert Hancock struct u64_stats_sync rx_stat_sync;
5779e2bc267SRobert Hancock
5789e2bc267SRobert Hancock struct napi_struct napi_tx;
5799e2bc267SRobert Hancock u32 tx_dma_cr;
5809e2bc267SRobert Hancock struct axidma_bd *tx_bd_v;
5819e2bc267SRobert Hancock dma_addr_t tx_bd_p;
5829e2bc267SRobert Hancock u32 tx_bd_num;
5839e2bc267SRobert Hancock u32 tx_bd_ci;
5849e2bc267SRobert Hancock u32 tx_bd_tail;
585cb45a8bfSRobert Hancock u64_stats_t tx_packets;
586cb45a8bfSRobert Hancock u64_stats_t tx_bytes;
587cb45a8bfSRobert Hancock struct u64_stats_sync tx_stat_sync;
588cc37610cSRobert Hancock
58976abb5d6SSean Anderson u64 hw_stat_base[STAT_COUNT];
59076abb5d6SSean Anderson u32 hw_last_counter[STAT_COUNT];
59176abb5d6SSean Anderson seqcount_mutex_t hw_stats_seqcount;
59276abb5d6SSean Anderson struct mutex stats_lock;
59376abb5d6SSean Anderson struct delayed_work stats_work;
59476abb5d6SSean Anderson bool reset_in_progress;
59576abb5d6SSean Anderson
59624201a64SAndre Przywara struct work_struct dma_err_task;
597858430dbSSean Anderson bool stopping;
5988a3b7a25Sdanborkmann@iogearbox.net
5998a3b7a25Sdanborkmann@iogearbox.net int tx_irq;
6008a3b7a25Sdanborkmann@iogearbox.net int rx_irq;
601522856ceSRobert Hancock int eth_irq;
602ee06b172SAlvaro G. M phy_interface_t phy_mode;
6038a3b7a25Sdanborkmann@iogearbox.net
6046c8f06bbSRobert Hancock u32 options;
6058a3b7a25Sdanborkmann@iogearbox.net u32 features;
6068a3b7a25Sdanborkmann@iogearbox.net
6078a3b7a25Sdanborkmann@iogearbox.net u32 max_frm_size;
608f080a8c3SSrikanth Thokala u32 rxmem;
6098a3b7a25Sdanborkmann@iogearbox.net
6108a3b7a25Sdanborkmann@iogearbox.net u32 coalesce_count_rx;
6110b79b8dcSRobert Hancock u32 coalesce_usec_rx;
6128a3b7a25Sdanborkmann@iogearbox.net u32 coalesce_count_tx;
6130b79b8dcSRobert Hancock u32 coalesce_usec_tx;
6146b1b40f7SSarath Babu Naidu Gaddam u8 use_dmaengine;
6156a91b846SRadhey Shyam Pandey struct dma_chan *tx_chan;
6166a91b846SRadhey Shyam Pandey struct dma_chan *rx_chan;
6176a91b846SRadhey Shyam Pandey struct skbuf_dma_descriptor **tx_skb_ring;
6186a91b846SRadhey Shyam Pandey struct skbuf_dma_descriptor **rx_skb_ring;
6196a91b846SRadhey Shyam Pandey int tx_ring_head;
6206a91b846SRadhey Shyam Pandey int tx_ring_tail;
6216a91b846SRadhey Shyam Pandey int rx_ring_head;
6226a91b846SRadhey Shyam Pandey int rx_ring_tail;
6238a3b7a25Sdanborkmann@iogearbox.net };
6248a3b7a25Sdanborkmann@iogearbox.net
6258a3b7a25Sdanborkmann@iogearbox.net /**
62606c2a5cdSSuraj Gupta * struct axienet_option - Used to set axi ethernet hardware options
6278a3b7a25Sdanborkmann@iogearbox.net * @opt: Option to be set.
6288a3b7a25Sdanborkmann@iogearbox.net * @reg: Register offset to be written for setting the option
6298a3b7a25Sdanborkmann@iogearbox.net * @m_or: Mask to be ORed for setting the option in the register
6308a3b7a25Sdanborkmann@iogearbox.net */
6318a3b7a25Sdanborkmann@iogearbox.net struct axienet_option {
6328a3b7a25Sdanborkmann@iogearbox.net u32 opt;
6338a3b7a25Sdanborkmann@iogearbox.net u32 reg;
6348a3b7a25Sdanborkmann@iogearbox.net u32 m_or;
6358a3b7a25Sdanborkmann@iogearbox.net };
6368a3b7a25Sdanborkmann@iogearbox.net
6378a3b7a25Sdanborkmann@iogearbox.net /**
6388a3b7a25Sdanborkmann@iogearbox.net * axienet_ior - Memory mapped Axi Ethernet register read
6398a3b7a25Sdanborkmann@iogearbox.net * @lp: Pointer to axienet local structure
6408a3b7a25Sdanborkmann@iogearbox.net * @offset: Address offset from the base address of Axi Ethernet core
6418a3b7a25Sdanborkmann@iogearbox.net *
642b0d081c5SMichal Simek * Return: The contents of the Axi Ethernet register
6438a3b7a25Sdanborkmann@iogearbox.net *
6448a3b7a25Sdanborkmann@iogearbox.net * This function returns the contents of the corresponding register.
6458a3b7a25Sdanborkmann@iogearbox.net */
axienet_ior(struct axienet_local * lp,off_t offset)6468a3b7a25Sdanborkmann@iogearbox.net static inline u32 axienet_ior(struct axienet_local *lp, off_t offset)
6478a3b7a25Sdanborkmann@iogearbox.net {
648d85f5f3eSRobert Hancock return ioread32(lp->regs + offset);
6498a3b7a25Sdanborkmann@iogearbox.net }
6508a3b7a25Sdanborkmann@iogearbox.net
axinet_ior_read_mcr(struct axienet_local * lp)651882119ffSKurt Kanzenbach static inline u32 axinet_ior_read_mcr(struct axienet_local *lp)
652882119ffSKurt Kanzenbach {
653882119ffSKurt Kanzenbach return axienet_ior(lp, XAE_MDIO_MCR_OFFSET);
654882119ffSKurt Kanzenbach }
655882119ffSKurt Kanzenbach
axienet_lock_mii(struct axienet_local * lp)656de9c7854SDaniel Mack static inline void axienet_lock_mii(struct axienet_local *lp)
657de9c7854SDaniel Mack {
658de9c7854SDaniel Mack if (lp->mii_bus)
659de9c7854SDaniel Mack mutex_lock(&lp->mii_bus->mdio_lock);
660de9c7854SDaniel Mack }
661de9c7854SDaniel Mack
axienet_unlock_mii(struct axienet_local * lp)662de9c7854SDaniel Mack static inline void axienet_unlock_mii(struct axienet_local *lp)
663de9c7854SDaniel Mack {
664de9c7854SDaniel Mack if (lp->mii_bus)
665de9c7854SDaniel Mack mutex_unlock(&lp->mii_bus->mdio_lock);
666de9c7854SDaniel Mack }
667de9c7854SDaniel Mack
6688a3b7a25Sdanborkmann@iogearbox.net /**
6698a3b7a25Sdanborkmann@iogearbox.net * axienet_iow - Memory mapped Axi Ethernet register write
6708a3b7a25Sdanborkmann@iogearbox.net * @lp: Pointer to axienet local structure
6718a3b7a25Sdanborkmann@iogearbox.net * @offset: Address offset from the base address of Axi Ethernet core
6728a3b7a25Sdanborkmann@iogearbox.net * @value: Value to be written into the Axi Ethernet register
6738a3b7a25Sdanborkmann@iogearbox.net *
6748a3b7a25Sdanborkmann@iogearbox.net * This function writes the desired value into the corresponding Axi Ethernet
6758a3b7a25Sdanborkmann@iogearbox.net * register.
6768a3b7a25Sdanborkmann@iogearbox.net */
axienet_iow(struct axienet_local * lp,off_t offset,u32 value)6778a3b7a25Sdanborkmann@iogearbox.net static inline void axienet_iow(struct axienet_local *lp, off_t offset,
6788a3b7a25Sdanborkmann@iogearbox.net u32 value)
6798a3b7a25Sdanborkmann@iogearbox.net {
680d85f5f3eSRobert Hancock iowrite32(value, lp->regs + offset);
6818a3b7a25Sdanborkmann@iogearbox.net }
6828a3b7a25Sdanborkmann@iogearbox.net
68300be43a7SAndy Chiu /**
68400be43a7SAndy Chiu * axienet_dma_out32 - Memory mapped Axi DMA register write.
68500be43a7SAndy Chiu * @lp: Pointer to axienet local structure
68600be43a7SAndy Chiu * @reg: Address offset from the base address of the Axi DMA core
68700be43a7SAndy Chiu * @value: Value to be written into the Axi DMA register
68800be43a7SAndy Chiu *
68900be43a7SAndy Chiu * This function writes the desired value into the corresponding Axi DMA
69000be43a7SAndy Chiu * register.
69100be43a7SAndy Chiu */
69200be43a7SAndy Chiu
axienet_dma_out32(struct axienet_local * lp,off_t reg,u32 value)69300be43a7SAndy Chiu static inline void axienet_dma_out32(struct axienet_local *lp,
69400be43a7SAndy Chiu off_t reg, u32 value)
69500be43a7SAndy Chiu {
69600be43a7SAndy Chiu iowrite32(value, lp->dma_regs + reg);
69700be43a7SAndy Chiu }
69800be43a7SAndy Chiu
6995f7b8415SDavid S. Miller #if defined(CONFIG_64BIT) && defined(iowrite64)
700b690f8dfSAndy Chiu /**
701b690f8dfSAndy Chiu * axienet_dma_out64 - Memory mapped Axi DMA register write.
702b690f8dfSAndy Chiu * @lp: Pointer to axienet local structure
703b690f8dfSAndy Chiu * @reg: Address offset from the base address of the Axi DMA core
704b690f8dfSAndy Chiu * @value: Value to be written into the Axi DMA register
705b690f8dfSAndy Chiu *
706b690f8dfSAndy Chiu * This function writes the desired value into the corresponding Axi DMA
707b690f8dfSAndy Chiu * register.
708b690f8dfSAndy Chiu */
axienet_dma_out64(struct axienet_local * lp,off_t reg,u64 value)709b690f8dfSAndy Chiu static inline void axienet_dma_out64(struct axienet_local *lp,
710b690f8dfSAndy Chiu off_t reg, u64 value)
711b690f8dfSAndy Chiu {
712b690f8dfSAndy Chiu iowrite64(value, lp->dma_regs + reg);
713b690f8dfSAndy Chiu }
714b690f8dfSAndy Chiu
axienet_dma_out_addr(struct axienet_local * lp,off_t reg,dma_addr_t addr)7155f7b8415SDavid S. Miller static inline void axienet_dma_out_addr(struct axienet_local *lp, off_t reg,
71600be43a7SAndy Chiu dma_addr_t addr)
71700be43a7SAndy Chiu {
71800be43a7SAndy Chiu if (lp->features & XAE_FEATURE_DMA_64BIT)
719b690f8dfSAndy Chiu axienet_dma_out64(lp, reg, addr);
720b690f8dfSAndy Chiu else
721b690f8dfSAndy Chiu axienet_dma_out32(lp, reg, lower_32_bits(addr));
72200be43a7SAndy Chiu }
72300be43a7SAndy Chiu
72400be43a7SAndy Chiu #else /* CONFIG_64BIT */
72500be43a7SAndy Chiu
axienet_dma_out_addr(struct axienet_local * lp,off_t reg,dma_addr_t addr)7265f7b8415SDavid S. Miller static inline void axienet_dma_out_addr(struct axienet_local *lp, off_t reg,
72700be43a7SAndy Chiu dma_addr_t addr)
72800be43a7SAndy Chiu {
72900be43a7SAndy Chiu axienet_dma_out32(lp, reg, lower_32_bits(addr));
73000be43a7SAndy Chiu }
73100be43a7SAndy Chiu
73200be43a7SAndy Chiu #endif /* CONFIG_64BIT */
73300be43a7SAndy Chiu
7348a3b7a25Sdanborkmann@iogearbox.net /* Function prototypes visible in xilinx_axienet_mdio.c for other files */
73509a0354cSRobert Hancock int axienet_mdio_setup(struct axienet_local *lp);
7368a3b7a25Sdanborkmann@iogearbox.net void axienet_mdio_teardown(struct axienet_local *lp);
7378a3b7a25Sdanborkmann@iogearbox.net
7388a3b7a25Sdanborkmann@iogearbox.net #endif /* XILINX_AXI_ENET_H */
739