1 /* 2 * Copyright (c) 2017 Stormshield. 3 * Copyright (c) 2017 Semihalf. 4 * Copyright (c) 2015 Internet Initiative Japan Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 * 28 */ 29 30 #ifndef _IF_MVNETAREG_H_ 31 #define _IF_MVNETAREG_H_ 32 33 #if BYTE_ORDER == BIG_ENDIAN 34 #error "BIG ENDIAN not supported" 35 #endif 36 37 #define MVNETA_SIZE 0x4000 38 39 #define MVNETA_NWINDOW 6 40 #define MVNETA_NREMAP 4 41 42 #define MVNETA_MAX_QUEUE_SIZE 8 43 #define MVNETA_RX_QNUM_MAX 1 44 /* XXX: Currently multi-queue can be used on the Tx side only */ 45 #ifdef MVNETA_MULTIQUEUE 46 #define MVNETA_TX_QNUM_MAX 2 47 #else 48 #define MVNETA_TX_QNUM_MAX 1 49 #endif 50 51 #if MVNETA_TX_QNUM_MAX & (MVNETA_TX_QNUM_MAX - 1) != 0 52 #error "MVNETA_TX_QNUM_MAX Should be a power of 2" 53 #endif 54 #if MVNETA_RX_QNUM_MAX & (MVNETA_RX_QNUM_MAX - 1) != 0 55 #error "MVNETA_RX_QNUM_MAX Should be a power of 2" 56 #endif 57 58 #define MVNETA_QUEUE(n) (1 << (n)) 59 #define MVNETA_QUEUE_ALL 0xff 60 #define MVNETA_TX_QUEUE_ALL ((1<<MVNETA_TX_QNUM_MAX)-1) 61 #define MVNETA_RX_QUEUE_ALL ((1<<MVNETA_RX_QNUM_MAX)-1) 62 63 /* 64 * Ethernet Unit Registers 65 * GbE0 BASE 0x00007.0000 SIZE 0x4000 66 * GbE1 BASE 0x00007.4000 SIZE 0x4000 67 * 68 * TBD: reasonable bus space submapping.... 69 */ 70 /* Address Decoder Registers */ 71 #define MVNETA_BASEADDR(n) (0x2200 + ((n) << 3)) /* Base Address */ 72 #define MVNETA_S(n) (0x2204 + ((n) << 3)) /* Size */ 73 #define MVNETA_HA(n) (0x2280 + ((n) << 2)) /* High Address Remap */ 74 #define MVNETA_BARE 0x2290 /* Base Address Enable */ 75 #define MVNETA_EPAP 0x2294 /* Ethernet Port Access Protect */ 76 77 /* Global Miscellaneous Registers */ 78 #define MVNETA_PHYADDR 0x2000 79 #define MVNETA_SMI 0x2004 80 #define MVNETA_EUDA 0x2008 /* Ethernet Unit Default Address */ 81 #define MVNETA_EUDID 0x200c /* Ethernet Unit Default ID */ 82 #define MVNETA_MBUS_CONF 0x2010 /* MBUS configuration */ 83 #define MVNETA_MBUS_RETRY_EN 0x20 /* MBUS transactions retry enable */ 84 #define MVNETA_EUIC 0x2080 /* Ethernet Unit Interrupt Cause */ 85 #define MVNETA_EUIM 0x2084 /* Ethernet Unit Interrupt Mask */ 86 #define MVNETA_EUEA 0x2094 /* Ethernet Unit Error Address */ 87 #define MVNETA_EUIAE 0x2098 /* Ethernet Unit Internal Addr Error */ 88 #define MVNETA_EUC 0x20b0 /* Ethernet Unit Control */ 89 90 /* Miscellaneous Registers */ 91 #define MVNETA_SDC 0x241c /* SDMA Configuration */ 92 93 /* Networking Controller Miscellaneous Registers */ 94 #define MVNETA_PACC 0x2500 /* Port Acceleration Mode */ 95 #define MVNETA_PV 0x25bc /* Port Version */ 96 97 /* Rx DMA Hardware Parser Registers */ 98 #define MVNETA_EVLANE 0x2410 /* VLAN EtherType */ 99 #define MVNETA_MACAL 0x2414 /* MAC Address Low */ 100 #define MVNETA_MACAH 0x2418 /* MAC Address High */ 101 #define MVNETA_NDSCP 7 102 #define MVNETA_DSCP(n) (0x2420 + ((n) << 2)) 103 #define MVNETA_VPT2P 0x2440 /* VLAN Priority Tag to Priority */ 104 #define MVNETA_ETP 0x24bc /* Ethernet Type Priority */ 105 #define MVNETA_NDFSMT 64 106 #define MVNETA_DFSMT(n) (0x3400 + ((n) << 2)) 107 /* Destination Address Filter Special Multicast Table */ 108 #define MVNETA_NDFOMT 64 109 #define MVNETA_DFOMT(n) (0x3500 + ((n) << 2)) 110 /* Destination Address Filter Other Multicast Table */ 111 #define MVNETA_NDFUT 4 112 #define MVNETA_DFUT(n) (0x3600 + ((n) << 2)) 113 /* Destination Address Filter Unicast Table */ 114 115 /* Rx DMA Miscellaneous Registers */ 116 #define MVNETA_PMFS 0x247c /* Port Rx Minimal Frame Size */ 117 #define MVNETA_PDFC 0x2484 /* Port Rx Discard Frame Counter */ 118 #define MVNETA_POFC 0x2488 /* Port Overrun Frame Counter */ 119 #define MVNETA_RQC 0x2680 /* Receive Queue Command */ 120 121 /* Rx DMA Networking Controller Miscellaneous Registers */ 122 #define MVNETA_PRXC(q) (0x1400 + ((q) << 2)) /*Port RX queues Config*/ 123 #define MVNETA_PRXSNP(q) (0x1420 + ((q) << 2)) /* Port RX queues Snoop */ 124 #define MVNETA_PRXDQA(q) (0x1480 + ((q) << 2)) /*P RXqueues desc Q Addr*/ 125 #define MVNETA_PRXDQS(q) (0x14a0 + ((q) << 2)) /*P RXqueues desc Q Size*/ 126 #define MVNETA_PRXDQTH(q) (0x14c0 + ((q) << 2)) /*P RXqueues desc Q Thrs*/ 127 #define MVNETA_PRXS(q) (0x14e0 + ((q) << 2)) /*Port RX queues Status */ 128 #define MVNETA_PRXSU(q) (0x1500 + ((q) << 2)) /*P RXqueues Stat Update*/ 129 #define MVNETA_PRXDI(q) (0x1520 + ((q) << 2)) /*P RXqueues Stat Update*/ 130 #define MVNETA_PRXINIT 0x1cc0 /* Port RX Initialization */ 131 132 /* Rx DMA Wake on LAN Registers 0x3690 - 0x36b8 */ 133 134 /* Tx DMA Miscellaneous Registers */ 135 #define MVNETA_TQC 0x2448 /* Transmit Queue Command */ 136 #define MVNETA_TQC_1 0x24e4 137 #define MVNETA_PXTFTT 0x2478 /* Port Tx FIFO Threshold */ 138 #define MVNETA_TXBADFCS 0x3cc0 /*Tx Bad FCS Transmitted Pckts Counter*/ 139 #define MVNETA_TXDROPPED 0x3cc4 /* Tx Dropped Packets Counter */ 140 141 /* Tx DMA Networking Controller Miscellaneous Registers */ 142 #define MVNETA_PTXDQA(q) (0x3c00 + ((q) << 2)) /*P TXqueues desc Q Addr*/ 143 #define MVNETA_PTXDQS(q) (0x3c20 + ((q) << 2)) /*P TXqueues desc Q Size*/ 144 #define MVNETA_PTXS(q) (0x3c40 + ((q) << 2)) /* Port TX queues Status*/ 145 #define MVNETA_PTXSU(q) (0x3c60 + ((q) << 2)) /*P TXqueues Stat Update*/ 146 #define MVNETA_PTXDI(q) (0x3c80 + ((q) << 2)) /* P TXqueues Desc Index*/ 147 #define MVNETA_TXTBC(q) (0x3ca0 + ((q) << 2)) /* TX Trans-ed Buf Count*/ 148 #define MVNETA_PTXINIT 0x3cf0 /* Port TX Initialization */ 149 150 /* Tx DMA Packet Modification Registers */ 151 #define MVNETA_NMH 15 152 #define MVNETA_TXMH(n) (0x3d44 + ((n) << 2)) 153 #define MVNETA_TXMTU 0x3d88 154 155 /* Tx DMA Queue Arbiter Registers (Version 1) */ 156 #define MVNETA_TQFPC_V1 0x24dc /* Transmit Queue Fixed Priority Cfg */ 157 #define MVNETA_TQTBC_V1 0x24e0 /* Transmit Queue Token-Bucket Cfg */ 158 #define MVNETA_MTU_V1 0x24e8 /* MTU */ 159 #define MVNETA_PMTBS_V1 0x24ec /* Port Max Token-Bucket Size */ 160 #define MVNETA_TQTBCOUNT_V1(q) (0x2700 + ((q) << 4)) 161 /* Transmit Queue Token-Bucket Counter */ 162 #define MVNETA_TQTBCONFIG_V1(q) (0x2704 + ((q) << 4)) 163 /* Transmit Queue Token-Bucket Configuration */ 164 #define MVNETA_PTTBC_V1 0x2740 /* Port Transmit Backet Counter */ 165 166 /* Tx DMA Queue Arbiter Registers (Version 3) */ 167 #define MVNETA_TQC1_V3 0x3e00 /* Transmit Queue Command1 */ 168 #define MVNETA_TQFPC_V3 0x3e04 /* Transmit Queue Fixed Priority Cfg */ 169 #define MVNETA_BRC_V3 0x3e08 /* Basic Refill No of Clocks */ 170 #define MVNETA_MTU_V3 0x3e0c /* MTU */ 171 #define MVNETA_PREFILL_V3 0x3e10 /* Port Backet Refill */ 172 #define MVNETA_PMTBS_V3 0x3e14 /* Port Max Token-Bucket Size */ 173 #define MVNETA_QREFILL_V3(q) (0x3e20 + ((q) << 2)) 174 /* Transmit Queue Refill */ 175 #define MVNETA_QMTBS_V3(q) (0x3e40 + ((q) << 2)) 176 /* Transmit Queue Max Token-Bucket Size */ 177 #define MVNETA_QTTBC_V3(q) (0x3e60 + ((q) << 2)) 178 /* Transmit Queue Token-Bucket Counter */ 179 #define MVNETA_TQAC_V3(q) (0x3e80 + ((q) << 2)) 180 /* Transmit Queue Arbiter Cfg */ 181 #define MVNETA_TQIPG_V3(q) (0x3ea0 + ((q) << 2)) 182 /* Transmit Queue IPG(valid q=2..3) */ 183 #define MVNETA_HITKNINLOPKT_V3 0x3eb0 /* High Token in Low Packet */ 184 #define MVNETA_HITKNINASYNCPKT_V3 0x3eb4 /* High Token in Async Packet */ 185 #define MVNETA_LOTKNINASYNCPKT_V3 0x3eb8 /* Low Token in Async Packet */ 186 #define MVNETA_TS_V3 0x3ebc /* Token Speed */ 187 188 /* RX_TX DMA Registers */ 189 #define MVNETA_PXC 0x2400 /* Port Configuration */ 190 #define MVNETA_PXCX 0x2404 /* Port Configuration Extend */ 191 #define MVNETA_MH 0x2454 /* Marvell Header */ 192 193 /* Serial(SMI/MII) Registers */ 194 #define MVNETA_PSC0 0x243c /* Port Serial Control0 */ 195 #define MVNETA_PS0 0x2444 /* Ethernet Port Status */ 196 #define MVNETA_PSERDESCFG 0x24a0 /* Serdes Configuration */ 197 #define MVNETA_PSERDESSTS 0x24a4 /* Serdes Status */ 198 #define MVNETA_PSOMSCD 0x24f4 /* One mS Clock Divider */ 199 #define MVNETA_PSPFCCD 0x24f8 /* Periodic Flow Control Clock Divider*/ 200 201 /* Gigabit Ethernet MAC Serial Parameters Configuration Registers */ 202 #define MVNETA_PSPC 0x2c14 /* Port Serial Parameters Config */ 203 #define MVNETA_PSP1C 0x2c94 /* Port Serial Parameters 1 Config */ 204 205 /* Gigabit Ethernet Auto-Negotiation Configuration Registers */ 206 #define MVNETA_PANC 0x2c0c /* Port Auto-Negotiation Configuration*/ 207 208 /* Gigabit Ethernet MAC Control Registers */ 209 #define MVNETA_PMACC0 0x2c00 /* Port MAC Control 0 */ 210 #define MVNETA_PMACC1 0x2c04 /* Port MAC Control 1 */ 211 #define MVNETA_PMACC2 0x2c08 /* Port MAC Control 2 */ 212 #define MVNETA_PMACC3 0x2c48 /* Port MAC Control 3 */ 213 #define MVNETA_CCFCPST(p) (0x2c58 + ((p) << 2)) /*CCFC Port Speed Timerp*/ 214 #define MVNETA_PMACC4 0x2c90 /* Port MAC Control 4 */ 215 216 /* Gigabit Ethernet MAC Interrupt Registers */ 217 #define MVNETA_PIC 0x2c20 218 #define MVNETA_PIM 0x2c24 219 220 /* Gigabit Ethernet Low Power Idle Registers */ 221 #define MVNETA_LPIC0 0x2cc0 /* LowPowerIdle control 0 */ 222 #define MVNETA_LPIC1 0x2cc4 /* LPI control 1 */ 223 #define MVNETA_LPIC2 0x2cc8 /* LPI control 2 */ 224 #define MVNETA_LPIS 0x2ccc /* LPI status */ 225 #define MVNETA_LPIC 0x2cd0 /* LPI counter */ 226 227 /* Gigabit Ethernet MAC PRBS Check Status Registers */ 228 #define MVNETA_PPRBSS 0x2c38 /* Port PRBS Status */ 229 #define MVNETA_PPRBSEC 0x2c3c /* Port PRBS Error Counter */ 230 231 /* Gigabit Ethernet MAC Status Registers */ 232 #define MVNETA_PSR 0x2c10 /* Port Status Register0 */ 233 234 /* Networking Controller Interrupt Registers */ 235 #define MVNETA_PCP2Q(cpu) (0x2540 + ((cpu) << 2)) 236 #define MVNETA_PRXITTH(q) (0x2580 + ((q) << 2)) 237 /* Port Rx Interrupt Threshold */ 238 #define MVNETA_PRXTXTIC 0x25a0 /*Port RX_TX Threshold Interrupt Cause*/ 239 #define MVNETA_PRXTXTIM 0x25a4 /*Port RX_TX Threshold Interrupt Mask */ 240 #define MVNETA_PRXTXIC 0x25a8 /* Port RX_TX Interrupt Cause */ 241 #define MVNETA_PRXTXIM 0x25ac /* Port RX_TX Interrupt Mask */ 242 #define MVNETA_PMIC 0x25b0 /* Port Misc Interrupt Cause */ 243 #define MVNETA_PMIM 0x25b4 /* Port Misc Interrupt Mask */ 244 #define MVNETA_PIE 0x25b8 /* Port Interrupt Enable */ 245 #define MVNETA_PSNPCFG 0x25e4 /* Port Snoop Config */ 246 #define MVNETA_PSNPCFG_DESCSNP_MASK (0x3 << 4) 247 #define MVNETA_PSNPCFG_BUFSNP_MASK (0x3 << 8) 248 249 /* Miscellaneous Interrupt Registers */ 250 #define MVNETA_PEUIAE 0x2494 /* Port Internal Address Error */ 251 252 /* SGMII PHY Registers */ 253 #define MVNETA_PPLLC 0x2e04 /* Power and PLL Control */ 254 #define MVNETA_TESTC0 0x2e54 /* PHY Test Control 0 */ 255 #define MVNETA_TESTPRBSEC0 0x2e7c /* PHY Test PRBS Error Counter 0 */ 256 #define MVNETA_TESTPRBSEC1 0x2e80 /* PHY Test PRBS Error Counter 1 */ 257 #define MVNETA_TESTOOB0 0x2e84 /* PHY Test OOB 0 */ 258 #define MVNETA_DLE 0x2e8c /* Digital Loopback Enable */ 259 #define MVNETA_RCS 0x2f18 /* Reference Clock Select */ 260 #define MVNETA_COMPHYC 0x2f18 /* COMPHY Control */ 261 262 /* 263 * Ethernet MAC MIB Registers 264 * GbE0 BASE 0x00007.3000 265 * GbE1 BASE 0x00007.7000 266 */ 267 /* MAC MIB Counters 0x3000 - 0x307c */ 268 #define MVNETA_PORTMIB_BASE 0x3000 269 #define MVNETA_PORTMIB_SIZE 0x0080 270 #define MVNETA_PORTMIB_NOCOUNTER 30 271 272 /* Rx */ 273 #define MVNETA_MIB_RX_GOOD_OCT 0x00 /* 64bit */ 274 #define MVNETA_MIB_RX_BAD_OCT 0x08 275 #define MVNETA_MIB_RX_GOOD_FRAME 0x10 276 #define MVNETA_MIB_RX_BAD_FRAME 0x14 277 #define MVNETA_MIB_RX_BCAST_FRAME 0x18 278 #define MVNETA_MIB_RX_MCAST_FRAME 0x1c 279 #define MVNETA_MIB_RX_FRAME64_OCT 0x20 280 #define MVNETA_MIB_RX_FRAME127_OCT 0x24 281 #define MVNETA_MIB_RX_FRAME255_OCT 0x28 282 #define MVNETA_MIB_RX_FRAME511_OCT 0x2c 283 #define MVNETA_MIB_RX_FRAME1023_OCT 0x30 284 #define MVNETA_MIB_RX_FRAMEMAX_OCT 0x34 285 286 /* Tx */ 287 #define MVNETA_MIB_TX_MAC_TRNS_ERR 0x0c 288 #define MVNETA_MIB_TX_GOOD_OCT 0x38 /* 64bit */ 289 #define MVNETA_MIB_TX_GOOD_FRAME 0x40 290 #define MVNETA_MIB_TX_EXCES_COL 0x44 291 #define MVNETA_MIB_TX_MCAST_FRAME 0x48 292 #define MVNETA_MIB_TX_BCAST_FRAME 0x4c 293 #define MVNETA_MIB_TX_MAC_CTL_ERR 0x50 294 295 /* Flow Control */ 296 #define MVNETA_MIB_FC_SENT 0x54 297 #define MVNETA_MIB_FC_GOOD 0x58 298 #define MVNETA_MIB_FC_BAD 0x5c 299 300 /* Packet Processing */ 301 #define MVNETA_MIB_PKT_UNDERSIZE 0x60 302 #define MVNETA_MIB_PKT_FRAGMENT 0x64 303 #define MVNETA_MIB_PKT_OVERSIZE 0x68 304 #define MVNETA_MIB_PKT_JABBER 0x6c 305 306 /* MAC Layer Errors */ 307 #define MVNETA_MIB_MAC_RX_ERR 0x70 308 #define MVNETA_MIB_MAC_CRC_ERR 0x74 309 #define MVNETA_MIB_MAC_COL 0x78 310 #define MVNETA_MIB_MAC_LATE_COL 0x7c 311 312 /* END OF REGISTER NUMBERS */ 313 314 /* 315 * 316 * Register Formats 317 * 318 */ 319 /* 320 * Address Decoder Registers 321 */ 322 /* Base Address (MVNETA_BASEADDR) */ 323 #define MVNETA_BASEADDR_TARGET(target) ((target) & 0xf) 324 #define MVNETA_BASEADDR_ATTR(attr) (((attr) & 0xff) << 8) 325 #define MVNETA_BASEADDR_BASE(base) ((base) & 0xffff0000) 326 327 /* Size (MVNETA_S) */ 328 #define MVNETA_S_SIZE(size) (((size) - 1) & 0xffff0000) 329 330 /* Base Address Enable (MVNETA_BARE) */ 331 #define MVNETA_BARE_EN_MASK ((1 << MVNETA_NWINDOW) - 1) 332 #define MVNETA_BARE_EN(win) ((1 << (win)) & MVNETA_BARE_EN_MASK) 333 334 /* Ethernet Port Access Protect (MVNETA_EPAP) */ 335 #define MVNETA_EPAP_AC_NAC 0x0 /* No access allowed */ 336 #define MVNETA_EPAP_AC_RO 0x1 /* Read Only */ 337 #define MVNETA_EPAP_AC_FA 0x3 /* Full access (r/w) */ 338 #define MVNETA_EPAP_EPAR(win, ac) ((ac) << ((win) * 2)) 339 340 /* 341 * Global Miscellaneous Registers 342 */ 343 /* PHY Address (MVNETA_PHYADDR) */ 344 #define MVNETA_PHYADDR_PHYAD(phy) ((phy) & 0x1f) 345 #define MVNETA_PHYADDR_GET_PHYAD(reg) ((reg) & 0x1f) 346 347 /* SMI register fields (MVNETA_SMI) */ 348 #define MVNETA_SMI_DATA_MASK 0x0000ffff 349 #define MVNETA_SMI_PHYAD(phy) (((phy) & 0x1f) << 16) 350 #define MVNETA_SMI_REGAD(reg) (((reg) & 0x1f) << 21) 351 #define MVNETA_SMI_OPCODE_WRITE (0 << 26) 352 #define MVNETA_SMI_OPCODE_READ (1 << 26) 353 #define MVNETA_SMI_READVALID (1 << 27) 354 #define MVNETA_SMI_BUSY (1 << 28) 355 356 /* Ethernet Unit Default ID (MVNETA_EUDID) */ 357 #define MVNETA_EUDID_DIDR_MASK 0x0000000f 358 #define MVNETA_EUDID_DIDR(id) ((id) & 0x0f) 359 #define MVNETA_EUDID_DATTR_MASK 0x00000ff0 360 #define MVNETA_EUDID_DATTR(attr) (((attr) & 0xff) << 4) 361 362 /* Ethernet Unit Interrupt Cause (MVNETA_EUIC) */ 363 #define MVNETA_EUIC_ETHERINTSUM (1 << 0) 364 #define MVNETA_EUIC_PARITY (1 << 1) 365 #define MVNETA_EUIC_ADDRVIOL (1 << 2) 366 #define MVNETA_EUIC_ADDRVNOMATCH (1 << 3) 367 #define MVNETA_EUIC_SMIDONE (1 << 4) 368 #define MVNETA_EUIC_COUNTWA (1 << 5) 369 #define MVNETA_EUIC_INTADDRERR (1 << 7) 370 #define MVNETA_EUIC_PORT0DPERR (1 << 9) 371 #define MVNETA_EUIC_TOPDPERR (1 << 12) 372 373 /* Ethernet Unit Internal Addr Error (MVNETA_EUIAE) */ 374 #define MVNETA_EUIAE_INTADDR_MASK 0x000001ff 375 #define MVNETA_EUIAE_INTADDR(addr) ((addr) & 0x1ff) 376 #define MVNETA_EUIAE_GET_INTADDR(addr) ((addr) & 0x1ff) 377 378 /* Ethernet Unit Control (MVNETA_EUC) */ 379 #define MVNETA_EUC_POLLING (1 << 1) 380 #define MVNETA_EUC_PORTRESET (1 << 24) 381 #define MVNETA_EUC_RAMSINITIALIZATIONCOMPLETED (1 << 25) 382 383 /* 384 * Miscellaneous Registers 385 */ 386 /* SDMA Configuration (MVNETA_SDC) */ 387 #define MVNETA_SDC_RXBSZ(x) ((x) << 1) 388 #define MVNETA_SDC_RXBSZ_MASK MVNETA_SDC_RXBSZ(7) 389 #define MVNETA_SDC_RXBSZ_1_64BITWORDS MVNETA_SDC_RXBSZ(0) 390 #define MVNETA_SDC_RXBSZ_2_64BITWORDS MVNETA_SDC_RXBSZ(1) 391 #define MVNETA_SDC_RXBSZ_4_64BITWORDS MVNETA_SDC_RXBSZ(2) 392 #define MVNETA_SDC_RXBSZ_8_64BITWORDS MVNETA_SDC_RXBSZ(3) 393 #define MVNETA_SDC_RXBSZ_16_64BITWORDS MVNETA_SDC_RXBSZ(4) 394 #define MVNETA_SDC_BLMR (1 << 4) 395 #define MVNETA_SDC_BLMT (1 << 5) 396 #define MVNETA_SDC_SWAPMODE (1 << 6) 397 #define MVNETA_SDC_TXBSZ(x) ((x) << 22) 398 #define MVNETA_SDC_TXBSZ_MASK MVNETA_SDC_TXBSZ(7) 399 #define MVNETA_SDC_TXBSZ_1_64BITWORDS MVNETA_SDC_TXBSZ(0) 400 #define MVNETA_SDC_TXBSZ_2_64BITWORDS MVNETA_SDC_TXBSZ(1) 401 #define MVNETA_SDC_TXBSZ_4_64BITWORDS MVNETA_SDC_TXBSZ(2) 402 #define MVNETA_SDC_TXBSZ_8_64BITWORDS MVNETA_SDC_TXBSZ(3) 403 #define MVNETA_SDC_TXBSZ_16_64BITWORDS MVNETA_SDC_TXBSZ(4) 404 405 /* 406 * Networking Controller Miscellaneous Registers 407 */ 408 /* Port Acceleration Mode (MVNETA_PACC) */ 409 #define MVNETA_PACC_ACCELERATIONMODE_MASK 0x7 410 #define MVNETA_PACC_ACCELERATIONMODE_EDM 0x1 /* Enhanced Desc Mode */ 411 412 /* Port Version (MVNETA_PV) */ 413 #define MVNETA_PV_VERSION_MASK 0xff 414 #define MVNETA_PV_VERSION(v) ((v) & 0xff) 415 #define MVNETA_PV_GET_VERSION(reg) ((reg) & 0xff) 416 417 /* 418 * Rx DMA Hardware Parser Registers 419 */ 420 /* Ether Type Priority (MVNETA_ETP) */ 421 #define MVNETA_ETP_ETHERTYPEPRIEN (1 << 0) /* EtherType Prio Ena */ 422 #define MVNETA_ETP_ETHERTYPEPRIFRSTEN (1 << 1) 423 #define MVNETA_ETP_ETHERTYPEPRIQ (0x7 << 2) /*EtherType Prio Queue*/ 424 #define MVNETA_ETP_ETHERTYPEPRIVAL (0xffff << 5) /*EtherType Prio Value*/ 425 #define MVNETA_ETP_FORCEUNICSTHIT (1 << 21) /* Force Unicast hit */ 426 427 /* Destination Address Filter Registers (MVNETA_DF{SM,OM,U}T) */ 428 #define MVNETA_DF(n, x) ((x) << (8 * (n))) 429 #define MVNETA_DF_PASS (1 << 0) 430 #define MVNETA_DF_QUEUE(q) ((q) << 1) 431 #define MVNETA_DF_QUEUE_ALL ((MVNETA_RX_QNUM_MAX-1) << 1) 432 #define MVNETA_DF_QUEUE_MASK ((MVNETA_RX_QNUM_MAX-1) << 1) 433 434 /* 435 * Rx DMA Miscellaneous Registers 436 */ 437 /* Port Rx Minimal Frame Size (MVNETA_PMFS) */ 438 #define MVNETA_PMFS_RXMFS(rxmfs) (((rxmfs) - 40) & 0x7c) 439 440 /* Receive Queue Command (MVNETA_RQC) */ 441 #define MVNETA_RQC_EN_MASK (0xff << 0) /* Enable Q */ 442 #define MVNETA_RQC_ENQ(q) (1 << (0 + (q))) 443 #define MVNETA_RQC_EN(n) ((n) << 0) 444 #define MVNETA_RQC_DIS_MASK (0xff << 8) /* Disable Q */ 445 #define MVNETA_RQC_DISQ(q) (1 << (8 + (q))) 446 #define MVNETA_RQC_DIS(n) ((n) << 8) 447 448 /* 449 * Rx DMA Networking Controller Miscellaneous Registers 450 */ 451 /* Port RX queues Configuration (MVNETA_PRXC) */ 452 #define MVNETA_PRXC_PACKETOFFSET(o) (((o) & 0xf) << 8) 453 454 /* Port RX queues Snoop (MVNETA_PRXSNP) */ 455 #define MVNETA_PRXSNP_SNOOPNOOFBYTES(b) (((b) & 0x3fff) << 0) 456 #define MVNETA_PRXSNP_L2DEPOSITNOOFBYTES(b) (((b) & 0x3fff) << 16) 457 458 /* Port RX queues Descriptors Queue Size (MVNETA_PRXDQS) */ 459 #define MVNETA_PRXDQS_DESCRIPTORSQUEUESIZE(s) (((s) & 0x3fff) << 0) 460 #define MVNETA_PRXDQS_BUFFERSIZE(s) (((s) & 0x1fff) << 19) 461 462 /* Port RX queues Descriptors Queue Threshold (MVNETA_PRXDQTH) */ 463 /* Occupied Descriptors Threshold */ 464 #define MVNETA_PRXDQTH_ODT(x) (((x) & 0x3fff) << 0) 465 /* Non Occupied Descriptors Threshold */ 466 #define MVNETA_PRXDQTH_NODT(x) (((x) & 0x3fff) << 16) 467 468 /* Port RX queues Status (MVNETA_PRXS) */ 469 /* Occupied Descriptors Counter */ 470 #define MVNETA_PRXS_ODC(x) (((x) & 0x3fff) << 0) 471 /* Non Occupied Descriptors Counter */ 472 #define MVNETA_PRXS_NODC(x) (((x) & 0x3fff) << 16) 473 #define MVNETA_PRXS_GET_ODC(reg) (((reg) >> 0) & 0x3fff) 474 #define MVNETA_PRXS_GET_NODC(reg) (((reg) >> 16) & 0x3fff) 475 476 /* Port RX queues Status Update (MVNETA_PRXSU) */ 477 #define MVNETA_PRXSU_NOOFPROCESSEDDESCRIPTORS(x) (((x) & 0xff) << 0) 478 #define MVNETA_PRXSU_NOOFNEWDESCRIPTORS(x) (((x) & 0xff) << 16) 479 480 /* Port RX Initialization (MVNETA_PRXINIT) */ 481 #define MVNETA_PRXINIT_RXDMAINIT (1 << 0) 482 483 /* 484 * Tx DMA Miscellaneous Registers 485 */ 486 /* Transmit Queue Command (MVNETA_TQC) */ 487 #define MVNETA_TQC_EN_MASK (0xff << 0) 488 #define MVNETA_TQC_ENQ(q) (1 << ((q) + 0))/* Enable Q */ 489 #define MVNETA_TQC_EN(n) ((n) << 0) 490 #define MVNETA_TQC_DIS_MASK (0xff << 8) 491 #define MVNETA_TQC_DISQ(q) (1 << ((q) + 8))/* Disable Q */ 492 #define MVNETA_TQC_DIS(n) ((n) << 8) 493 494 /* 495 * Tx DMA Networking Controller Miscellaneous Registers 496 */ 497 /* Port TX queues Descriptors Queue Size (MVNETA_PTXDQS) */ 498 /* Descriptors Queue Size */ 499 #define MVNETA_PTXDQS_DQS_MASK (0x3fff << 0) 500 #define MVNETA_PTXDQS_DQS(x) (((x) & 0x3fff) << 0) 501 /* Transmitted Buffer Threshold */ 502 #define MVNETA_PTXDQS_TBT_MASK (0x3fff << 16) 503 #define MVNETA_PTXDQS_TBT(x) (((x) & 0x3fff) << 16) 504 505 /* Port TX queues Status (MVNETA_PTXS) */ 506 /* Transmitted Buffer Counter */ 507 #define MVNETA_PTXS_TBC(x) (((x) & 0x3fff) << 16) 508 509 #define MVNETA_PTXS_GET_TBC(reg) (((reg) >> 16) & 0x3fff) 510 /* Pending Descriptors Counter */ 511 #define MVNETA_PTXS_PDC(x) ((x) & 0x3fff) 512 #define MVNETA_PTXS_GET_PDC(x) ((x) & 0x3fff) 513 514 /* Port TX queues Status Update (MVNETA_PTXSU) */ 515 /* Number Of Written Descriptors */ 516 #define MVNETA_PTXSU_NOWD(x) (((x) & 0xff) << 0) 517 /* Number Of Released Buffers */ 518 #define MVNETA_PTXSU_NORB(x) (((x) & 0xff) << 16) 519 520 /* TX Transmitted Buffers Counter (MVNETA_TXTBC) */ 521 /* Transmitted Buffers Counter */ 522 #define MVNETA_TXTBC_TBC(x) (((x) & 0x3fff) << 16) 523 524 /* Port TX Initialization (MVNETA_PTXINIT) */ 525 #define MVNETA_PTXINIT_TXDMAINIT (1 << 0) 526 527 /* 528 * Tx DMA Queue Arbiter Registers (Version 1 ) 529 */ 530 /* Transmit Queue Fixed Priority Configuration */ 531 #define MVNETA_TQFPC_EN(q) (1 << (q)) 532 533 /* 534 * RX_TX DMA Registers 535 */ 536 /* Port Configuration (MVNETA_PXC) */ 537 #define MVNETA_PXC_UPM (1 << 0) /* Uni Promisc mode */ 538 #define MVNETA_PXC_RXQ(q) ((q) << 1) 539 #define MVNETA_PXC_RXQ_MASK MVNETA_PXC_RXQ(7) 540 #define MVNETA_PXC_RXQARP(q) ((q) << 4) 541 #define MVNETA_PXC_RXQARP_MASK MVNETA_PXC_RXQARP(7) 542 #define MVNETA_PXC_RB (1 << 7) /* Rej mode of MAC */ 543 #define MVNETA_PXC_RBIP (1 << 8) 544 #define MVNETA_PXC_RBARP (1 << 9) 545 #define MVNETA_PXC_AMNOTXES (1 << 12) 546 #define MVNETA_PXC_RBARPF (1 << 13) 547 #define MVNETA_PXC_TCPCAPEN (1 << 14) 548 #define MVNETA_PXC_UDPCAPEN (1 << 15) 549 #define MVNETA_PXC_TCPQ(q) ((q) << 16) 550 #define MVNETA_PXC_TCPQ_MASK MVNETA_PXC_TCPQ(7) 551 #define MVNETA_PXC_UDPQ(q) ((q) << 19) 552 #define MVNETA_PXC_UDPQ_MASK MVNETA_PXC_UDPQ(7) 553 #define MVNETA_PXC_BPDUQ(q) ((q) << 22) 554 #define MVNETA_PXC_BPDUQ_MASK MVNETA_PXC_BPDUQ(7) 555 #define MVNETA_PXC_RXCS (1 << 25) 556 557 /* Port Configuration Extend (MVNETA_PXCX) */ 558 #define MVNETA_PXCX_SPAN (1 << 1) 559 #define MVNETA_PXCX_TXCRCDIS (1 << 3) 560 561 /* Marvell Header (MVNETA_MH) */ 562 #define MVNETA_MH_MHEN (1 << 0) 563 #define MVNETA_MH_DAPREFIX (0x3 << 1) 564 #define MVNETA_MH_SPID (0xf << 4) 565 #define MVNETA_MH_MHMASK (0x3 << 8) 566 #define MVNETA_MH_MHMASK_8QUEUES (0x0 << 8) 567 #define MVNETA_MH_MHMASK_4QUEUES (0x1 << 8) 568 #define MVNETA_MH_MHMASK_2QUEUES (0x3 << 8) 569 #define MVNETA_MH_DSAEN_MASK (0x3 << 10) 570 #define MVNETA_MH_DSAEN_DISABLE (0x0 << 10) 571 #define MVNETA_MH_DSAEN_NONEXTENDED (0x1 << 10) 572 #define MVNETA_MH_DSAEN_EXTENDED (0x2 << 10) 573 574 /* 575 * Serial(SMI/MII) Registers 576 */ 577 #define MVNETA_PSOMSCD_ENABLE (1UL<<31) 578 #define MVNETA_PSERDESCFG_QSGMII (0x0667) 579 #define MVNETA_PSERDESCFG_SGMII (0x0cc7) 580 /* Port Seiral Control0 (MVNETA_PSC0) */ 581 #define MVNETA_PSC0_FORCE_FC_MASK (0x3 << 5) 582 #define MVNETA_PSC0_FORCE_FC(fc) (((fc) & 0x3) << 5) 583 #define MVNETA_PSC0_FORCE_FC_PAUSE MVNETA_PSC0_FORCE_FC(0x1) 584 #define MVNETA_PSC0_FORCE_FC_NO_PAUSE MVNETA_PSC0_FORCE_FC(0x0) 585 #define MVNETA_PSC0_FORCE_BP_MASK (0x3 << 7) 586 #define MVNETA_PSC0_FORCE_BP(fc) (((fc) & 0x3) << 5) 587 #define MVNETA_PSC0_FORCE_BP_JAM MVNETA_PSC0_FORCE_BP(0x1) 588 #define MVNETA_PSC0_FORCE_BP_NO_JAM MVNETA_PSC0_FORCE_BP(0x0) 589 #define MVNETA_PSC0_DTE_ADV (1 << 14) 590 #define MVNETA_PSC0_IGN_RXERR (1 << 28) 591 #define MVNETA_PSC0_IGN_COLLISION (1 << 29) 592 #define MVNETA_PSC0_IGN_CARRIER (1 << 30) 593 594 /* Ethernet Port Status0 (MVNETA_PS0) */ 595 #define MVNETA_PS0_TXINPROG (1 << 0) 596 #define MVNETA_PS0_TXFIFOEMP (1 << 8) 597 #define MVNETA_PS0_RXFIFOEMPTY (1 << 16) 598 599 /* 600 * Gigabit Ethernet MAC Serial Parameters Configuration Registers 601 */ 602 #define MVNETA_PSPC_MUST_SET (1 << 3 | 1 << 4 | 1 << 5 | 0x23 << 6) 603 #define MVNETA_PSP1C_MUST_SET (1 << 0 | 1 << 1 | 1 << 2) 604 605 /* 606 * Gigabit Ethernet Auto-Negotiation Configuration Registers 607 */ 608 /* Port Auto-Negotiation Configuration (MVNETA_PANC) */ 609 #define MVNETA_PANC_FORCELINKFAIL (1 << 0) 610 #define MVNETA_PANC_FORCELINKPASS (1 << 1) 611 #define MVNETA_PANC_INBANDANEN (1 << 2) 612 #define MVNETA_PANC_INBANDANBYPASSEN (1 << 3) 613 #define MVNETA_PANC_INBANDRESTARTAN (1 << 4) 614 #define MVNETA_PANC_SETMIISPEED (1 << 5) 615 #define MVNETA_PANC_SETGMIISPEED (1 << 6) 616 #define MVNETA_PANC_ANSPEEDEN (1 << 7) 617 #define MVNETA_PANC_SETFCEN (1 << 8) 618 #define MVNETA_PANC_PAUSEADV (1 << 9) 619 #define MVNETA_PANC_ANFCEN (1 << 11) 620 #define MVNETA_PANC_SETFULLDX (1 << 12) 621 #define MVNETA_PANC_ANDUPLEXEN (1 << 13) 622 #define MVNETA_PANC_MUSTSET (1 << 15) 623 624 /* 625 * Gigabit Ethernet MAC Control Registers 626 */ 627 /* Port MAC Control 0 (MVNETA_PMACC0) */ 628 #define MVNETA_PMACC0_PORTEN (1 << 0) 629 #define MVNETA_PMACC0_PORTTYPE (1 << 1) 630 #define MVNETA_PMACC0_FRAMESIZELIMIT(x) ((((x) >> 1) << 2) & 0x7ffc) 631 #define MVNETA_PMACC0_FRAMESIZELIMIT_MASK (0x7ffc) 632 #define MVNETA_PMACC0_MUSTSET (1 << 15) 633 634 /* Port MAC Control 1 (MVNETA_PMACC1) */ 635 #define MVNETA_PMACC1_PCSLB (1 << 6) 636 637 /* Port MAC Control 2 (MVNETA_PMACC2) */ 638 #define MVNETA_PMACC2_INBANDANMODE (1 << 0) 639 #define MVNETA_PMACC2_PCSEN (1 << 3) 640 #define MVNETA_PMACC2_PCSEN (1 << 3) 641 #define MVNETA_PMACC2_RGMIIEN (1 << 4) 642 #define MVNETA_PMACC2_PADDINGDIS (1 << 5) 643 #define MVNETA_PMACC2_PORTMACRESET (1 << 6) 644 #define MVNETA_PMACC2_PRBSCHECKEN (1 << 10) 645 #define MVNETA_PMACC2_PRBSGENEN (1 << 11) 646 #define MVNETA_PMACC2_SDTT_MASK (3 << 12) /* Select Data To Transmit */ 647 #define MVNETA_PMACC2_SDTT_RM (0 << 12) /* Regular Mode */ 648 #define MVNETA_PMACC2_SDTT_PRBS (1 << 12) /* PRBS Mode */ 649 #define MVNETA_PMACC2_SDTT_ZC (2 << 12) /* Zero Constant */ 650 #define MVNETA_PMACC2_SDTT_OC (3 << 12) /* One Constant */ 651 #define MVNETA_PMACC2_MUSTSET (3 << 14) 652 653 /* Port MAC Control 3 (MVNETA_PMACC3) */ 654 #define MVNETA_PMACC3_IPG_MASK 0x7f80 655 656 /* 657 * Gigabit Ethernet MAC Interrupt Registers 658 */ 659 /* Port Interrupt Cause/Mask (MVNETA_PIC/MVNETA_PIM) */ 660 #define MVNETA_PI_INTSUM (1 << 0) 661 #define MVNETA_PI_LSC (1 << 1) /* LinkStatus Change */ 662 #define MVNETA_PI_ACOP (1 << 2) /* AnCompleted OnPort */ 663 #define MVNETA_PI_AOOR (1 << 5) /* AddressOut Of Range */ 664 #define MVNETA_PI_SSC (1 << 6) /* SyncStatus Change */ 665 #define MVNETA_PI_PRBSEOP (1 << 7) /* QSGMII PRBS error */ 666 #define MVNETA_PI_MIBCWA (1 << 15) /* MIB counter wrap around */ 667 #define MVNETA_PI_QSGMIIPRBSE (1 << 10) /* QSGMII PRBS error */ 668 #define MVNETA_PI_PCSRXPRLPI (1 << 11) /* PCS Rx path received LPI*/ 669 #define MVNETA_PI_PCSTXPRLPI (1 << 12) /* PCS Tx path received LPI*/ 670 #define MVNETA_PI_MACRXPRLPI (1 << 13) /* MAC Rx path received LPI*/ 671 #define MVNETA_PI_MIBCCD (1 << 14) /* MIB counters copy done */ 672 673 /* 674 * Gigabit Ethernet MAC Low Power Idle Registers 675 */ 676 /* LPI Control 0 (MVNETA_LPIC0) */ 677 #define MVNETA_LPIC0_LILIMIT(x) (((x) & 0xff) << 0) 678 #define MVNETA_LPIC0_TSLIMIT(x) (((x) & 0xff) << 8) 679 680 /* LPI Control 1 (MVNETA_LPIC1) */ 681 #define MVNETA_LPIC1_LPIRE (1 << 0) /* LPI request enable */ 682 #define MVNETA_LPIC1_LPIRF (1 << 1) /* LPI request force */ 683 #define MVNETA_LPIC1_LPIMM (1 << 2) /* LPI manual mode */ 684 #define MVNETA_LPIC1_TWLIMIT(x) (((x) & 0xfff) << 4) 685 686 /* LPI Control 2 (MVNETA_LPIC2) */ 687 #define MVNETA_LPIC2_MUSTSET 0x17d 688 689 /* LPI Status (MVNETA_LPIS) */ 690 #define MVNETA_LPIS_PCSRXPLPIS (1 << 0) /* PCS Rx path LPI status */ 691 #define MVNETA_LPIS_PCSTXPLPIS (1 << 1) /* PCS Tx path LPI status */ 692 #define MVNETA_LPIS_MACRXPLPIS (1 << 2)/* MAC Rx path LP idle status */ 693 #define MVNETA_LPIS_MACTXPLPWS (1 << 3)/* MAC Tx path LP wait status */ 694 #define MVNETA_LPIS_MACTXPLPIS (1 << 4)/* MAC Tx path LP idle status */ 695 696 /* 697 * Gigabit Ethernet MAC PRBS Check Status Registers 698 */ 699 /* Port PRBS Status (MVNETA_PPRBSS) */ 700 #define MVNETA_PPRBSS_PRBSCHECKLOCKED (1 << 0) 701 #define MVNETA_PPRBSS_PRBSCHECKRDY (1 << 1) 702 703 /* 704 * Gigabit Ethernet MAC Status Registers 705 */ 706 /* Port Status Register (MVNETA_PSR) */ 707 #define MVNETA_PSR_LINKUP (1 << 0) 708 #define MVNETA_PSR_GMIISPEED (1 << 1) 709 #define MVNETA_PSR_MIISPEED (1 << 2) 710 #define MVNETA_PSR_FULLDX (1 << 3) 711 #define MVNETA_PSR_RXFCEN (1 << 4) 712 #define MVNETA_PSR_TXFCEN (1 << 5) 713 #define MVNETA_PSR_PRP (1 << 6) /* Port Rx Pause */ 714 #define MVNETA_PSR_PTP (1 << 7) /* Port Tx Pause */ 715 #define MVNETA_PSR_PDP (1 << 8) /*Port is Doing Back-Pressure*/ 716 #define MVNETA_PSR_SYNCFAIL10MS (1 << 10) 717 #define MVNETA_PSR_ANDONE (1 << 11) 718 #define MVNETA_PSR_IBANBA (1 << 12) /* InBand AutoNeg BypassAct */ 719 #define MVNETA_PSR_SYNCOK (1 << 14) 720 721 /* 722 * Networking Controller Interrupt Registers 723 */ 724 /* Port CPU to Queue */ 725 #define MVNETA_MAXCPU 2 726 #define MVNETA_PCP2Q_TXQEN(q) (1 << ((q) + 8)) 727 #define MVNETA_PCP2Q_TXQEN_MASK (0xff << 8) 728 #define MVNETA_PCP2Q_RXQEN(q) (1 << ((q) + 0)) 729 #define MVNETA_PCP2Q_RXQEN_MASK (0xff << 0) 730 731 /* Port RX_TX Interrupt Threshold */ 732 #define MVNETA_PRXITTH_RITT(t) ((t) & 0xffffff) 733 734 /* Port RX_TX Threshold Interrupt Cause/Mask (MVNETA_PRXTXTIC/MVNETA_PRXTXTIM) */ 735 #define MVNETA_PRXTXTI_TBTCQ(q) (1 << ((q) + 0)) 736 #define MVNETA_PRXTXTI_TBTCQ_MASK (0xff << 0) 737 #define MVNETA_PRXTXTI_GET_TBTCQ(reg) (((reg) >> 0) & 0xff) 738 /* Tx Buffer Threshold Cross Queue*/ 739 #define MVNETA_PRXTXTI_RBICTAPQ(q) (1 << ((q) + 8)) 740 #define MVNETA_PRXTXTI_RBICTAPQ_MASK (0xff << 8) 741 #define MVNETA_PRXTXTI_GET_RBICTAPQ(reg) (((reg) >> 8) & 0xff) 742 /* Rx Buffer Int. Coaleasing Th. Pri. Alrt Q */ 743 #define MVNETA_PRXTXTI_RDTAQ(q) (1 << ((q) + 16)) 744 #define MVNETA_PRXTXTI_RDTAQ_MASK (0xff << 16) 745 #define MVNETA_PRXTXTI_GET_RDTAQ(reg) (((reg) >> 16) & 0xff) 746 /* Rx Descriptor Threshold Alert Queue*/ 747 #define MVNETA_PRXTXTI_PRXTXICSUMMARY (1 << 29) /* PRXTXI summary */ 748 #define MVNETA_PRXTXTI_PTXERRORSUMMARY (1 << 30) /* PTEXERROR summary */ 749 #define MVNETA_PRXTXTI_PMISCICSUMMARY (1UL << 31) /* PMISCIC summary */ 750 751 /* Port RX_TX Interrupt Cause/Mask (MVNETA_PRXTXIC/MVNETA_PRXTXIM) */ 752 #define MVNETA_PRXTXI_TBRQ(q) (1 << ((q) + 0)) 753 #define MVNETA_PRXTXI_TBRQ_MASK (0xff << 0) 754 #define MVNETA_PRXTXI_GET_TBRQ(reg) (((reg) >> 0) & 0xff) 755 #define MVNETA_PRXTXI_RPQ(q) (1 << ((q) + 8)) 756 #define MVNETA_PRXTXI_RPQ_MASK (0xff << 8) 757 #define MVNETA_PRXTXI_GET_RPQ(reg) (((reg) >> 8) & 0xff) 758 #define MVNETA_PRXTXI_RREQ(q) (1 << ((q) + 16)) 759 #define MVNETA_PRXTXI_RREQ_MASK (0xff << 16) 760 #define MVNETA_PRXTXI_GET_RREQ(reg) (((reg) >> 16) & 0xff) 761 #define MVNETA_PRXTXI_PRXTXTHICSUMMARY (1 << 29) 762 #define MVNETA_PRXTXI_PTXERRORSUMMARY (1 << 30) 763 #define MVNETA_PRXTXI_PMISCICSUMMARY (1UL << 31) 764 765 /* Port Misc Interrupt Cause/Mask (MVNETA_PMIC/MVNETA_PMIM) */ 766 #define MVNETA_PMI_PHYSTATUSCHNG (1 << 0) 767 #define MVNETA_PMI_LINKCHANGE (1 << 1) 768 #define MVNETA_PMI_IAE (1 << 7) /* Internal Address Error */ 769 #define MVNETA_PMI_RXOVERRUN (1 << 8) 770 #define MVNETA_PMI_RXCRCERROR (1 << 9) 771 #define MVNETA_PMI_RXLARGEPACKET (1 << 10) 772 #define MVNETA_PMI_TXUNDRN (1 << 11) 773 #define MVNETA_PMI_PRBSERROR (1 << 12) 774 #define MVNETA_PMI_PSCSYNCCHANGE (1 << 13) 775 #define MVNETA_PMI_SRSE (1 << 14) /* SerdesRealignSyncError */ 776 #define MVNETA_PMI_TREQ(q) (1 << ((q) + 24)) /* TxResourceErrorQ */ 777 #define MVNETA_PMI_TREQ_MASK (0xff << 24) /* TxResourceErrorQ */ 778 779 /* Port Interrupt Enable (MVNETA_PIE) */ 780 #define MVNETA_PIE_RXPKTINTRPTENB(q) (1 << ((q) + 0)) 781 #define MVNETA_PIE_TXPKTINTRPTENB(q) (1 << ((q) + 8)) 782 #define MVNETA_PIE_RXPKTINTRPTENB_MASK (0xff << 0) 783 #define MVNETA_PIE_TXPKTINTRPTENB_MASK (0xff << 8) 784 785 /* 786 * Miscellaneous Interrupt Registers 787 */ 788 #define MVNETA_PEUIAE_ADDR_MASK (0x3fff) 789 #define MVNETA_PEUIAE_ADDR(addr) ((addr) & 0x3fff) 790 #define MVNETA_PEUIAE_GET_ADDR(reg) ((reg) & 0x3fff) 791 792 /* 793 * SGMII PHY Registers 794 */ 795 /* Power and PLL Control (MVNETA_PPLLC) */ 796 #define MVNETA_PPLLC_REF_FREF_SEL_MASK (0xf << 0) 797 #define MVNETA_PPLLC_PHY_MODE_MASK (7 << 5) 798 #define MVNETA_PPLLC_PHY_MODE_SATA (0 << 5) 799 #define MVNETA_PPLLC_PHY_MODE_SAS (1 << 5) 800 #define MVNETA_PPLLC_PLL_LOCK (1 << 8) 801 #define MVNETA_PPLLC_PU_DFE (1 << 10) 802 #define MVNETA_PPLLC_PU_TX_INTP (1 << 11) 803 #define MVNETA_PPLLC_PU_TX (1 << 12) 804 #define MVNETA_PPLLC_PU_RX (1 << 13) 805 #define MVNETA_PPLLC_PU_PLL (1 << 14) 806 807 /* Digital Loopback Enable (MVNETA_DLE) */ 808 #define MVNETA_DLE_LOCAL_SEL_BITS_MASK (3 << 10) 809 #define MVNETA_DLE_LOCAL_SEL_BITS_10BITS (0 << 10) 810 #define MVNETA_DLE_LOCAL_SEL_BITS_20BITS (1 << 10) 811 #define MVNETA_DLE_LOCAL_SEL_BITS_40BITS (2 << 10) 812 #define MVNETA_DLE_LOCAL_RXPHER_TO_TX_EN (1 << 12) 813 #define MVNETA_DLE_LOCAL_ANA_TX2RX_LPBK_EN (1 << 13) 814 #define MVNETA_DLE_LOCAL_DIG_TX2RX_LPBK_EN (1 << 14) 815 #define MVNETA_DLE_LOCAL_DIG_RX2TX_LPBK_EN (1 << 15) 816 817 /* Reference Clock Select (MVNETA_RCS) */ 818 #define MVNETA_RCS_REFCLK_SEL (1 << 10) 819 820 /* 821 * DMA descriptors 822 */ 823 struct mvneta_tx_desc { 824 /* LITTLE_ENDIAN */ 825 uint32_t command; /* off 0x00: commands */ 826 uint16_t l4ichk; /* initial checksum */ 827 uint16_t bytecnt; /* 0ff 0x04: buffer byte count */ 828 uint32_t bufptr_pa; /* off 0x08: buffer ptr(PA) */ 829 uint32_t flags; /* off 0x0c: flags */ 830 uint32_t reserved0; /* off 0x10 */ 831 uint32_t reserved1; /* off 0x14 */ 832 uint32_t reserved2; /* off 0x18 */ 833 uint32_t reserved3; /* off 0x1c */ 834 }; 835 836 struct mvneta_rx_desc { 837 /* LITTLE_ENDIAN */ 838 uint32_t status; /* status and flags */ 839 uint16_t reserved0; 840 uint16_t bytecnt; /* buffer byte count */ 841 uint32_t bufptr_pa; /* packet buffer pointer */ 842 uint32_t reserved1; 843 uint32_t bufptr_va; 844 uint16_t reserved2; 845 uint16_t l4chk; /* L4 checksum */ 846 uint32_t reserved3; 847 uint32_t reserved4; 848 }; 849 850 /* 851 * Received packet command header: 852 * network controller => software 853 * the controller parse the packet and set some flags. 854 */ 855 #define MVNETA_RX_IPV4_FRAGMENT (1UL << 31) /* Fragment Indicator */ 856 #define MVNETA_RX_L4_CHECKSUM_OK (1 << 30) /* L4 Checksum */ 857 /* bit 29 reserved */ 858 #define MVNETA_RX_U (1 << 28) /* Unknown Destination */ 859 #define MVNETA_RX_F (1 << 27) /* First buffer */ 860 #define MVNETA_RX_L (1 << 26) /* Last buffer */ 861 #define MVNETA_RX_IP_HEADER_OK (1 << 25) /* IP Header is OK */ 862 #define MVNETA_RX_L3_IP (1 << 24) /* IP Type 0:IP6 1:IP4 */ 863 #define MVNETA_RX_L2_EV2 (1 << 23) /* Ethernet v2 frame */ 864 #define MVNETA_RX_L4_MASK (3 << 21) /* L4 Type */ 865 #define MVNETA_RX_L4_TCP (0x00 << 21) 866 #define MVNETA_RX_L4_UDP (0x01 << 21) 867 #define MVNETA_RX_L4_OTH (0x10 << 21) 868 #define MVNETA_RX_BPDU (1 << 20) /* BPDU frame */ 869 #define MVNETA_RX_VLAN (1 << 19) /* VLAN tag found */ 870 #define MVNETA_RX_EC_MASK (3 << 17) /* Error code */ 871 #define MVNETA_RX_EC_CE (0x00 << 17) /* CRC error */ 872 #define MVNETA_RX_EC_OR (0x01 << 17) /* FIFO overrun */ 873 #define MVNETA_RX_EC_MF (0x10 << 17) /* Max. frame len */ 874 #define MVNETA_RX_EC_RE (0x11 << 17) /* Resource error */ 875 #define MVNETA_RX_ES (1 << 16) /* Error summary */ 876 /* bit 15:0 reserved */ 877 878 /* 879 * Transmit packet command header: 880 * software => network controller 881 */ 882 #define MVNETA_TX_CMD_L4_CHECKSUM_MASK (0x3 << 30) /* Do L4 Checksum */ 883 #define MVNETA_TX_CMD_L4_CHECKSUM_FRAG (0x0 << 30) 884 #define MVNETA_TX_CMD_L4_CHECKSUM_NOFRAG (0x1 << 30) 885 #define MVNETA_TX_CMD_L4_CHECKSUM_NONE (0x2 << 30) 886 #define MVNETA_TX_CMD_PACKET_OFFSET_MASK (0x7f << 23) /* Payload offset */ 887 #define MVNETA_TX_CMD_W_PACKET_OFFSET(v) (((v) & 0x7f) << 23) 888 /* bit 22 reserved */ 889 #define MVNETA_TX_CMD_F (1 << 21) /* First buffer */ 890 #define MVNETA_TX_CMD_L (1 << 20) /* Last buffer */ 891 #define MVNETA_TX_CMD_PADDING (1 << 19) /* Pad short frame */ 892 #define MVNETA_TX_CMD_IP4_CHECKSUM (1 << 18) /* Do IPv4 Checksum */ 893 #define MVNETA_TX_CMD_L3_IP4 (0 << 17) 894 #define MVNETA_TX_CMD_L3_IP6 (1 << 17) 895 #define MVNETA_TX_CMD_L4_TCP (0 << 16) 896 #define MVNETA_TX_CMD_L4_UDP (1 << 16) 897 /* bit 15:13 reserved */ 898 #define MVNETA_TX_CMD_IP_HEADER_LEN_MASK (0x1f << 8) /* IP header len >> 2 */ 899 #define MVNETA_TX_CMD_IP_HEADER_LEN(v) (((v) & 0x1f) << 8) 900 /* bit 7 reserved */ 901 #define MVNETA_TX_CMD_L3_OFFSET_MASK (0x7f << 0) /* offset of L3 hdr. */ 902 #define MVNETA_TX_CMD_L3_OFFSET(v) (((v) & 0x7f) << 0) 903 904 /* 905 * Transmit packet extra attributes 906 * and error status returned from network controller. 907 */ 908 #define MVNETA_TX_F_DSA_TAG (3 << 30) /* DSA Tag */ 909 /* bit 29:8 reserved */ 910 #define MVNETA_TX_F_MH_SEL (0xf << 4) /* Marvell Header */ 911 /* bit 3 reserved */ 912 #define MVNETA_TX_F_EC_MASK (3 << 1) /* Error code */ 913 #define MVNETA_TX_F_EC_LC (0x00 << 1) /* Late Collision */ 914 #define MVNETA_TX_F_EC_UR (0x01 << 1) /* Underrun */ 915 #define MVNETA_TX_F_EC_RL (0x10 << 1) /* Excess. Collision */ 916 #define MVNETA_TX_F_EC_RESERVED (0x11 << 1) 917 #define MVNETA_TX_F_ES (1 << 0) /* Error summary */ 918 919 #define MVNETA_ERROR_SUMMARY (1 << 0) 920 #define MVNETA_BUFFER_OWNED_MASK (1UL << 31) 921 #define MVNETA_BUFFER_OWNED_BY_HOST (0UL << 31) 922 #define MVNETA_BUFFER_OWNED_BY_DMA (1UL << 31) 923 924 #endif /* _IF_MVNETAREG_H_ */ 925