Ticket #12328: 0001-Sync-atheros813x-with-FreeBSD-v2.patch
File 0001-Sync-atheros813x-with-FreeBSD-v2.patch, 90.2 KB (added by , 8 years ago) |
---|
-
headers/posix/net/if_media.h
From f54c3119fa5c92d3619bf45c412546684ba36de4 Mon Sep 17 00:00:00 2001 From: Andrew Aldridge <i80and@foxquill.com> Date: Wed, 18 Jan 2017 23:35:14 +0000 Subject: [PATCH] Sync atheros813x with FreeBSD --- headers/posix/net/if_media.h | 1 + .../drivers/network/atheros813x/dev/alc/if_alc.c | 1343 ++++++++++++++++---- .../network/atheros813x/dev/alc/if_alcreg.h | 313 ++++- .../network/atheros813x/dev/alc/if_alcvar.h | 10 +- src/libs/compat/freebsd_network/compat/net/if.h | 1 + .../compat/freebsd_network/compat/net/if_media.h | 3 + .../compat/freebsd_network/compat/net/if_var.h | 18 + src/libs/compat/freebsd_network/if.c | 45 + 8 files changed, 1488 insertions(+), 246 deletions(-) diff --git a/headers/posix/net/if_media.h b/headers/posix/net/if_media.h index ca67cf6..b712905 100644
a b 32 32 #define IFM_1000_T 16 /* 1000Base-T - RJ45 */ 33 33 #define IFM_1000_SX 18 /* 1000Base-SX - Fiber Optic */ 34 34 #define IFM_10G_T 22 /* 10GBase-T - RJ45 */ 35 #define IFM_UNKNOWN 25 /* media types not defined yet */ 35 36 36 37 /* General options */ 37 38 -
src/add-ons/kernel/drivers/network/atheros813x/dev/alc/if_alc.c
diff --git a/src/add-ons/kernel/drivers/network/atheros813x/dev/alc/if_alc.c b/src/add-ons/kernel/drivers/network/atheros813x/dev/alc/if_alc.c index 732220f..ca7ae9d 100644
a b __FBSDID("$FreeBSD$"); 49 49 50 50 #include <net/bpf.h> 51 51 #include <net/if.h> 52 #include <net/if_var.h> 52 53 #include <net/if_arp.h> 53 54 #include <net/ethernet.h> 54 55 #include <net/if_dl.h> … … static struct alc_ident alc_ident_table[] = { 110 111 "Atheros AR8152 v1.1 PCIe Fast Ethernet" }, 111 112 { VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8152_B2, 6 * 1024, 112 113 "Atheros AR8152 v2.0 PCIe Fast Ethernet" }, 114 { VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8161, 9 * 1024, 115 "Atheros AR8161 PCIe Gigabit Ethernet" }, 116 { VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8162, 9 * 1024, 117 "Atheros AR8162 PCIe Fast Ethernet" }, 118 { VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8171, 9 * 1024, 119 "Atheros AR8171 PCIe Gigabit Ethernet" }, 120 { VENDORID_ATHEROS, DEVICEID_ATHEROS_AR8172, 9 * 1024, 121 "Atheros AR8172 PCIe Fast Ethernet" }, 122 { VENDORID_ATHEROS, DEVICEID_ATHEROS_E2200, 9 * 1024, 123 "Killer E2200 Gigabit Ethernet" }, 124 { VENDORID_ATHEROS, DEVICEID_ATHEROS_E2400, 9 * 1024, 125 "Killer E2400 Gigabit Ethernet" }, 126 { VENDORID_ATHEROS, DEVICEID_ATHEROS_E2500, 9 * 1024, 127 "Killer E2500 Gigabit Ethernet" }, 113 128 { 0, 0, 0, NULL} 114 129 }; 115 130 116 static void alc_aspm(struct alc_softc *, int); 131 static void alc_aspm(struct alc_softc *, int, int); 132 static void alc_aspm_813x(struct alc_softc *, int); 133 static void alc_aspm_816x(struct alc_softc *, int); 117 134 static int alc_attach(device_t); 118 135 static int alc_check_boundary(struct alc_softc *); 136 static void alc_config_msi(struct alc_softc *); 119 137 static int alc_detach(device_t); 120 138 static void alc_disable_l0s_l1(struct alc_softc *); 121 139 static int alc_dma_alloc(struct alc_softc *); 122 140 static void alc_dma_free(struct alc_softc *); 123 141 static void alc_dmamap_cb(void *, bus_dma_segment_t *, int, int); 142 static void alc_dsp_fixup(struct alc_softc *, int); 124 143 static int alc_encap(struct alc_softc *, struct mbuf **); 125 144 static struct alc_ident * 126 145 alc_find_ident(device_t); … … static struct mbuf * 129 148 alc_fixup_rx(struct ifnet *, struct mbuf *); 130 149 #endif 131 150 static void alc_get_macaddr(struct alc_softc *); 151 static void alc_get_macaddr_813x(struct alc_softc *); 152 static void alc_get_macaddr_816x(struct alc_softc *); 153 static void alc_get_macaddr_par(struct alc_softc *); 132 154 static void alc_init(void *); 133 155 static void alc_init_cmb(struct alc_softc *); 134 156 static void alc_init_locked(struct alc_softc *); … … static void alc_int_task(void *, int); 140 162 static int alc_intr(void *); 141 163 static int alc_ioctl(struct ifnet *, u_long, caddr_t); 142 164 static void alc_mac_config(struct alc_softc *); 165 static uint32_t alc_mii_readreg_813x(struct alc_softc *, int, int); 166 static uint32_t alc_mii_readreg_816x(struct alc_softc *, int, int); 167 static uint32_t alc_mii_writereg_813x(struct alc_softc *, int, int, int); 168 static uint32_t alc_mii_writereg_816x(struct alc_softc *, int, int, int); 143 169 static int alc_miibus_readreg(device_t, int, int); 144 170 static void alc_miibus_statchg(device_t); 145 171 static int alc_miibus_writereg(device_t, int, int, int); 172 static uint32_t alc_miidbg_readreg(struct alc_softc *, int); 173 static uint32_t alc_miidbg_writereg(struct alc_softc *, int, int); 174 static uint32_t alc_miiext_readreg(struct alc_softc *, int, int); 175 static uint32_t alc_miiext_writereg(struct alc_softc *, int, int, int); 146 176 static int alc_mediachange(struct ifnet *); 177 static int alc_mediachange_locked(struct alc_softc *); 147 178 static void alc_mediastatus(struct ifnet *, struct ifmediareq *); 148 179 static int alc_newbuf(struct alc_softc *, struct alc_rxdesc *); 180 static void alc_osc_reset(struct alc_softc *); 149 181 static void alc_phy_down(struct alc_softc *); 150 182 static void alc_phy_reset(struct alc_softc *); 183 static void alc_phy_reset_813x(struct alc_softc *); 184 static void alc_phy_reset_816x(struct alc_softc *); 151 185 static int alc_probe(device_t); 152 186 static void alc_reset(struct alc_softc *); 153 187 static int alc_resume(device_t); … … static void alc_rxfilter(struct alc_softc *); 157 191 static void alc_rxvlan(struct alc_softc *); 158 192 static void alc_setlinkspeed(struct alc_softc *); 159 193 static void alc_setwol(struct alc_softc *); 194 static void alc_setwol_813x(struct alc_softc *); 195 static void alc_setwol_816x(struct alc_softc *); 160 196 static int alc_shutdown(device_t); 161 197 static void alc_start(struct ifnet *); 162 198 static void alc_start_locked(struct ifnet *); … … static struct resource_spec alc_irq_spec_msix[] = { 223 259 { -1, 0, 0 } 224 260 }; 225 261 226 static uint32_t alc_dma_burst[] = { 128, 256, 512, 1024, 2048, 4096, 0 };262 static uint32_t alc_dma_burst[] = { 128, 256, 512, 1024, 2048, 4096, 0, 0 }; 227 263 228 264 static int 229 265 alc_miibus_readreg(device_t dev, int phy, int reg) 230 266 { 231 267 struct alc_softc *sc; 232 uint32_t v; 233 int i; 268 int v; 234 269 235 270 sc = device_get_softc(dev); 271 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 272 v = alc_mii_readreg_816x(sc, phy, reg); 273 else 274 v = alc_mii_readreg_813x(sc, phy, reg); 275 return (v); 276 } 277 278 static uint32_t 279 alc_mii_readreg_813x(struct alc_softc *sc, int phy, int reg) 280 { 281 uint32_t v; 282 int i; 236 283 237 284 /* 238 285 * For AR8132 fast ethernet controller, do not report 1000baseT … … alc_miibus_readreg(device_t dev, int phy, int reg) 261 308 return ((v & MDIO_DATA_MASK) >> MDIO_DATA_SHIFT); 262 309 } 263 310 311 static uint32_t 312 alc_mii_readreg_816x(struct alc_softc *sc, int phy, int reg) 313 { 314 uint32_t clk, v; 315 int i; 316 317 if ((sc->alc_flags & ALC_FLAG_LINK) != 0) 318 clk = MDIO_CLK_25_128; 319 else 320 clk = MDIO_CLK_25_4; 321 CSR_WRITE_4(sc, ALC_MDIO, MDIO_OP_EXECUTE | MDIO_OP_READ | 322 MDIO_SUP_PREAMBLE | clk | MDIO_REG_ADDR(reg)); 323 for (i = ALC_PHY_TIMEOUT; i > 0; i--) { 324 DELAY(5); 325 v = CSR_READ_4(sc, ALC_MDIO); 326 if ((v & MDIO_OP_BUSY) == 0) 327 break; 328 } 329 330 if (i == 0) { 331 device_printf(sc->alc_dev, "phy read timeout : %d\n", reg); 332 return (0); 333 } 334 335 return ((v & MDIO_DATA_MASK) >> MDIO_DATA_SHIFT); 336 } 337 264 338 static int 265 339 alc_miibus_writereg(device_t dev, int phy, int reg, int val) 266 340 { 267 341 struct alc_softc *sc; 268 uint32_t v; 269 int i; 342 int v; 270 343 271 344 sc = device_get_softc(dev); 345 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 346 v = alc_mii_writereg_816x(sc, phy, reg, val); 347 else 348 v = alc_mii_writereg_813x(sc, phy, reg, val); 349 return (v); 350 } 351 352 static uint32_t 353 alc_mii_writereg_813x(struct alc_softc *sc, int phy, int reg, int val) 354 { 355 uint32_t v; 356 int i; 272 357 273 358 CSR_WRITE_4(sc, ALC_MDIO, MDIO_OP_EXECUTE | MDIO_OP_WRITE | 274 359 (val & MDIO_DATA_MASK) << MDIO_DATA_SHIFT | … … alc_miibus_writereg(device_t dev, int phy, int reg, int val) 286 371 return (0); 287 372 } 288 373 374 static uint32_t 375 alc_mii_writereg_816x(struct alc_softc *sc, int phy, int reg, int val) 376 { 377 uint32_t clk, v; 378 int i; 379 380 if ((sc->alc_flags & ALC_FLAG_LINK) != 0) 381 clk = MDIO_CLK_25_128; 382 else 383 clk = MDIO_CLK_25_4; 384 CSR_WRITE_4(sc, ALC_MDIO, MDIO_OP_EXECUTE | MDIO_OP_WRITE | 385 ((val & MDIO_DATA_MASK) << MDIO_DATA_SHIFT) | MDIO_REG_ADDR(reg) | 386 MDIO_SUP_PREAMBLE | clk); 387 for (i = ALC_PHY_TIMEOUT; i > 0; i--) { 388 DELAY(5); 389 v = CSR_READ_4(sc, ALC_MDIO); 390 if ((v & MDIO_OP_BUSY) == 0) 391 break; 392 } 393 394 if (i == 0) 395 device_printf(sc->alc_dev, "phy write timeout : %d\n", reg); 396 397 return (0); 398 } 399 289 400 static void 290 401 alc_miibus_statchg(device_t dev) 291 402 { … … alc_miibus_statchg(device_t dev) 318 429 break; 319 430 } 320 431 } 321 alc_stop_queue(sc);322 432 /* Stop Rx/Tx MACs. */ 323 433 alc_stop_mac(sc); 324 434 … … alc_miibus_statchg(device_t dev) 330 440 reg = CSR_READ_4(sc, ALC_MAC_CFG); 331 441 reg |= MAC_CFG_TX_ENB | MAC_CFG_RX_ENB; 332 442 CSR_WRITE_4(sc, ALC_MAC_CFG, reg); 333 alc_aspm(sc, IFM_SUBTYPE(mii->mii_media_active)); 443 } 444 alc_aspm(sc, 0, IFM_SUBTYPE(mii->mii_media_active)); 445 alc_dsp_fixup(sc, IFM_SUBTYPE(mii->mii_media_active)); 446 } 447 448 static uint32_t 449 alc_miidbg_readreg(struct alc_softc *sc, int reg) 450 { 451 452 alc_miibus_writereg(sc->alc_dev, sc->alc_phyaddr, ALC_MII_DBG_ADDR, 453 reg); 454 return (alc_miibus_readreg(sc->alc_dev, sc->alc_phyaddr, 455 ALC_MII_DBG_DATA)); 456 } 457 458 static uint32_t 459 alc_miidbg_writereg(struct alc_softc *sc, int reg, int val) 460 { 461 462 alc_miibus_writereg(sc->alc_dev, sc->alc_phyaddr, ALC_MII_DBG_ADDR, 463 reg); 464 return (alc_miibus_writereg(sc->alc_dev, sc->alc_phyaddr, 465 ALC_MII_DBG_DATA, val)); 466 } 467 468 static uint32_t 469 alc_miiext_readreg(struct alc_softc *sc, int devaddr, int reg) 470 { 471 uint32_t clk, v; 472 int i; 473 474 CSR_WRITE_4(sc, ALC_EXT_MDIO, EXT_MDIO_REG(reg) | 475 EXT_MDIO_DEVADDR(devaddr)); 476 if ((sc->alc_flags & ALC_FLAG_LINK) != 0) 477 clk = MDIO_CLK_25_128; 478 else 479 clk = MDIO_CLK_25_4; 480 CSR_WRITE_4(sc, ALC_MDIO, MDIO_OP_EXECUTE | MDIO_OP_READ | 481 MDIO_SUP_PREAMBLE | clk | MDIO_MODE_EXT); 482 for (i = ALC_PHY_TIMEOUT; i > 0; i--) { 483 DELAY(5); 484 v = CSR_READ_4(sc, ALC_MDIO); 485 if ((v & MDIO_OP_BUSY) == 0) 486 break; 487 } 488 489 if (i == 0) { 490 device_printf(sc->alc_dev, "phy ext read timeout : %d, %d\n", 491 devaddr, reg); 492 return (0); 493 } 494 495 return ((v & MDIO_DATA_MASK) >> MDIO_DATA_SHIFT); 496 } 497 498 static uint32_t 499 alc_miiext_writereg(struct alc_softc *sc, int devaddr, int reg, int val) 500 { 501 uint32_t clk, v; 502 int i; 503 504 CSR_WRITE_4(sc, ALC_EXT_MDIO, EXT_MDIO_REG(reg) | 505 EXT_MDIO_DEVADDR(devaddr)); 506 if ((sc->alc_flags & ALC_FLAG_LINK) != 0) 507 clk = MDIO_CLK_25_128; 508 else 509 clk = MDIO_CLK_25_4; 510 CSR_WRITE_4(sc, ALC_MDIO, MDIO_OP_EXECUTE | MDIO_OP_WRITE | 511 ((val & MDIO_DATA_MASK) << MDIO_DATA_SHIFT) | 512 MDIO_SUP_PREAMBLE | clk | MDIO_MODE_EXT); 513 for (i = ALC_PHY_TIMEOUT; i > 0; i--) { 514 DELAY(5); 515 v = CSR_READ_4(sc, ALC_MDIO); 516 if ((v & MDIO_OP_BUSY) == 0) 517 break; 518 } 519 520 if (i == 0) 521 device_printf(sc->alc_dev, "phy ext write timeout : %d, %d\n", 522 devaddr, reg); 523 524 return (0); 525 } 526 527 static void 528 alc_dsp_fixup(struct alc_softc *sc, int media) 529 { 530 uint16_t agc, len, val; 531 532 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 533 return; 534 if (AR816X_REV(sc->alc_rev) >= AR816X_REV_C0) 535 return; 536 537 /* 538 * Vendor PHY magic. 539 * 1000BT/AZ, wrong cable length 540 */ 541 if ((sc->alc_flags & ALC_FLAG_LINK) != 0) { 542 len = alc_miiext_readreg(sc, MII_EXT_PCS, MII_EXT_CLDCTL6); 543 len = (len >> EXT_CLDCTL6_CAB_LEN_SHIFT) & 544 EXT_CLDCTL6_CAB_LEN_MASK; 545 agc = alc_miidbg_readreg(sc, MII_DBG_AGC); 546 agc = (agc >> DBG_AGC_2_VGA_SHIFT) & DBG_AGC_2_VGA_MASK; 547 if ((media == IFM_1000_T && len > EXT_CLDCTL6_CAB_LEN_SHORT1G && 548 agc > DBG_AGC_LONG1G_LIMT) || 549 (media == IFM_100_TX && len > DBG_AGC_LONG100M_LIMT && 550 agc > DBG_AGC_LONG1G_LIMT)) { 551 alc_miidbg_writereg(sc, MII_DBG_AZ_ANADECT, 552 DBG_AZ_ANADECT_LONG); 553 val = alc_miiext_readreg(sc, MII_EXT_ANEG, 554 MII_EXT_ANEG_AFE); 555 val |= ANEG_AFEE_10BT_100M_TH; 556 alc_miiext_writereg(sc, MII_EXT_ANEG, MII_EXT_ANEG_AFE, 557 val); 558 } else { 559 alc_miidbg_writereg(sc, MII_DBG_AZ_ANADECT, 560 DBG_AZ_ANADECT_DEFAULT); 561 val = alc_miiext_readreg(sc, MII_EXT_ANEG, 562 MII_EXT_ANEG_AFE); 563 val &= ~ANEG_AFEE_10BT_100M_TH; 564 alc_miiext_writereg(sc, MII_EXT_ANEG, MII_EXT_ANEG_AFE, 565 val); 566 } 567 if ((sc->alc_flags & ALC_FLAG_LINK_WAR) != 0 && 568 AR816X_REV(sc->alc_rev) == AR816X_REV_B0) { 569 if (media == IFM_1000_T) { 570 /* 571 * Giga link threshold, raise the tolerance of 572 * noise 50%. 573 */ 574 val = alc_miidbg_readreg(sc, MII_DBG_MSE20DB); 575 val &= ~DBG_MSE20DB_TH_MASK; 576 val |= (DBG_MSE20DB_TH_HI << 577 DBG_MSE20DB_TH_SHIFT); 578 alc_miidbg_writereg(sc, MII_DBG_MSE20DB, val); 579 } else if (media == IFM_100_TX) 580 alc_miidbg_writereg(sc, MII_DBG_MSE16DB, 581 DBG_MSE16DB_UP); 582 } 583 } else { 584 val = alc_miiext_readreg(sc, MII_EXT_ANEG, MII_EXT_ANEG_AFE); 585 val &= ~ANEG_AFEE_10BT_100M_TH; 586 alc_miiext_writereg(sc, MII_EXT_ANEG, MII_EXT_ANEG_AFE, val); 587 if ((sc->alc_flags & ALC_FLAG_LINK_WAR) != 0 && 588 AR816X_REV(sc->alc_rev) == AR816X_REV_B0) { 589 alc_miidbg_writereg(sc, MII_DBG_MSE16DB, 590 DBG_MSE16DB_DOWN); 591 val = alc_miidbg_readreg(sc, MII_DBG_MSE20DB); 592 val &= ~DBG_MSE20DB_TH_MASK; 593 val |= (DBG_MSE20DB_TH_DEFAULT << DBG_MSE20DB_TH_SHIFT); 594 alc_miidbg_writereg(sc, MII_DBG_MSE20DB, val); 595 } 334 596 } 335 597 } 336 598 … … static int 358 620 alc_mediachange(struct ifnet *ifp) 359 621 { 360 622 struct alc_softc *sc; 361 struct mii_data *mii;362 struct mii_softc *miisc;363 623 int error; 364 624 365 625 sc = ifp->if_softc; 366 626 ALC_LOCK(sc); 627 error = alc_mediachange_locked(sc); 628 ALC_UNLOCK(sc); 629 630 return (error); 631 } 632 633 static int 634 alc_mediachange_locked(struct alc_softc *sc) 635 { 636 struct mii_data *mii; 637 struct mii_softc *miisc; 638 int error; 639 640 ALC_LOCK_ASSERT(sc); 641 367 642 mii = device_get_softc(sc->alc_miibus); 368 643 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) 369 644 PHY_RESET(miisc); 370 645 error = mii_mediachg(mii); 371 ALC_UNLOCK(sc);372 646 373 647 return (error); 374 648 } … … alc_probe(device_t dev) 406 680 static void 407 681 alc_get_macaddr(struct alc_softc *sc) 408 682 { 409 uint32_t ea[2], opt; 683 684 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 685 alc_get_macaddr_816x(sc); 686 else 687 alc_get_macaddr_813x(sc); 688 } 689 690 static void 691 alc_get_macaddr_813x(struct alc_softc *sc) 692 { 693 uint32_t opt; 410 694 uint16_t val; 411 695 int eeprom, i; 412 696 … … alc_get_macaddr(struct alc_softc *sc) 501 785 } 502 786 } 503 787 788 alc_get_macaddr_par(sc); 789 } 790 791 static void 792 alc_get_macaddr_816x(struct alc_softc *sc) 793 { 794 uint32_t reg; 795 int i, reloaded; 796 797 reloaded = 0; 798 /* Try to reload station address via TWSI. */ 799 for (i = 100; i > 0; i--) { 800 reg = CSR_READ_4(sc, ALC_SLD); 801 if ((reg & (SLD_PROGRESS | SLD_START)) == 0) 802 break; 803 DELAY(1000); 804 } 805 if (i != 0) { 806 CSR_WRITE_4(sc, ALC_SLD, reg | SLD_START); 807 for (i = 100; i > 0; i--) { 808 DELAY(1000); 809 reg = CSR_READ_4(sc, ALC_SLD); 810 if ((reg & SLD_START) == 0) 811 break; 812 } 813 if (i != 0) 814 reloaded++; 815 else if (bootverbose) 816 device_printf(sc->alc_dev, 817 "reloading station address via TWSI timed out!\n"); 818 } 819 820 /* Try to reload station address from EEPROM or FLASH. */ 821 if (reloaded == 0) { 822 reg = CSR_READ_4(sc, ALC_EEPROM_LD); 823 if ((reg & (EEPROM_LD_EEPROM_EXIST | 824 EEPROM_LD_FLASH_EXIST)) != 0) { 825 for (i = 100; i > 0; i--) { 826 reg = CSR_READ_4(sc, ALC_EEPROM_LD); 827 if ((reg & (EEPROM_LD_PROGRESS | 828 EEPROM_LD_START)) == 0) 829 break; 830 DELAY(1000); 831 } 832 if (i != 0) { 833 CSR_WRITE_4(sc, ALC_EEPROM_LD, reg | 834 EEPROM_LD_START); 835 for (i = 100; i > 0; i--) { 836 DELAY(1000); 837 reg = CSR_READ_4(sc, ALC_EEPROM_LD); 838 if ((reg & EEPROM_LD_START) == 0) 839 break; 840 } 841 } else if (bootverbose) 842 device_printf(sc->alc_dev, 843 "reloading EEPROM/FLASH timed out!\n"); 844 } 845 } 846 847 alc_get_macaddr_par(sc); 848 } 849 850 static void 851 alc_get_macaddr_par(struct alc_softc *sc) 852 { 853 uint32_t ea[2]; 854 504 855 ea[0] = CSR_READ_4(sc, ALC_PAR0); 505 856 ea[1] = CSR_READ_4(sc, ALC_PAR1); 506 857 sc->alc_eaddr[0] = (ea[1] >> 8) & 0xFF; … … alc_disable_l0s_l1(struct alc_softc *sc) 516 867 { 517 868 uint32_t pmcfg; 518 869 519 /* Another magic from vendor. */ 520 pmcfg = CSR_READ_4(sc, ALC_PM_CFG); 521 pmcfg &= ~(PM_CFG_L1_ENTRY_TIMER_MASK | PM_CFG_CLK_SWH_L1 | 522 PM_CFG_ASPM_L0S_ENB | PM_CFG_ASPM_L1_ENB | PM_CFG_MAC_ASPM_CHK | 523 PM_CFG_SERDES_PD_EX_L1); 524 pmcfg |= PM_CFG_SERDES_BUDS_RX_L1_ENB | PM_CFG_SERDES_PLL_L1_ENB | 525 PM_CFG_SERDES_L1_ENB; 526 CSR_WRITE_4(sc, ALC_PM_CFG, pmcfg); 870 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) { 871 /* Another magic from vendor. */ 872 pmcfg = CSR_READ_4(sc, ALC_PM_CFG); 873 pmcfg &= ~(PM_CFG_L1_ENTRY_TIMER_MASK | PM_CFG_CLK_SWH_L1 | 874 PM_CFG_ASPM_L0S_ENB | PM_CFG_ASPM_L1_ENB | 875 PM_CFG_MAC_ASPM_CHK | PM_CFG_SERDES_PD_EX_L1); 876 pmcfg |= PM_CFG_SERDES_BUDS_RX_L1_ENB | 877 PM_CFG_SERDES_PLL_L1_ENB | PM_CFG_SERDES_L1_ENB; 878 CSR_WRITE_4(sc, ALC_PM_CFG, pmcfg); 879 } 527 880 } 528 881 529 882 static void 530 883 alc_phy_reset(struct alc_softc *sc) 531 884 { 885 886 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 887 alc_phy_reset_816x(sc); 888 else 889 alc_phy_reset_813x(sc); 890 } 891 892 static void 893 alc_phy_reset_813x(struct alc_softc *sc) 894 { 532 895 uint16_t data; 533 896 534 897 /* Reset magic from Linux. */ … … alc_phy_reset(struct alc_softc *sc) 641 1004 } 642 1005 643 1006 static void 1007 alc_phy_reset_816x(struct alc_softc *sc) 1008 { 1009 uint32_t val; 1010 1011 val = CSR_READ_4(sc, ALC_GPHY_CFG); 1012 val &= ~(GPHY_CFG_EXT_RESET | GPHY_CFG_LED_MODE | 1013 GPHY_CFG_GATE_25M_ENB | GPHY_CFG_PHY_IDDQ | GPHY_CFG_PHY_PLL_ON | 1014 GPHY_CFG_PWDOWN_HW | GPHY_CFG_100AB_ENB); 1015 val |= GPHY_CFG_SEL_ANA_RESET; 1016 #ifdef notyet 1017 val |= GPHY_CFG_HIB_PULSE | GPHY_CFG_HIB_EN | GPHY_CFG_SEL_ANA_RESET; 1018 #else 1019 /* Disable PHY hibernation. */ 1020 val &= ~(GPHY_CFG_HIB_PULSE | GPHY_CFG_HIB_EN); 1021 #endif 1022 CSR_WRITE_4(sc, ALC_GPHY_CFG, val); 1023 DELAY(10); 1024 CSR_WRITE_4(sc, ALC_GPHY_CFG, val | GPHY_CFG_EXT_RESET); 1025 DELAY(800); 1026 1027 /* Vendor PHY magic. */ 1028 #ifdef notyet 1029 alc_miidbg_writereg(sc, MII_DBG_LEGCYPS, DBG_LEGCYPS_DEFAULT); 1030 alc_miidbg_writereg(sc, MII_DBG_SYSMODCTL, DBG_SYSMODCTL_DEFAULT); 1031 alc_miiext_writereg(sc, MII_EXT_PCS, MII_EXT_VDRVBIAS, 1032 EXT_VDRVBIAS_DEFAULT); 1033 #else 1034 /* Disable PHY hibernation. */ 1035 alc_miidbg_writereg(sc, MII_DBG_LEGCYPS, 1036 DBG_LEGCYPS_DEFAULT & ~DBG_LEGCYPS_ENB); 1037 alc_miidbg_writereg(sc, MII_DBG_HIBNEG, 1038 DBG_HIBNEG_DEFAULT & ~(DBG_HIBNEG_PSHIB_EN | DBG_HIBNEG_HIB_PULSE)); 1039 alc_miidbg_writereg(sc, MII_DBG_GREENCFG, DBG_GREENCFG_DEFAULT); 1040 #endif 1041 1042 /* XXX Disable EEE. */ 1043 val = CSR_READ_4(sc, ALC_LPI_CTL); 1044 val &= ~LPI_CTL_ENB; 1045 CSR_WRITE_4(sc, ALC_LPI_CTL, val); 1046 alc_miiext_writereg(sc, MII_EXT_ANEG, MII_EXT_ANEG_LOCAL_EEEADV, 0); 1047 1048 /* PHY power saving. */ 1049 alc_miidbg_writereg(sc, MII_DBG_TST10BTCFG, DBG_TST10BTCFG_DEFAULT); 1050 alc_miidbg_writereg(sc, MII_DBG_SRDSYSMOD, DBG_SRDSYSMOD_DEFAULT); 1051 alc_miidbg_writereg(sc, MII_DBG_TST100BTCFG, DBG_TST100BTCFG_DEFAULT); 1052 alc_miidbg_writereg(sc, MII_DBG_ANACTL, DBG_ANACTL_DEFAULT); 1053 val = alc_miidbg_readreg(sc, MII_DBG_GREENCFG2); 1054 val &= ~DBG_GREENCFG2_GATE_DFSE_EN; 1055 alc_miidbg_writereg(sc, MII_DBG_GREENCFG2, val); 1056 1057 /* RTL8139C, 120m issue. */ 1058 alc_miiext_writereg(sc, MII_EXT_ANEG, MII_EXT_ANEG_NLP78, 1059 ANEG_NLP78_120M_DEFAULT); 1060 alc_miiext_writereg(sc, MII_EXT_ANEG, MII_EXT_ANEG_S3DIG10, 1061 ANEG_S3DIG10_DEFAULT); 1062 1063 if ((sc->alc_flags & ALC_FLAG_LINK_WAR) != 0) { 1064 /* Turn off half amplitude. */ 1065 val = alc_miiext_readreg(sc, MII_EXT_PCS, MII_EXT_CLDCTL3); 1066 val |= EXT_CLDCTL3_BP_CABLE1TH_DET_GT; 1067 alc_miiext_writereg(sc, MII_EXT_PCS, MII_EXT_CLDCTL3, val); 1068 /* Turn off Green feature. */ 1069 val = alc_miidbg_readreg(sc, MII_DBG_GREENCFG2); 1070 val |= DBG_GREENCFG2_BP_GREEN; 1071 alc_miidbg_writereg(sc, MII_DBG_GREENCFG2, val); 1072 /* Turn off half bias. */ 1073 val = alc_miiext_readreg(sc, MII_EXT_PCS, MII_EXT_CLDCTL5); 1074 val |= EXT_CLDCTL5_BP_VD_HLFBIAS; 1075 alc_miiext_writereg(sc, MII_EXT_PCS, MII_EXT_CLDCTL5, val); 1076 } 1077 } 1078 1079 static void 644 1080 alc_phy_down(struct alc_softc *sc) 645 1081 { 1082 uint32_t gphy; 646 1083 647 1084 switch (sc->alc_ident->deviceid) { 1085 case DEVICEID_ATHEROS_AR8161: 1086 case DEVICEID_ATHEROS_E2200: 1087 case DEVICEID_ATHEROS_E2400: 1088 case DEVICEID_ATHEROS_E2500: 1089 case DEVICEID_ATHEROS_AR8162: 1090 case DEVICEID_ATHEROS_AR8171: 1091 case DEVICEID_ATHEROS_AR8172: 1092 gphy = CSR_READ_4(sc, ALC_GPHY_CFG); 1093 gphy &= ~(GPHY_CFG_EXT_RESET | GPHY_CFG_LED_MODE | 1094 GPHY_CFG_100AB_ENB | GPHY_CFG_PHY_PLL_ON); 1095 gphy |= GPHY_CFG_HIB_EN | GPHY_CFG_HIB_PULSE | 1096 GPHY_CFG_SEL_ANA_RESET; 1097 gphy |= GPHY_CFG_PHY_IDDQ | GPHY_CFG_PWDOWN_HW; 1098 CSR_WRITE_4(sc, ALC_GPHY_CFG, gphy); 1099 break; 648 1100 case DEVICEID_ATHEROS_AR8151: 649 1101 case DEVICEID_ATHEROS_AR8151_V2: 1102 case DEVICEID_ATHEROS_AR8152_B: 1103 case DEVICEID_ATHEROS_AR8152_B2: 650 1104 /* 651 1105 * GPHY power down caused more problems on AR8151 v2.0. 652 1106 * When driver is reloaded after GPHY power down, … … alc_phy_down(struct alc_softc *sc) 672 1126 } 673 1127 674 1128 static void 675 alc_aspm(struct alc_softc *sc, int media) 1129 alc_aspm(struct alc_softc *sc, int init, int media) 1130 { 1131 1132 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 1133 alc_aspm_816x(sc, init); 1134 else 1135 alc_aspm_813x(sc, media); 1136 } 1137 1138 static void 1139 alc_aspm_813x(struct alc_softc *sc, int media) 676 1140 { 677 1141 uint32_t pmcfg; 678 1142 uint16_t linkcfg; 679 1143 680 ALC_LOCK_ASSERT(sc); 1144 if ((sc->alc_flags & ALC_FLAG_LINK) == 0) 1145 return; 681 1146 682 1147 pmcfg = CSR_READ_4(sc, ALC_PM_CFG); 683 1148 if ((sc->alc_flags & (ALC_FLAG_APS | ALC_FLAG_PCIE)) == … … alc_aspm(struct alc_softc *sc, int media) 694 1159 695 1160 if ((sc->alc_flags & ALC_FLAG_APS) != 0) { 696 1161 /* Disable extended sync except AR8152 B v1.0 */ 697 linkcfg &= ~ 0x80;1162 linkcfg &= ~PCIEM_LINK_CTL_EXTENDED_SYNC; 698 1163 if (sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8152_B && 699 1164 sc->alc_rev == ATHEROS_AR8152_B_V10) 700 linkcfg |= 0x80;1165 linkcfg |= PCIEM_LINK_CTL_EXTENDED_SYNC; 701 1166 CSR_WRITE_2(sc, sc->alc_expcap + PCIER_LINK_CTL, 702 1167 linkcfg); 703 1168 pmcfg &= ~(PM_CFG_EN_BUFS_RX_L0S | PM_CFG_SA_DLY_ENB | … … alc_aspm(struct alc_softc *sc, int media) 758 1223 CSR_WRITE_4(sc, ALC_PM_CFG, pmcfg); 759 1224 } 760 1225 761 static int762 alc_a ttach(device_t dev)1226 static void 1227 alc_aspm_816x(struct alc_softc *sc, int init) 763 1228 { 764 struct alc_softc *sc; 765 struct ifnet *ifp; 766 char *aspm_state[] = { "L0s/L1", "L0s", "L1", "L0s/L1" }; 767 uint16_t burst; 768 int base, error, i, msic, msixc, state; 769 uint32_t cap, ctl, val; 770 771 error = 0; 772 sc = device_get_softc(dev); 773 sc->alc_dev = dev; 774 775 mtx_init(&sc->alc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 776 MTX_DEF); 777 callout_init_mtx(&sc->alc_tick_ch, &sc->alc_mtx, 0); 778 TASK_INIT(&sc->alc_int_task, 0, alc_int_task, sc); 779 sc->alc_ident = alc_find_ident(dev); 1229 uint32_t pmcfg; 780 1230 781 /* Map the device. */ 782 pci_enable_busmaster(dev); 783 sc->alc_res_spec = alc_res_spec_mem; 784 sc->alc_irq_spec = alc_irq_spec_legacy; 785 error = bus_alloc_resources(dev, sc->alc_res_spec, sc->alc_res); 786 if (error != 0) { 787 device_printf(dev, "cannot allocate memory resources.\n"); 788 goto fail; 1231 pmcfg = CSR_READ_4(sc, ALC_PM_CFG); 1232 pmcfg &= ~PM_CFG_L1_ENTRY_TIMER_816X_MASK; 1233 pmcfg |= PM_CFG_L1_ENTRY_TIMER_816X_DEFAULT; 1234 pmcfg &= ~PM_CFG_PM_REQ_TIMER_MASK; 1235 pmcfg |= PM_CFG_PM_REQ_TIMER_816X_DEFAULT; 1236 pmcfg &= ~PM_CFG_LCKDET_TIMER_MASK; 1237 pmcfg |= PM_CFG_LCKDET_TIMER_DEFAULT; 1238 pmcfg |= PM_CFG_SERDES_PD_EX_L1 | PM_CFG_CLK_SWH_L1 | PM_CFG_PCIE_RECV; 1239 pmcfg &= ~(PM_CFG_RX_L1_AFTER_L0S | PM_CFG_TX_L1_AFTER_L0S | 1240 PM_CFG_ASPM_L1_ENB | PM_CFG_ASPM_L0S_ENB | 1241 PM_CFG_SERDES_L1_ENB | PM_CFG_SERDES_PLL_L1_ENB | 1242 PM_CFG_SERDES_BUDS_RX_L1_ENB | PM_CFG_SA_DLY_ENB | 1243 PM_CFG_MAC_ASPM_CHK | PM_CFG_HOTRST); 1244 if (AR816X_REV(sc->alc_rev) <= AR816X_REV_A1 && 1245 (sc->alc_rev & 0x01) != 0) 1246 pmcfg |= PM_CFG_SERDES_L1_ENB | PM_CFG_SERDES_PLL_L1_ENB; 1247 if ((sc->alc_flags & ALC_FLAG_LINK) != 0) { 1248 /* Link up, enable both L0s, L1s. */ 1249 pmcfg |= PM_CFG_ASPM_L0S_ENB | PM_CFG_ASPM_L1_ENB | 1250 PM_CFG_MAC_ASPM_CHK; 1251 } else { 1252 if (init != 0) 1253 pmcfg |= PM_CFG_ASPM_L0S_ENB | PM_CFG_ASPM_L1_ENB | 1254 PM_CFG_MAC_ASPM_CHK; 1255 else if ((sc->alc_ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) 1256 pmcfg |= PM_CFG_ASPM_L1_ENB | PM_CFG_MAC_ASPM_CHK; 789 1257 } 1258 CSR_WRITE_4(sc, ALC_PM_CFG, pmcfg); 1259 } 790 1260 791 /* Set PHY address. */ 792 sc->alc_phyaddr = ALC_PHY_ADDR; 1261 static void 1262 alc_init_pcie(struct alc_softc *sc) 1263 { 1264 const char *aspm_state[] = { "L0s/L1", "L0s", "L1", "L0s/L1" }; 1265 uint32_t cap, ctl, val; 1266 int state; 793 1267 794 /* Initialize DMA parameters. */ 795 sc->alc_dma_rd_burst = 0; 796 sc->alc_dma_wr_burst = 0; 797 sc->alc_rcb = DMA_CFG_RCB_64; 798 if (pci_find_cap(dev, PCIY_EXPRESS, &base) == 0) { 799 sc->alc_flags |= ALC_FLAG_PCIE; 800 sc->alc_expcap = base; 801 burst = CSR_READ_2(sc, base + PCIER_DEVICE_CTL); 802 sc->alc_dma_rd_burst = 803 (burst & PCIEM_CTL_MAX_READ_REQUEST) >> 12; 804 sc->alc_dma_wr_burst = (burst & PCIEM_CTL_MAX_PAYLOAD) >> 5; 805 if (bootverbose) { 806 device_printf(dev, "Read request size : %u bytes.\n", 807 alc_dma_burst[sc->alc_dma_rd_burst]); 808 device_printf(dev, "TLP payload size : %u bytes.\n", 809 alc_dma_burst[sc->alc_dma_wr_burst]); 810 } 811 if (alc_dma_burst[sc->alc_dma_rd_burst] > 1024) 812 sc->alc_dma_rd_burst = 3; 813 if (alc_dma_burst[sc->alc_dma_wr_burst] > 1024) 814 sc->alc_dma_wr_burst = 3; 815 /* Clear data link and flow-control protocol error. */ 816 val = CSR_READ_4(sc, ALC_PEX_UNC_ERR_SEV); 817 val &= ~(PEX_UNC_ERR_SEV_DLP | PEX_UNC_ERR_SEV_FCP); 818 CSR_WRITE_4(sc, ALC_PEX_UNC_ERR_SEV, val); 1268 /* Clear data link and flow-control protocol error. */ 1269 val = CSR_READ_4(sc, ALC_PEX_UNC_ERR_SEV); 1270 val &= ~(PEX_UNC_ERR_SEV_DLP | PEX_UNC_ERR_SEV_FCP); 1271 CSR_WRITE_4(sc, ALC_PEX_UNC_ERR_SEV, val); 1272 1273 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) { 819 1274 CSR_WRITE_4(sc, ALC_LTSSM_ID_CFG, 820 1275 CSR_READ_4(sc, ALC_LTSSM_ID_CFG) & ~LTSSM_ID_WRO_ENB); 821 1276 CSR_WRITE_4(sc, ALC_PCIE_PHYMISC, 822 1277 CSR_READ_4(sc, ALC_PCIE_PHYMISC) | 823 1278 PCIE_PHYMISC_FORCE_RCV_DET); 824 1279 if (sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8152_B && 825 pci_get_revid(dev)== ATHEROS_AR8152_B_V10) {1280 sc->alc_rev == ATHEROS_AR8152_B_V10) { 826 1281 val = CSR_READ_4(sc, ALC_PCIE_PHYMISC2); 827 1282 val &= ~(PCIE_PHYMISC2_SERDES_CDR_MASK | 828 1283 PCIE_PHYMISC2_SERDES_TH_MASK); … … alc_attach(device_t dev) 831 1286 CSR_WRITE_4(sc, ALC_PCIE_PHYMISC2, val); 832 1287 } 833 1288 /* Disable ASPM L0S and L1. */ 834 cap = CSR_READ_2(sc, base+ PCIER_LINK_CAP);1289 cap = CSR_READ_2(sc, sc->alc_expcap + PCIER_LINK_CAP); 835 1290 if ((cap & PCIEM_LINK_CAP_ASPM) != 0) { 836 ctl = CSR_READ_2(sc, base+ PCIER_LINK_CTL);837 if ((ctl & 0x08) != 0)1291 ctl = CSR_READ_2(sc, sc->alc_expcap + PCIER_LINK_CTL); 1292 if ((ctl & PCIEM_LINK_CTL_RCB) != 0) 838 1293 sc->alc_rcb = DMA_CFG_RCB_128; 839 1294 if (bootverbose) 840 device_printf( dev, "RCB %u bytes\n",1295 device_printf(sc->alc_dev, "RCB %u bytes\n", 841 1296 sc->alc_rcb == DMA_CFG_RCB_64 ? 64 : 128); 842 state = ctl & 0x03;843 if (state & 0x01)1297 state = ctl & PCIEM_LINK_CTL_ASPMC; 1298 if (state & PCIEM_LINK_CTL_ASPMC_L0S) 844 1299 sc->alc_flags |= ALC_FLAG_L0S; 845 if (state & 0x02)1300 if (state & PCIEM_LINK_CTL_ASPMC_L1) 846 1301 sc->alc_flags |= ALC_FLAG_L1S; 847 1302 if (bootverbose) 848 1303 device_printf(sc->alc_dev, "ASPM %s %s\n", … … alc_attach(device_t dev) 854 1309 device_printf(sc->alc_dev, 855 1310 "no ASPM support\n"); 856 1311 } 1312 } else { 1313 val = CSR_READ_4(sc, ALC_PDLL_TRNS1); 1314 val &= ~PDLL_TRNS1_D3PLLOFF_ENB; 1315 CSR_WRITE_4(sc, ALC_PDLL_TRNS1, val); 1316 val = CSR_READ_4(sc, ALC_MASTER_CFG); 1317 if (AR816X_REV(sc->alc_rev) <= AR816X_REV_A1 && 1318 (sc->alc_rev & 0x01) != 0) { 1319 if ((val & MASTER_WAKEN_25M) == 0 || 1320 (val & MASTER_CLK_SEL_DIS) == 0) { 1321 val |= MASTER_WAKEN_25M | MASTER_CLK_SEL_DIS; 1322 CSR_WRITE_4(sc, ALC_MASTER_CFG, val); 1323 } 1324 } else { 1325 if ((val & MASTER_WAKEN_25M) == 0 || 1326 (val & MASTER_CLK_SEL_DIS) != 0) { 1327 val |= MASTER_WAKEN_25M; 1328 val &= ~MASTER_CLK_SEL_DIS; 1329 CSR_WRITE_4(sc, ALC_MASTER_CFG, val); 1330 } 1331 } 1332 } 1333 alc_aspm(sc, 1, IFM_UNKNOWN); 1334 } 1335 1336 static void 1337 alc_config_msi(struct alc_softc *sc) 1338 { 1339 uint32_t ctl, mod; 1340 1341 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) { 1342 /* 1343 * It seems interrupt moderation is controlled by 1344 * ALC_MSI_RETRANS_TIMER register if MSI/MSIX is active. 1345 * Driver uses RX interrupt moderation parameter to 1346 * program ALC_MSI_RETRANS_TIMER register. 1347 */ 1348 ctl = CSR_READ_4(sc, ALC_MSI_RETRANS_TIMER); 1349 ctl &= ~MSI_RETRANS_TIMER_MASK; 1350 ctl &= ~MSI_RETRANS_MASK_SEL_LINE; 1351 mod = ALC_USECS(sc->alc_int_rx_mod); 1352 if (mod == 0) 1353 mod = 1; 1354 ctl |= mod; 1355 if ((sc->alc_flags & ALC_FLAG_MSIX) != 0) 1356 CSR_WRITE_4(sc, ALC_MSI_RETRANS_TIMER, ctl | 1357 MSI_RETRANS_MASK_SEL_STD); 1358 else if ((sc->alc_flags & ALC_FLAG_MSI) != 0) 1359 CSR_WRITE_4(sc, ALC_MSI_RETRANS_TIMER, ctl | 1360 MSI_RETRANS_MASK_SEL_LINE); 1361 else 1362 CSR_WRITE_4(sc, ALC_MSI_RETRANS_TIMER, 0); 857 1363 } 1364 } 858 1365 859 /* Reset PHY. */ 860 alc_phy_reset(sc); 1366 static int 1367 alc_attach(device_t dev) 1368 { 1369 struct alc_softc *sc; 1370 struct ifnet *ifp; 1371 int base, error, i, msic, msixc; 1372 uint16_t burst; 861 1373 862 /* Reset the ethernet controller. */ 863 alc_reset(sc); 1374 error = 0; 1375 sc = device_get_softc(dev); 1376 sc->alc_dev = dev; 1377 sc->alc_rev = pci_get_revid(dev); 1378 1379 mtx_init(&sc->alc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, 1380 MTX_DEF); 1381 callout_init_mtx(&sc->alc_tick_ch, &sc->alc_mtx, 0); 1382 TASK_INIT(&sc->alc_int_task, 0, alc_int_task, sc); 1383 sc->alc_ident = alc_find_ident(dev); 1384 1385 /* Map the device. */ 1386 pci_enable_busmaster(dev); 1387 sc->alc_res_spec = alc_res_spec_mem; 1388 sc->alc_irq_spec = alc_irq_spec_legacy; 1389 error = bus_alloc_resources(dev, sc->alc_res_spec, sc->alc_res); 1390 if (error != 0) { 1391 device_printf(dev, "cannot allocate memory resources.\n"); 1392 goto fail; 1393 } 1394 1395 /* Set PHY address. */ 1396 sc->alc_phyaddr = ALC_PHY_ADDR; 864 1397 865 1398 /* 866 1399 * One odd thing is AR8132 uses the same PHY hardware(F1 … … alc_attach(device_t dev) 870 1403 * shows the same PHY model/revision number of AR8131. 871 1404 */ 872 1405 switch (sc->alc_ident->deviceid) { 1406 case DEVICEID_ATHEROS_E2200: 1407 case DEVICEID_ATHEROS_E2400: 1408 case DEVICEID_ATHEROS_E2500: 1409 sc->alc_flags |= ALC_FLAG_E2X00; 1410 /* FALLTHROUGH */ 1411 case DEVICEID_ATHEROS_AR8161: 1412 if (pci_get_subvendor(dev) == VENDORID_ATHEROS && 1413 pci_get_subdevice(dev) == 0x0091 && sc->alc_rev == 0) 1414 sc->alc_flags |= ALC_FLAG_LINK_WAR; 1415 /* FALLTHROUGH */ 1416 case DEVICEID_ATHEROS_AR8171: 1417 sc->alc_flags |= ALC_FLAG_AR816X_FAMILY; 1418 break; 1419 case DEVICEID_ATHEROS_AR8162: 1420 case DEVICEID_ATHEROS_AR8172: 1421 sc->alc_flags |= ALC_FLAG_FASTETHER | ALC_FLAG_AR816X_FAMILY; 1422 break; 873 1423 case DEVICEID_ATHEROS_AR8152_B: 874 1424 case DEVICEID_ATHEROS_AR8152_B2: 875 1425 sc->alc_flags |= ALC_FLAG_APS; … … alc_attach(device_t dev) 884 1434 default: 885 1435 break; 886 1436 } 887 sc->alc_flags |= ALC_FLAG_ ASPM_MON | ALC_FLAG_JUMBO;1437 sc->alc_flags |= ALC_FLAG_JUMBO; 888 1438 889 1439 /* 890 1440 * It seems that AR813x/AR815x has silicon bug for SMB. In … … alc_attach(device_t dev) 897 1447 * Don't use Tx CMB. It is known to have silicon bug. 898 1448 */ 899 1449 sc->alc_flags |= ALC_FLAG_CMB_BUG; 900 sc->alc_rev = pci_get_revid(dev);901 1450 sc->alc_chip_rev = CSR_READ_4(sc, ALC_MASTER_CFG) >> 902 1451 MASTER_CHIP_REV_SHIFT; 903 1452 if (bootverbose) { … … alc_attach(device_t dev) 905 1454 sc->alc_rev); 906 1455 device_printf(dev, "Chip id/revision : 0x%04x\n", 907 1456 sc->alc_chip_rev); 1457 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 1458 device_printf(dev, "AR816x revision : 0x%x\n", 1459 AR816X_REV(sc->alc_rev)); 908 1460 } 909 1461 device_printf(dev, "%u Tx FIFO, %u Rx FIFO\n", 910 1462 CSR_READ_4(sc, ALC_SRAM_TX_FIFO_LEN) * 8, 911 1463 CSR_READ_4(sc, ALC_SRAM_RX_FIFO_LEN) * 8); 912 1464 1465 /* Initialize DMA parameters. */ 1466 sc->alc_dma_rd_burst = 0; 1467 sc->alc_dma_wr_burst = 0; 1468 sc->alc_rcb = DMA_CFG_RCB_64; 1469 if (pci_find_cap(dev, PCIY_EXPRESS, &base) == 0) { 1470 sc->alc_flags |= ALC_FLAG_PCIE; 1471 sc->alc_expcap = base; 1472 burst = CSR_READ_2(sc, base + PCIER_DEVICE_CTL); 1473 sc->alc_dma_rd_burst = 1474 (burst & PCIEM_CTL_MAX_READ_REQUEST) >> 12; 1475 sc->alc_dma_wr_burst = (burst & PCIEM_CTL_MAX_PAYLOAD) >> 5; 1476 if (bootverbose) { 1477 device_printf(dev, "Read request size : %u bytes.\n", 1478 alc_dma_burst[sc->alc_dma_rd_burst]); 1479 device_printf(dev, "TLP payload size : %u bytes.\n", 1480 alc_dma_burst[sc->alc_dma_wr_burst]); 1481 } 1482 if (alc_dma_burst[sc->alc_dma_rd_burst] > 1024) 1483 sc->alc_dma_rd_burst = 3; 1484 if (alc_dma_burst[sc->alc_dma_wr_burst] > 1024) 1485 sc->alc_dma_wr_burst = 3; 1486 /* 1487 * Force maximum payload size to 128 bytes for 1488 * E2200/E2400/E2500. 1489 * Otherwise it triggers DMA write error. 1490 */ 1491 if ((sc->alc_flags & ALC_FLAG_E2X00) != 0) 1492 sc->alc_dma_wr_burst = 0; 1493 alc_init_pcie(sc); 1494 } 1495 1496 /* Reset PHY. */ 1497 alc_phy_reset(sc); 1498 1499 /* Reset the ethernet controller. */ 1500 alc_stop_mac(sc); 1501 alc_reset(sc); 1502 913 1503 /* Allocate IRQ resources. */ 914 1504 msixc = pci_msix_count(dev); 915 1505 msic = pci_msi_count(dev); … … alc_attach(device_t dev) 917 1507 device_printf(dev, "MSIX count : %d\n", msixc); 918 1508 device_printf(dev, "MSI count : %d\n", msic); 919 1509 } 920 /* Prefer MSIX over MSI. */ 1510 if (msixc > 1) 1511 msixc = 1; 1512 if (msic > 1) 1513 msic = 1; 1514 /* 1515 * Prefer MSIX over MSI. 1516 * AR816x controller has a silicon bug that MSI interrupt 1517 * does not assert if PCIM_CMD_INTxDIS bit of command 1518 * register is set. pci(4) was taught to handle that case. 1519 */ 921 1520 if (msix_disable == 0 || msi_disable == 0) { 922 if (msix_disable == 0 && msixc == ALC_MSIX_MESSAGES&&1521 if (msix_disable == 0 && msixc > 0 && 923 1522 pci_alloc_msix(dev, &msixc) == 0) { 924 if (msic == ALC_MSIX_MESSAGES) {1523 if (msic == 1) { 925 1524 device_printf(dev, 926 1525 "Using %d MSIX message(s).\n", msixc); 927 1526 sc->alc_flags |= ALC_FLAG_MSIX; … … alc_attach(device_t dev) 930 1529 pci_release_msi(dev); 931 1530 } 932 1531 if (msi_disable == 0 && (sc->alc_flags & ALC_FLAG_MSIX) == 0 && 933 msic == ALC_MSI_MESSAGES && 934 pci_alloc_msi(dev, &msic) == 0) { 935 if (msic == ALC_MSI_MESSAGES) { 1532 msic > 0 && pci_alloc_msi(dev, &msic) == 0) { 1533 if (msic == 1) { 936 1534 device_printf(dev, 937 1535 "Using %d MSI message(s).\n", msic); 938 1536 sc->alc_flags |= ALC_FLAG_MSI; … … alc_attach(device_t dev) 951 1549 /* Create device sysctl node. */ 952 1550 alc_sysctl_node(sc); 953 1551 954 if ((error = alc_dma_alloc(sc) != 0))1552 if ((error = alc_dma_alloc(sc)) != 0) 955 1553 goto fail; 956 1554 957 1555 /* Load station address. */ … … alc_attach(device_t dev) 1006 1604 * sample boards. To safety, don't enable Tx checksum offloading 1007 1605 * by default but give chance to users to toggle it if they know 1008 1606 * their controllers work without problems. 1607 * Fortunately, Tx checksum offloading for AR816x family 1608 * seems to work. 1009 1609 */ 1010 ifp->if_capenable &= ~IFCAP_TXCSUM; 1011 ifp->if_hwassist &= ~ALC_CSUM_FEATURES; 1610 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) { 1611 ifp->if_capenable &= ~IFCAP_TXCSUM; 1612 ifp->if_hwassist &= ~ALC_CSUM_FEATURES; 1613 } 1012 1614 1013 1615 /* Tell the upper layer(s) we support long frames. */ 1014 ifp->if_ data.ifi_hdrlen = sizeof(struct ether_vlan_header);1616 ifp->if_hdrlen = sizeof(struct ether_vlan_header); 1015 1617 1016 1618 /* Create local taskq. */ 1017 1619 sc->alc_tq = taskqueue_create_fast("alc_taskq", M_WAITOK, … … alc_attach(device_t dev) 1025 1627 taskqueue_start_threads(&sc->alc_tq, 1, PI_NET, "%s taskq", 1026 1628 device_get_nameunit(sc->alc_dev)); 1027 1629 1630 alc_config_msi(sc); 1028 1631 if ((sc->alc_flags & ALC_FLAG_MSIX) != 0) 1029 1632 msic = ALC_MSIX_MESSAGES; 1030 1633 else if ((sc->alc_flags & ALC_FLAG_MSI) != 0) … … alc_sysctl_node(struct alc_softc *sc) 1286 1889 &stats->tx_late_colls, "Late collisions"); 1287 1890 ALC_SYSCTL_STAT_ADD32(ctx, child, "excess_colls", 1288 1891 &stats->tx_excess_colls, "Excessive collisions"); 1289 ALC_SYSCTL_STAT_ADD32(ctx, child, "abort",1290 &stats->tx_abort, "Aborted frames due to Excessive collisions");1291 1892 ALC_SYSCTL_STAT_ADD32(ctx, child, "underruns", 1292 1893 &stats->tx_underrun, "FIFO underruns"); 1293 1894 ALC_SYSCTL_STAT_ADD32(ctx, child, "desc_underruns", … … again: 1599 2200 1600 2201 /* 1601 2202 * Create Tx buffer parent tag. 1602 * AR81 3x/AR815x allows 64bit DMA addressing of Tx/Rx buffers2203 * AR81[3567]x allows 64bit DMA addressing of Tx/Rx buffers 1603 2204 * so it needs separate parent DMA tag as parent DMA address 1604 2205 * space could be restricted to be within 32bit address space 1605 2206 * by 4GB boundary crossing. … … alc_dma_free(struct alc_softc *sc) 1734 2335 } 1735 2336 /* Tx descriptor ring. */ 1736 2337 if (sc->alc_cdata.alc_tx_ring_tag != NULL) { 1737 if (sc->alc_ cdata.alc_tx_ring_map != NULL)2338 if (sc->alc_rdata.alc_tx_ring_paddr != 0) 1738 2339 bus_dmamap_unload(sc->alc_cdata.alc_tx_ring_tag, 1739 2340 sc->alc_cdata.alc_tx_ring_map); 1740 if (sc->alc_cdata.alc_tx_ring_map != NULL && 1741 sc->alc_rdata.alc_tx_ring != NULL) 2341 if (sc->alc_rdata.alc_tx_ring != NULL) 1742 2342 bus_dmamem_free(sc->alc_cdata.alc_tx_ring_tag, 1743 2343 sc->alc_rdata.alc_tx_ring, 1744 2344 sc->alc_cdata.alc_tx_ring_map); 2345 sc->alc_rdata.alc_tx_ring_paddr = 0; 1745 2346 sc->alc_rdata.alc_tx_ring = NULL; 1746 sc->alc_cdata.alc_tx_ring_map = NULL;1747 2347 bus_dma_tag_destroy(sc->alc_cdata.alc_tx_ring_tag); 1748 2348 sc->alc_cdata.alc_tx_ring_tag = NULL; 1749 2349 } 1750 2350 /* Rx ring. */ 1751 2351 if (sc->alc_cdata.alc_rx_ring_tag != NULL) { 1752 if (sc->alc_ cdata.alc_rx_ring_map != NULL)2352 if (sc->alc_rdata.alc_rx_ring_paddr != 0) 1753 2353 bus_dmamap_unload(sc->alc_cdata.alc_rx_ring_tag, 1754 2354 sc->alc_cdata.alc_rx_ring_map); 1755 if (sc->alc_cdata.alc_rx_ring_map != NULL && 1756 sc->alc_rdata.alc_rx_ring != NULL) 2355 if (sc->alc_rdata.alc_rx_ring != NULL) 1757 2356 bus_dmamem_free(sc->alc_cdata.alc_rx_ring_tag, 1758 2357 sc->alc_rdata.alc_rx_ring, 1759 2358 sc->alc_cdata.alc_rx_ring_map); 2359 sc->alc_rdata.alc_rx_ring_paddr = 0; 1760 2360 sc->alc_rdata.alc_rx_ring = NULL; 1761 sc->alc_cdata.alc_rx_ring_map = NULL;1762 2361 bus_dma_tag_destroy(sc->alc_cdata.alc_rx_ring_tag); 1763 2362 sc->alc_cdata.alc_rx_ring_tag = NULL; 1764 2363 } 1765 2364 /* Rx return ring. */ 1766 2365 if (sc->alc_cdata.alc_rr_ring_tag != NULL) { 1767 if (sc->alc_ cdata.alc_rr_ring_map != NULL)2366 if (sc->alc_rdata.alc_rr_ring_paddr != 0) 1768 2367 bus_dmamap_unload(sc->alc_cdata.alc_rr_ring_tag, 1769 2368 sc->alc_cdata.alc_rr_ring_map); 1770 if (sc->alc_cdata.alc_rr_ring_map != NULL && 1771 sc->alc_rdata.alc_rr_ring != NULL) 2369 if (sc->alc_rdata.alc_rr_ring != NULL) 1772 2370 bus_dmamem_free(sc->alc_cdata.alc_rr_ring_tag, 1773 2371 sc->alc_rdata.alc_rr_ring, 1774 2372 sc->alc_cdata.alc_rr_ring_map); 2373 sc->alc_rdata.alc_rr_ring_paddr = 0; 1775 2374 sc->alc_rdata.alc_rr_ring = NULL; 1776 sc->alc_cdata.alc_rr_ring_map = NULL;1777 2375 bus_dma_tag_destroy(sc->alc_cdata.alc_rr_ring_tag); 1778 2376 sc->alc_cdata.alc_rr_ring_tag = NULL; 1779 2377 } 1780 2378 /* CMB block */ 1781 2379 if (sc->alc_cdata.alc_cmb_tag != NULL) { 1782 if (sc->alc_ cdata.alc_cmb_map != NULL)2380 if (sc->alc_rdata.alc_cmb_paddr != 0) 1783 2381 bus_dmamap_unload(sc->alc_cdata.alc_cmb_tag, 1784 2382 sc->alc_cdata.alc_cmb_map); 1785 if (sc->alc_cdata.alc_cmb_map != NULL && 1786 sc->alc_rdata.alc_cmb != NULL) 2383 if (sc->alc_rdata.alc_cmb != NULL) 1787 2384 bus_dmamem_free(sc->alc_cdata.alc_cmb_tag, 1788 2385 sc->alc_rdata.alc_cmb, 1789 sc->alc_cdata.alc_cmb_map); 2386 sc->alc_cdata.alc_cmb_map); 2387 sc->alc_rdata.alc_cmb_paddr = 0; 1790 2388 sc->alc_rdata.alc_cmb = NULL; 1791 sc->alc_cdata.alc_cmb_map = NULL;1792 2389 bus_dma_tag_destroy(sc->alc_cdata.alc_cmb_tag); 1793 2390 sc->alc_cdata.alc_cmb_tag = NULL; 1794 2391 } 1795 2392 /* SMB block */ 1796 2393 if (sc->alc_cdata.alc_smb_tag != NULL) { 1797 if (sc->alc_ cdata.alc_smb_map != NULL)2394 if (sc->alc_rdata.alc_smb_paddr != 0) 1798 2395 bus_dmamap_unload(sc->alc_cdata.alc_smb_tag, 1799 2396 sc->alc_cdata.alc_smb_map); 1800 if (sc->alc_cdata.alc_smb_map != NULL && 1801 sc->alc_rdata.alc_smb != NULL) 2397 if (sc->alc_rdata.alc_smb != NULL) 1802 2398 bus_dmamem_free(sc->alc_cdata.alc_smb_tag, 1803 2399 sc->alc_rdata.alc_smb, 1804 2400 sc->alc_cdata.alc_smb_map); 2401 sc->alc_rdata.alc_smb_paddr = 0; 1805 2402 sc->alc_rdata.alc_smb = NULL; 1806 sc->alc_cdata.alc_smb_map = NULL;1807 2403 bus_dma_tag_destroy(sc->alc_cdata.alc_smb_tag); 1808 2404 sc->alc_cdata.alc_smb_tag = NULL; 1809 2405 } … … alc_setlinkspeed(struct alc_softc *sc) 1906 2502 static void 1907 2503 alc_setwol(struct alc_softc *sc) 1908 2504 { 2505 2506 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 2507 alc_setwol_816x(sc); 2508 else 2509 alc_setwol_813x(sc); 2510 } 2511 2512 static void 2513 alc_setwol_813x(struct alc_softc *sc) 2514 { 1909 2515 struct ifnet *ifp; 1910 2516 uint32_t reg, pmcs; 1911 2517 uint16_t pmstat; … … alc_setwol(struct alc_softc *sc) 1966 2572 sc->alc_pmcap + PCIR_POWER_STATUS, pmstat, 2); 1967 2573 } 1968 2574 2575 static void 2576 alc_setwol_816x(struct alc_softc *sc) 2577 { 2578 struct ifnet *ifp; 2579 uint32_t gphy, mac, master, pmcs, reg; 2580 uint16_t pmstat; 2581 2582 ALC_LOCK_ASSERT(sc); 2583 2584 ifp = sc->alc_ifp; 2585 master = CSR_READ_4(sc, ALC_MASTER_CFG); 2586 master &= ~MASTER_CLK_SEL_DIS; 2587 gphy = CSR_READ_4(sc, ALC_GPHY_CFG); 2588 gphy &= ~(GPHY_CFG_EXT_RESET | GPHY_CFG_LED_MODE | GPHY_CFG_100AB_ENB | 2589 GPHY_CFG_PHY_PLL_ON); 2590 gphy |= GPHY_CFG_HIB_EN | GPHY_CFG_HIB_PULSE | GPHY_CFG_SEL_ANA_RESET; 2591 if ((sc->alc_flags & ALC_FLAG_PM) == 0) { 2592 CSR_WRITE_4(sc, ALC_WOL_CFG, 0); 2593 gphy |= GPHY_CFG_PHY_IDDQ | GPHY_CFG_PWDOWN_HW; 2594 mac = CSR_READ_4(sc, ALC_MAC_CFG); 2595 } else { 2596 if ((ifp->if_capenable & IFCAP_WOL) != 0) { 2597 gphy |= GPHY_CFG_EXT_RESET; 2598 if ((sc->alc_flags & ALC_FLAG_FASTETHER) == 0) 2599 alc_setlinkspeed(sc); 2600 } 2601 pmcs = 0; 2602 if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0) 2603 pmcs |= WOL_CFG_MAGIC | WOL_CFG_MAGIC_ENB; 2604 CSR_WRITE_4(sc, ALC_WOL_CFG, pmcs); 2605 mac = CSR_READ_4(sc, ALC_MAC_CFG); 2606 mac &= ~(MAC_CFG_DBG | MAC_CFG_PROMISC | MAC_CFG_ALLMULTI | 2607 MAC_CFG_BCAST); 2608 if ((ifp->if_capenable & IFCAP_WOL_MCAST) != 0) 2609 mac |= MAC_CFG_ALLMULTI | MAC_CFG_BCAST; 2610 if ((ifp->if_capenable & IFCAP_WOL) != 0) 2611 mac |= MAC_CFG_RX_ENB; 2612 alc_miiext_writereg(sc, MII_EXT_ANEG, MII_EXT_ANEG_S3DIG10, 2613 ANEG_S3DIG10_SL); 2614 } 2615 2616 /* Enable OSC. */ 2617 reg = CSR_READ_4(sc, ALC_MISC); 2618 reg &= ~MISC_INTNLOSC_OPEN; 2619 CSR_WRITE_4(sc, ALC_MISC, reg); 2620 reg |= MISC_INTNLOSC_OPEN; 2621 CSR_WRITE_4(sc, ALC_MISC, reg); 2622 CSR_WRITE_4(sc, ALC_MASTER_CFG, master); 2623 CSR_WRITE_4(sc, ALC_MAC_CFG, mac); 2624 CSR_WRITE_4(sc, ALC_GPHY_CFG, gphy); 2625 reg = CSR_READ_4(sc, ALC_PDLL_TRNS1); 2626 reg |= PDLL_TRNS1_D3PLLOFF_ENB; 2627 CSR_WRITE_4(sc, ALC_PDLL_TRNS1, reg); 2628 2629 if ((sc->alc_flags & ALC_FLAG_PM) != 0) { 2630 /* Request PME. */ 2631 pmstat = pci_read_config(sc->alc_dev, 2632 sc->alc_pmcap + PCIR_POWER_STATUS, 2); 2633 pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE); 2634 if ((ifp->if_capenable & IFCAP_WOL) != 0) 2635 pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE; 2636 pci_write_config(sc->alc_dev, 2637 sc->alc_pmcap + PCIR_POWER_STATUS, pmstat, 2); 2638 } 2639 } 2640 1969 2641 static int 1970 2642 alc_suspend(device_t dev) 1971 2643 { … … alc_encap(struct alc_softc *sc, struct mbuf **m_head) 2036 2708 ip_off = poff = 0; 2037 2709 if ((m->m_pkthdr.csum_flags & (ALC_CSUM_FEATURES | CSUM_TSO)) != 0) { 2038 2710 /* 2039 * AR81 3x/AR815x requires offset of TCP/UDP header in its2711 * AR81[3567]x requires offset of TCP/UDP header in its 2040 2712 * Tx descriptor to perform Tx checksum offloading. TSO 2041 2713 * also requires TCP header offset and modification of 2042 2714 * IP/TCP header. This kind of operation takes many CPU … … alc_encap(struct alc_softc *sc, struct mbuf **m_head) 2174 2846 cflags |= (poff << TD_TCPHDR_OFFSET_SHIFT) & 2175 2847 TD_TCPHDR_OFFSET_MASK; 2176 2848 /* 2177 * AR81 3x/AR815x requires the first buffer should2849 * AR81[3567]x requires the first buffer should 2178 2850 * only hold IP/TCP header data. Payload should 2179 2851 * be handled in other descriptors. 2180 2852 */ … … alc_start_locked(struct ifnet *ifp) 2305 2977 bus_dmamap_sync(sc->alc_cdata.alc_tx_ring_tag, 2306 2978 sc->alc_cdata.alc_tx_ring_map, BUS_DMASYNC_PREWRITE); 2307 2979 /* Kick. Assume we're using normal Tx priority queue. */ 2308 CSR_WRITE_4(sc, ALC_MBOX_TD_PROD_IDX, 2309 (sc->alc_cdata.alc_tx_prod << 2310 MBOX_TD_PROD_LO_IDX_SHIFT) & 2311 MBOX_TD_PROD_LO_IDX_MASK); 2980 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 2981 CSR_WRITE_2(sc, ALC_MBOX_TD_PRI0_PROD_IDX, 2982 (uint16_t)sc->alc_cdata.alc_tx_prod); 2983 else 2984 CSR_WRITE_4(sc, ALC_MBOX_TD_PROD_IDX, 2985 (sc->alc_cdata.alc_tx_prod << 2986 MBOX_TD_PROD_LO_IDX_SHIFT) & 2987 MBOX_TD_PROD_LO_IDX_MASK); 2312 2988 /* Set a timeout in case the chip goes out to lunch. */ 2313 2989 sc->alc_watchdog_timer = ALC_TX_TIMEOUT; 2314 2990 } … … alc_watchdog(struct alc_softc *sc) 2327 3003 ifp = sc->alc_ifp; 2328 3004 if ((sc->alc_flags & ALC_FLAG_LINK) == 0) { 2329 3005 if_printf(sc->alc_ifp, "watchdog timeout (lost link)\n"); 2330 if p->if_oerrors++;3006 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); 2331 3007 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 2332 3008 alc_init_locked(sc); 2333 3009 return; 2334 3010 } 2335 3011 if_printf(sc->alc_ifp, "watchdog timeout -- resetting\n"); 2336 if p->if_oerrors++;3012 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); 2337 3013 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 2338 3014 alc_init_locked(sc); 2339 3015 if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd)) … … alc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 2362 3038 else if (ifp->if_mtu != ifr->ifr_mtu) { 2363 3039 ALC_LOCK(sc); 2364 3040 ifp->if_mtu = ifr->ifr_mtu; 2365 /* AR81 3x/AR815x has 13 bits MSS field. */3041 /* AR81[3567]x has 13 bits MSS field. */ 2366 3042 if (ifp->if_mtu > ALC_TSO_MTU && 2367 3043 (ifp->if_capenable & IFCAP_TSO4) != 0) { 2368 3044 ifp->if_capenable &= ~IFCAP_TSO4; … … alc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 2413 3089 (ifp->if_capabilities & IFCAP_TSO4) != 0) { 2414 3090 ifp->if_capenable ^= IFCAP_TSO4; 2415 3091 if ((ifp->if_capenable & IFCAP_TSO4) != 0) { 2416 /* AR81 3x/AR815x has 13 bits MSS field. */3092 /* AR81[3567]x has 13 bits MSS field. */ 2417 3093 if (ifp->if_mtu > ALC_TSO_MTU) { 2418 3094 ifp->if_capenable &= ~IFCAP_TSO4; 2419 3095 ifp->if_hwassist &= ~CSUM_TSO; … … alc_mac_config(struct alc_softc *sc) 2465 3141 reg = CSR_READ_4(sc, ALC_MAC_CFG); 2466 3142 reg &= ~(MAC_CFG_FULL_DUPLEX | MAC_CFG_TX_FC | MAC_CFG_RX_FC | 2467 3143 MAC_CFG_SPEED_MASK); 2468 if (sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8151 || 3144 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0 || 3145 sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8151 || 2469 3146 sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8151_V2 || 2470 3147 sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8152_B2) 2471 3148 reg |= MAC_CFG_HASH_ALG_CRC32 | MAC_CFG_SPEED_MODE_SW; … … alc_stats_update(struct alc_softc *sc) 2603 3280 stat->tx_multi_colls += smb->tx_multi_colls; 2604 3281 stat->tx_late_colls += smb->tx_late_colls; 2605 3282 stat->tx_excess_colls += smb->tx_excess_colls; 2606 stat->tx_abort += smb->tx_abort;2607 3283 stat->tx_underrun += smb->tx_underrun; 2608 3284 stat->tx_desc_underrun += smb->tx_desc_underrun; 2609 3285 stat->tx_lenerrs += smb->tx_lenerrs; … … alc_stats_update(struct alc_softc *sc) 2612 3288 stat->tx_mcast_bytes += smb->tx_mcast_bytes; 2613 3289 2614 3290 /* Update counters in ifnet. */ 2615 if p->if_opackets += smb->tx_frames;3291 if_inc_counter(ifp, IFCOUNTER_OPACKETS, smb->tx_frames); 2616 3292 2617 if p->if_collisions +=smb->tx_single_colls +3293 if_inc_counter(ifp, IFCOUNTER_COLLISIONS, smb->tx_single_colls + 2618 3294 smb->tx_multi_colls * 2 + smb->tx_late_colls + 2619 smb->tx_ abort * HDPX_CFG_RETRY_DEFAULT;3295 smb->tx_excess_colls * HDPX_CFG_RETRY_DEFAULT); 2620 3296 2621 /* 2622 * XXX 2623 * tx_pkts_truncated counter looks suspicious. It constantly 2624 * increments with no sign of Tx errors. This may indicate 2625 * the counter name is not correct one so I've removed the 2626 * counter in output errors. 2627 */ 2628 ifp->if_oerrors += smb->tx_abort + smb->tx_late_colls + 2629 smb->tx_underrun; 3297 if_inc_counter(ifp, IFCOUNTER_OERRORS, smb->tx_late_colls + 3298 smb->tx_excess_colls + smb->tx_underrun + smb->tx_pkts_truncated); 2630 3299 2631 if p->if_ipackets += smb->rx_frames;3300 if_inc_counter(ifp, IFCOUNTER_IPACKETS, smb->rx_frames); 2632 3301 2633 ifp->if_ierrors += smb->rx_crcerrs + smb->rx_lenerrs + 3302 if_inc_counter(ifp, IFCOUNTER_IERRORS, 3303 smb->rx_crcerrs + smb->rx_lenerrs + 2634 3304 smb->rx_runts + smb->rx_pkts_truncated + 2635 3305 smb->rx_fifo_oflows + smb->rx_rrs_errs + 2636 smb->rx_alignerrs ;3306 smb->rx_alignerrs); 2637 3307 2638 3308 if ((sc->alc_flags & ALC_FLAG_SMB_BUG) == 0) { 2639 3309 /* Update done, clear. */ … … alc_txeof(struct alc_softc *sc) 2754 3424 bus_dmamap_sync(sc->alc_cdata.alc_cmb_tag, 2755 3425 sc->alc_cdata.alc_cmb_map, BUS_DMASYNC_POSTREAD); 2756 3426 prod = sc->alc_rdata.alc_cmb->cons; 2757 } else 2758 prod = CSR_READ_4(sc, ALC_MBOX_TD_CONS_IDX); 2759 /* Assume we're using normal Tx priority queue. */ 2760 prod = (prod & MBOX_TD_CONS_LO_IDX_MASK) >> 2761 MBOX_TD_CONS_LO_IDX_SHIFT; 3427 } else { 3428 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 3429 prod = CSR_READ_2(sc, ALC_MBOX_TD_PRI0_CONS_IDX); 3430 else { 3431 prod = CSR_READ_4(sc, ALC_MBOX_TD_CONS_IDX); 3432 /* Assume we're using normal Tx priority queue. */ 3433 prod = (prod & MBOX_TD_CONS_LO_IDX_MASK) >> 3434 MBOX_TD_CONS_LO_IDX_SHIFT; 3435 } 3436 } 2762 3437 cons = sc->alc_cdata.alc_tx_cons; 2763 3438 /* 2764 3439 * Go through our Tx list and free mbufs for those … … alc_rxintr(struct alc_softc *sc, int count) 2894 3569 * it still seems that pre-fetching needs more 2895 3570 * experimentation. 2896 3571 */ 2897 CSR_WRITE_4(sc, ALC_MBOX_RD0_PROD_IDX, 2898 sc->alc_cdata.alc_rx_cons); 3572 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 3573 CSR_WRITE_2(sc, ALC_MBOX_RD0_PROD_IDX, 3574 (uint16_t)sc->alc_cdata.alc_rx_cons); 3575 else 3576 CSR_WRITE_4(sc, ALC_MBOX_RD0_PROD_IDX, 3577 sc->alc_cdata.alc_rx_cons); 2899 3578 } 2900 3579 2901 3580 return (count > 0 ? 0 : EAGAIN); … … alc_fixup_rx(struct ifnet *ifp, struct mbuf *m) 2925 3604 */ 2926 3605 MGETHDR(n, M_NOWAIT, MT_DATA); 2927 3606 if (n == NULL) { 2928 if p->if_iqdrops++;3607 if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); 2929 3608 m_freem(m); 2930 3609 return (NULL); 2931 3610 } … … alc_rxeof(struct alc_softc *sc, struct rx_rdesc *rrd) 2981 3660 mp = rxd->rx_m; 2982 3661 /* Add a new receive buffer to the ring. */ 2983 3662 if (alc_newbuf(sc, rxd) != 0) { 2984 if p->if_iqdrops++;3663 if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1); 2985 3664 /* Reuse Rx buffers. */ 2986 3665 if (sc->alc_cdata.alc_rxhead != NULL) 2987 3666 m_freem(sc->alc_cdata.alc_rxhead); … … alc_tick(void *arg) 3087 3766 } 3088 3767 3089 3768 static void 3090 alc_ reset(struct alc_softc *sc)3769 alc_osc_reset(struct alc_softc *sc) 3091 3770 { 3092 3771 uint32_t reg; 3772 3773 reg = CSR_READ_4(sc, ALC_MISC3); 3774 reg &= ~MISC3_25M_BY_SW; 3775 reg |= MISC3_25M_NOTO_INTNL; 3776 CSR_WRITE_4(sc, ALC_MISC3, reg); 3777 3778 reg = CSR_READ_4(sc, ALC_MISC); 3779 if (AR816X_REV(sc->alc_rev) >= AR816X_REV_B0) { 3780 /* 3781 * Restore over-current protection default value. 3782 * This value could be reset by MAC reset. 3783 */ 3784 reg &= ~MISC_PSW_OCP_MASK; 3785 reg |= (MISC_PSW_OCP_DEFAULT << MISC_PSW_OCP_SHIFT); 3786 reg &= ~MISC_INTNLOSC_OPEN; 3787 CSR_WRITE_4(sc, ALC_MISC, reg); 3788 CSR_WRITE_4(sc, ALC_MISC, reg | MISC_INTNLOSC_OPEN); 3789 reg = CSR_READ_4(sc, ALC_MISC2); 3790 reg &= ~MISC2_CALB_START; 3791 CSR_WRITE_4(sc, ALC_MISC2, reg); 3792 CSR_WRITE_4(sc, ALC_MISC2, reg | MISC2_CALB_START); 3793 3794 } else { 3795 reg &= ~MISC_INTNLOSC_OPEN; 3796 /* Disable isolate for revision A devices. */ 3797 if (AR816X_REV(sc->alc_rev) <= AR816X_REV_A1) 3798 reg &= ~MISC_ISO_ENB; 3799 CSR_WRITE_4(sc, ALC_MISC, reg | MISC_INTNLOSC_OPEN); 3800 CSR_WRITE_4(sc, ALC_MISC, reg); 3801 } 3802 3803 DELAY(20); 3804 } 3805 3806 static void 3807 alc_reset(struct alc_softc *sc) 3808 { 3809 uint32_t pmcfg, reg; 3093 3810 int i; 3094 3811 3095 reg = CSR_READ_4(sc, ALC_MASTER_CFG) & 0xFFFF; 3812 pmcfg = 0; 3813 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) { 3814 /* Reset workaround. */ 3815 CSR_WRITE_4(sc, ALC_MBOX_RD0_PROD_IDX, 1); 3816 if (AR816X_REV(sc->alc_rev) <= AR816X_REV_A1 && 3817 (sc->alc_rev & 0x01) != 0) { 3818 /* Disable L0s/L1s before reset. */ 3819 pmcfg = CSR_READ_4(sc, ALC_PM_CFG); 3820 if ((pmcfg & (PM_CFG_ASPM_L0S_ENB | PM_CFG_ASPM_L1_ENB)) 3821 != 0) { 3822 pmcfg &= ~(PM_CFG_ASPM_L0S_ENB | 3823 PM_CFG_ASPM_L1_ENB); 3824 CSR_WRITE_4(sc, ALC_PM_CFG, pmcfg); 3825 } 3826 } 3827 } 3828 reg = CSR_READ_4(sc, ALC_MASTER_CFG); 3096 3829 reg |= MASTER_OOB_DIS_OFF | MASTER_RESET; 3097 3830 CSR_WRITE_4(sc, ALC_MASTER_CFG, reg); 3831 3832 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) { 3833 for (i = ALC_RESET_TIMEOUT; i > 0; i--) { 3834 DELAY(10); 3835 if (CSR_READ_4(sc, ALC_MBOX_RD0_PROD_IDX) == 0) 3836 break; 3837 } 3838 if (i == 0) 3839 device_printf(sc->alc_dev, "MAC reset timeout!\n"); 3840 } 3098 3841 for (i = ALC_RESET_TIMEOUT; i > 0; i--) { 3099 3842 DELAY(10); 3100 3843 if ((CSR_READ_4(sc, ALC_MASTER_CFG) & MASTER_RESET) == 0) … … alc_reset(struct alc_softc *sc) 3104 3847 device_printf(sc->alc_dev, "master reset timeout!\n"); 3105 3848 3106 3849 for (i = ALC_RESET_TIMEOUT; i > 0; i--) { 3107 if ((reg = CSR_READ_4(sc, ALC_IDLE_STATUS)) == 0) 3850 reg = CSR_READ_4(sc, ALC_IDLE_STATUS); 3851 if ((reg & (IDLE_STATUS_RXMAC | IDLE_STATUS_TXMAC | 3852 IDLE_STATUS_RXQ | IDLE_STATUS_TXQ)) == 0) 3108 3853 break; 3109 3854 DELAY(10); 3110 3855 } 3111 3112 3856 if (i == 0) 3113 3857 device_printf(sc->alc_dev, "reset timeout(0x%08x)!\n", reg); 3858 3859 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) { 3860 if (AR816X_REV(sc->alc_rev) <= AR816X_REV_A1 && 3861 (sc->alc_rev & 0x01) != 0) { 3862 reg = CSR_READ_4(sc, ALC_MASTER_CFG); 3863 reg |= MASTER_CLK_SEL_DIS; 3864 CSR_WRITE_4(sc, ALC_MASTER_CFG, reg); 3865 /* Restore L0s/L1s config. */ 3866 if ((pmcfg & (PM_CFG_ASPM_L0S_ENB | PM_CFG_ASPM_L1_ENB)) 3867 != 0) 3868 CSR_WRITE_4(sc, ALC_PM_CFG, pmcfg); 3869 } 3870 3871 alc_osc_reset(sc); 3872 reg = CSR_READ_4(sc, ALC_MISC3); 3873 reg &= ~MISC3_25M_BY_SW; 3874 reg |= MISC3_25M_NOTO_INTNL; 3875 CSR_WRITE_4(sc, ALC_MISC3, reg); 3876 reg = CSR_READ_4(sc, ALC_MISC); 3877 reg &= ~MISC_INTNLOSC_OPEN; 3878 if (AR816X_REV(sc->alc_rev) <= AR816X_REV_A1) 3879 reg &= ~MISC_ISO_ENB; 3880 CSR_WRITE_4(sc, ALC_MISC, reg); 3881 DELAY(20); 3882 } 3883 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0 || 3884 sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8152_B || 3885 sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8151_V2) 3886 CSR_WRITE_4(sc, ALC_SERDES_LOCK, 3887 CSR_READ_4(sc, ALC_SERDES_LOCK) | SERDES_MAC_CLK_SLOWDOWN | 3888 SERDES_PHY_CLK_SLOWDOWN); 3114 3889 } 3115 3890 3116 3891 static void … … alc_init_locked(struct alc_softc *sc) 3161 3936 alc_init_smb(sc); 3162 3937 3163 3938 /* Enable all clocks. */ 3164 CSR_WRITE_4(sc, ALC_CLK_GATING_CFG, 0); 3939 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) { 3940 CSR_WRITE_4(sc, ALC_CLK_GATING_CFG, CLK_GATING_DMAW_ENB | 3941 CLK_GATING_DMAR_ENB | CLK_GATING_TXQ_ENB | 3942 CLK_GATING_RXQ_ENB | CLK_GATING_TXMAC_ENB | 3943 CLK_GATING_RXMAC_ENB); 3944 if (AR816X_REV(sc->alc_rev) >= AR816X_REV_B0) 3945 CSR_WRITE_4(sc, ALC_IDLE_DECISN_TIMER, 3946 IDLE_DECISN_TIMER_DEFAULT_1MS); 3947 } else 3948 CSR_WRITE_4(sc, ALC_CLK_GATING_CFG, 0); 3165 3949 3166 3950 /* Reprogram the station address. */ 3167 3951 bcopy(IF_LLADDR(ifp), eaddr, ETHER_ADDR_LEN); … … alc_init_locked(struct alc_softc *sc) 3187 3971 paddr = sc->alc_rdata.alc_rx_ring_paddr; 3188 3972 CSR_WRITE_4(sc, ALC_RX_BASE_ADDR_HI, ALC_ADDR_HI(paddr)); 3189 3973 CSR_WRITE_4(sc, ALC_RD0_HEAD_ADDR_LO, ALC_ADDR_LO(paddr)); 3190 /* We use one Rx ring. */ 3191 CSR_WRITE_4(sc, ALC_RD1_HEAD_ADDR_LO, 0); 3192 CSR_WRITE_4(sc, ALC_RD2_HEAD_ADDR_LO, 0); 3193 CSR_WRITE_4(sc, ALC_RD3_HEAD_ADDR_LO, 0); 3974 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) { 3975 /* We use one Rx ring. */ 3976 CSR_WRITE_4(sc, ALC_RD1_HEAD_ADDR_LO, 0); 3977 CSR_WRITE_4(sc, ALC_RD2_HEAD_ADDR_LO, 0); 3978 CSR_WRITE_4(sc, ALC_RD3_HEAD_ADDR_LO, 0); 3979 } 3194 3980 /* Set Rx descriptor counter. */ 3195 3981 CSR_WRITE_4(sc, ALC_RD_RING_CNT, 3196 3982 (ALC_RX_RING_CNT << RD_RING_CNT_SHIFT) & RD_RING_CNT_MASK); … … alc_init_locked(struct alc_softc *sc) 3215 4001 paddr = sc->alc_rdata.alc_rr_ring_paddr; 3216 4002 /* Set Rx return descriptor base addresses. */ 3217 4003 CSR_WRITE_4(sc, ALC_RRD0_HEAD_ADDR_LO, ALC_ADDR_LO(paddr)); 3218 /* We use one Rx return ring. */ 3219 CSR_WRITE_4(sc, ALC_RRD1_HEAD_ADDR_LO, 0); 3220 CSR_WRITE_4(sc, ALC_RRD2_HEAD_ADDR_LO, 0); 3221 CSR_WRITE_4(sc, ALC_RRD3_HEAD_ADDR_LO, 0); 4004 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) { 4005 /* We use one Rx return ring. */ 4006 CSR_WRITE_4(sc, ALC_RRD1_HEAD_ADDR_LO, 0); 4007 CSR_WRITE_4(sc, ALC_RRD2_HEAD_ADDR_LO, 0); 4008 CSR_WRITE_4(sc, ALC_RRD3_HEAD_ADDR_LO, 0); 4009 } 3222 4010 /* Set Rx return descriptor counter. */ 3223 4011 CSR_WRITE_4(sc, ALC_RRD_RING_CNT, 3224 4012 (ALC_RR_RING_CNT << RRD_RING_CNT_SHIFT) & RRD_RING_CNT_MASK); … … alc_init_locked(struct alc_softc *sc) 3245 4033 3246 4034 /* Configure interrupt moderation timer. */ 3247 4035 reg = ALC_USECS(sc->alc_int_rx_mod) << IM_TIMER_RX_SHIFT; 3248 reg |= ALC_USECS(sc->alc_int_tx_mod) << IM_TIMER_TX_SHIFT; 4036 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) 4037 reg |= ALC_USECS(sc->alc_int_tx_mod) << IM_TIMER_TX_SHIFT; 3249 4038 CSR_WRITE_4(sc, ALC_IM_TIMER, reg); 3250 4039 /* 3251 4040 * We don't want to automatic interrupt clear as task queue 3252 4041 * for the interrupt should know interrupt status. 3253 4042 */ 3254 reg = MASTER_SA_TIMER_ENB; 4043 reg = CSR_READ_4(sc, ALC_MASTER_CFG); 4044 reg &= ~(MASTER_IM_RX_TIMER_ENB | MASTER_IM_TX_TIMER_ENB); 4045 reg |= MASTER_SA_TIMER_ENB; 3255 4046 if (ALC_USECS(sc->alc_int_rx_mod) != 0) 3256 4047 reg |= MASTER_IM_RX_TIMER_ENB; 3257 if (ALC_USECS(sc->alc_int_tx_mod) != 0) 4048 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0 && 4049 ALC_USECS(sc->alc_int_tx_mod) != 0) 3258 4050 reg |= MASTER_IM_TX_TIMER_ENB; 3259 4051 CSR_WRITE_4(sc, ALC_MASTER_CFG, reg); 3260 4052 /* … … alc_init_locked(struct alc_softc *sc) 3263 4055 */ 3264 4056 CSR_WRITE_4(sc, ALC_INTR_RETRIG_TIMER, ALC_USECS(0)); 3265 4057 /* Configure CMB. */ 3266 if ((sc->alc_flags & ALC_FLAG_CMB_BUG) == 0) { 3267 CSR_WRITE_4(sc, ALC_CMB_TD_THRESH, 4); 3268 CSR_WRITE_4(sc, ALC_CMB_TX_TIMER, ALC_USECS(5000)); 3269 } else 3270 CSR_WRITE_4(sc, ALC_CMB_TX_TIMER, ALC_USECS(0)); 4058 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) { 4059 CSR_WRITE_4(sc, ALC_CMB_TD_THRESH, ALC_TX_RING_CNT / 3); 4060 CSR_WRITE_4(sc, ALC_CMB_TX_TIMER, 4061 ALC_USECS(sc->alc_int_tx_mod)); 4062 } else { 4063 if ((sc->alc_flags & ALC_FLAG_CMB_BUG) == 0) { 4064 CSR_WRITE_4(sc, ALC_CMB_TD_THRESH, 4); 4065 CSR_WRITE_4(sc, ALC_CMB_TX_TIMER, ALC_USECS(5000)); 4066 } else 4067 CSR_WRITE_4(sc, ALC_CMB_TX_TIMER, ALC_USECS(0)); 4068 } 3271 4069 /* 3272 4070 * Hardware can be configured to issue SMB interrupt based 3273 4071 * on programmed interval. Since there is a callout that is … … alc_init_locked(struct alc_softc *sc) 3294 4092 */ 3295 4093 CSR_WRITE_4(sc, ALC_FRAME_SIZE, sc->alc_ident->max_framelen); 3296 4094 3297 /* Disable header split(?) */ 3298 CSR_WRITE_4(sc, ALC_HDS_CFG, 0); 3299 3300 /* Configure IPG/IFG parameters. */ 3301 CSR_WRITE_4(sc, ALC_IPG_IFG_CFG, 3302 ((IPG_IFG_IPGT_DEFAULT << IPG_IFG_IPGT_SHIFT) & IPG_IFG_IPGT_MASK) | 3303 ((IPG_IFG_MIFG_DEFAULT << IPG_IFG_MIFG_SHIFT) & IPG_IFG_MIFG_MASK) | 3304 ((IPG_IFG_IPG1_DEFAULT << IPG_IFG_IPG1_SHIFT) & IPG_IFG_IPG1_MASK) | 3305 ((IPG_IFG_IPG2_DEFAULT << IPG_IFG_IPG2_SHIFT) & IPG_IFG_IPG2_MASK)); 3306 /* Set parameters for half-duplex media. */ 3307 CSR_WRITE_4(sc, ALC_HDPX_CFG, 3308 ((HDPX_CFG_LCOL_DEFAULT << HDPX_CFG_LCOL_SHIFT) & 3309 HDPX_CFG_LCOL_MASK) | 3310 ((HDPX_CFG_RETRY_DEFAULT << HDPX_CFG_RETRY_SHIFT) & 3311 HDPX_CFG_RETRY_MASK) | HDPX_CFG_EXC_DEF_EN | 3312 ((HDPX_CFG_ABEBT_DEFAULT << HDPX_CFG_ABEBT_SHIFT) & 3313 HDPX_CFG_ABEBT_MASK) | 3314 ((HDPX_CFG_JAMIPG_DEFAULT << HDPX_CFG_JAMIPG_SHIFT) & 3315 HDPX_CFG_JAMIPG_MASK)); 4095 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) { 4096 /* Disable header split(?) */ 4097 CSR_WRITE_4(sc, ALC_HDS_CFG, 0); 4098 4099 /* Configure IPG/IFG parameters. */ 4100 CSR_WRITE_4(sc, ALC_IPG_IFG_CFG, 4101 ((IPG_IFG_IPGT_DEFAULT << IPG_IFG_IPGT_SHIFT) & 4102 IPG_IFG_IPGT_MASK) | 4103 ((IPG_IFG_MIFG_DEFAULT << IPG_IFG_MIFG_SHIFT) & 4104 IPG_IFG_MIFG_MASK) | 4105 ((IPG_IFG_IPG1_DEFAULT << IPG_IFG_IPG1_SHIFT) & 4106 IPG_IFG_IPG1_MASK) | 4107 ((IPG_IFG_IPG2_DEFAULT << IPG_IFG_IPG2_SHIFT) & 4108 IPG_IFG_IPG2_MASK)); 4109 /* Set parameters for half-duplex media. */ 4110 CSR_WRITE_4(sc, ALC_HDPX_CFG, 4111 ((HDPX_CFG_LCOL_DEFAULT << HDPX_CFG_LCOL_SHIFT) & 4112 HDPX_CFG_LCOL_MASK) | 4113 ((HDPX_CFG_RETRY_DEFAULT << HDPX_CFG_RETRY_SHIFT) & 4114 HDPX_CFG_RETRY_MASK) | HDPX_CFG_EXC_DEF_EN | 4115 ((HDPX_CFG_ABEBT_DEFAULT << HDPX_CFG_ABEBT_SHIFT) & 4116 HDPX_CFG_ABEBT_MASK) | 4117 ((HDPX_CFG_JAMIPG_DEFAULT << HDPX_CFG_JAMIPG_SHIFT) & 4118 HDPX_CFG_JAMIPG_MASK)); 4119 } 4120 3316 4121 /* 3317 4122 * Set TSO/checksum offload threshold. For frames that is 3318 4123 * larger than this threshold, hardware wouldn't do 3319 4124 * TSO/checksum offloading. 3320 4125 */ 3321 CSR_WRITE_4(sc, ALC_TSO_OFFLOAD_THRESH, 3322 (sc->alc_ident->max_framelen >> TSO_OFFLOAD_THRESH_UNIT_SHIFT) & 3323 TSO_OFFLOAD_THRESH_MASK); 4126 reg = (sc->alc_ident->max_framelen >> TSO_OFFLOAD_THRESH_UNIT_SHIFT) & 4127 TSO_OFFLOAD_THRESH_MASK; 4128 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) 4129 reg |= TSO_OFFLOAD_ERRLGPKT_DROP_ENB; 4130 CSR_WRITE_4(sc, ALC_TSO_OFFLOAD_THRESH, reg); 3324 4131 /* Configure TxQ. */ 3325 4132 reg = (alc_dma_burst[sc->alc_dma_rd_burst] << 3326 4133 TXQ_CFG_TX_FIFO_BURST_SHIFT) & TXQ_CFG_TX_FIFO_BURST_MASK; … … alc_init_locked(struct alc_softc *sc) 3329 4136 reg >>= 1; 3330 4137 reg |= (TXQ_CFG_TD_BURST_DEFAULT << TXQ_CFG_TD_BURST_SHIFT) & 3331 4138 TXQ_CFG_TD_BURST_MASK; 4139 reg |= TXQ_CFG_IP_OPTION_ENB | TXQ_CFG_8023_ENB; 3332 4140 CSR_WRITE_4(sc, ALC_TXQ_CFG, reg | TXQ_CFG_ENHANCED_MODE); 3333 3334 /* Configure Rx free descriptor pre-fetching. */ 3335 CSR_WRITE_4(sc, ALC_RX_RD_FREE_THRESH, 3336 ((RX_RD_FREE_THRESH_HI_DEFAULT << RX_RD_FREE_THRESH_HI_SHIFT) & 3337 RX_RD_FREE_THRESH_HI_MASK) | 3338 ((RX_RD_FREE_THRESH_LO_DEFAULT << RX_RD_FREE_THRESH_LO_SHIFT) & 3339 RX_RD_FREE_THRESH_LO_MASK)); 4141 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) { 4142 reg = (TXQ_CFG_TD_BURST_DEFAULT << HQTD_CFG_Q1_BURST_SHIFT | 4143 TXQ_CFG_TD_BURST_DEFAULT << HQTD_CFG_Q2_BURST_SHIFT | 4144 TXQ_CFG_TD_BURST_DEFAULT << HQTD_CFG_Q3_BURST_SHIFT | 4145 HQTD_CFG_BURST_ENB); 4146 CSR_WRITE_4(sc, ALC_HQTD_CFG, reg); 4147 reg = WRR_PRI_RESTRICT_NONE; 4148 reg |= (WRR_PRI_DEFAULT << WRR_PRI0_SHIFT | 4149 WRR_PRI_DEFAULT << WRR_PRI1_SHIFT | 4150 WRR_PRI_DEFAULT << WRR_PRI2_SHIFT | 4151 WRR_PRI_DEFAULT << WRR_PRI3_SHIFT); 4152 CSR_WRITE_4(sc, ALC_WRR, reg); 4153 } else { 4154 /* Configure Rx free descriptor pre-fetching. */ 4155 CSR_WRITE_4(sc, ALC_RX_RD_FREE_THRESH, 4156 ((RX_RD_FREE_THRESH_HI_DEFAULT << 4157 RX_RD_FREE_THRESH_HI_SHIFT) & RX_RD_FREE_THRESH_HI_MASK) | 4158 ((RX_RD_FREE_THRESH_LO_DEFAULT << 4159 RX_RD_FREE_THRESH_LO_SHIFT) & RX_RD_FREE_THRESH_LO_MASK)); 4160 } 3340 4161 3341 4162 /* 3342 4163 * Configure flow control parameters. 3343 4164 * XON : 80% of Rx FIFO 3344 4165 * XOFF : 30% of Rx FIFO 3345 4166 */ 3346 if (sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8131 || 4167 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) { 4168 reg = CSR_READ_4(sc, ALC_SRAM_RX_FIFO_LEN); 4169 reg &= SRAM_RX_FIFO_LEN_MASK; 4170 reg *= 8; 4171 if (reg > 8 * 1024) 4172 reg -= RX_FIFO_PAUSE_816X_RSVD; 4173 else 4174 reg -= RX_BUF_SIZE_MAX; 4175 reg /= 8; 4176 CSR_WRITE_4(sc, ALC_RX_FIFO_PAUSE_THRESH, 4177 ((reg << RX_FIFO_PAUSE_THRESH_LO_SHIFT) & 4178 RX_FIFO_PAUSE_THRESH_LO_MASK) | 4179 (((RX_FIFO_PAUSE_816X_RSVD / 8) << 4180 RX_FIFO_PAUSE_THRESH_HI_SHIFT) & 4181 RX_FIFO_PAUSE_THRESH_HI_MASK)); 4182 } else if (sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8131 || 3347 4183 sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8132) { 3348 4184 reg = CSR_READ_4(sc, ALC_SRAM_RX_FIFO_LEN); 3349 4185 rxf_hi = (reg * 8) / 10; … … alc_init_locked(struct alc_softc *sc) 3355 4191 RX_FIFO_PAUSE_THRESH_HI_MASK)); 3356 4192 } 3357 4193 3358 if (sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8152_B || 3359 sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8151_V2) 3360 CSR_WRITE_4(sc, ALC_SERDES_LOCK, 3361 CSR_READ_4(sc, ALC_SERDES_LOCK) | SERDES_MAC_CLK_SLOWDOWN | 3362 SERDES_PHY_CLK_SLOWDOWN); 3363 3364 /* Disable RSS until I understand L1C/L2C's RSS logic. */ 3365 CSR_WRITE_4(sc, ALC_RSS_IDT_TABLE0, 0); 3366 CSR_WRITE_4(sc, ALC_RSS_CPU, 0); 4194 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) { 4195 /* Disable RSS until I understand L1C/L2C's RSS logic. */ 4196 CSR_WRITE_4(sc, ALC_RSS_IDT_TABLE0, 0); 4197 CSR_WRITE_4(sc, ALC_RSS_CPU, 0); 4198 } 3367 4199 3368 4200 /* Configure RxQ. */ 3369 4201 reg = (RXQ_CFG_RD_BURST_DEFAULT << RXQ_CFG_RD_BURST_SHIFT) & 3370 4202 RXQ_CFG_RD_BURST_MASK; 3371 4203 reg |= RXQ_CFG_RSS_MODE_DIS; 3372 if ((sc->alc_flags & ALC_FLAG_ASPM_MON) != 0) 3373 reg |= RXQ_CFG_ASPM_THROUGHPUT_LIMIT_1M; 4204 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) { 4205 reg |= (RXQ_CFG_816X_IDT_TBL_SIZE_DEFAULT << 4206 RXQ_CFG_816X_IDT_TBL_SIZE_SHIFT) & 4207 RXQ_CFG_816X_IDT_TBL_SIZE_MASK; 4208 if ((sc->alc_flags & ALC_FLAG_FASTETHER) == 0) 4209 reg |= RXQ_CFG_ASPM_THROUGHPUT_LIMIT_100M; 4210 } else { 4211 if ((sc->alc_flags & ALC_FLAG_FASTETHER) == 0 && 4212 sc->alc_ident->deviceid != DEVICEID_ATHEROS_AR8151_V2) 4213 reg |= RXQ_CFG_ASPM_THROUGHPUT_LIMIT_100M; 4214 } 3374 4215 CSR_WRITE_4(sc, ALC_RXQ_CFG, reg); 3375 4216 3376 4217 /* Configure DMA parameters. */ … … alc_init_locked(struct alc_softc *sc) 3390 4231 DMA_CFG_RD_DELAY_CNT_MASK; 3391 4232 reg |= (DMA_CFG_WR_DELAY_CNT_DEFAULT << DMA_CFG_WR_DELAY_CNT_SHIFT) & 3392 4233 DMA_CFG_WR_DELAY_CNT_MASK; 4234 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) { 4235 switch (AR816X_REV(sc->alc_rev)) { 4236 case AR816X_REV_A0: 4237 case AR816X_REV_A1: 4238 reg |= DMA_CFG_RD_CHNL_SEL_2; 4239 break; 4240 case AR816X_REV_B0: 4241 /* FALLTHROUGH */ 4242 default: 4243 reg |= DMA_CFG_RD_CHNL_SEL_4; 4244 break; 4245 } 4246 } 3393 4247 CSR_WRITE_4(sc, ALC_DMA_CFG, reg); 3394 4248 3395 4249 /* … … alc_init_locked(struct alc_softc *sc) 3408 4262 reg = MAC_CFG_TX_CRC_ENB | MAC_CFG_TX_AUTO_PAD | MAC_CFG_FULL_DUPLEX | 3409 4263 ((MAC_CFG_PREAMBLE_DEFAULT << MAC_CFG_PREAMBLE_SHIFT) & 3410 4264 MAC_CFG_PREAMBLE_MASK); 3411 if (sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8151 || 4265 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0 || 4266 sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8151 || 3412 4267 sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8151_V2 || 3413 4268 sc->alc_ident->deviceid == DEVICEID_ATHEROS_AR8152_B2) 3414 4269 reg |= MAC_CFG_HASH_ALG_CRC32 | MAC_CFG_SPEED_MODE_SW; … … alc_init_locked(struct alc_softc *sc) 3427 4282 CSR_WRITE_4(sc, ALC_INTR_STATUS, 0xFFFFFFFF); 3428 4283 CSR_WRITE_4(sc, ALC_INTR_STATUS, 0); 3429 4284 4285 ifp->if_drv_flags |= IFF_DRV_RUNNING; 4286 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 4287 3430 4288 sc->alc_flags &= ~ALC_FLAG_LINK; 3431 4289 /* Switch to the current media. */ 3432 mii_mediachg(mii);4290 alc_mediachange_locked(sc); 3433 4291 3434 4292 callout_reset(&sc->alc_tick_ch, hz, alc_tick, sc); 3435 3436 ifp->if_drv_flags |= IFF_DRV_RUNNING;3437 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;3438 4293 } 3439 4294 3440 4295 static void … … alc_stop(struct alc_softc *sc) 3459 4314 /* Disable interrupts. */ 3460 4315 CSR_WRITE_4(sc, ALC_INTR_MASK, 0); 3461 4316 CSR_WRITE_4(sc, ALC_INTR_STATUS, 0xFFFFFFFF); 3462 alc_stop_queue(sc);3463 4317 /* Disable DMA. */ 3464 4318 reg = CSR_READ_4(sc, ALC_DMA_CFG); 3465 4319 reg &= ~(DMA_CFG_CMB_ENB | DMA_CFG_SMB_ENB); … … alc_stop(struct alc_softc *sc) 3470 4324 alc_stop_mac(sc); 3471 4325 /* Disable interrupts which might be touched in taskq handler. */ 3472 4326 CSR_WRITE_4(sc, ALC_INTR_STATUS, 0xFFFFFFFF); 3473 4327 /* Disable L0s/L1s */ 4328 alc_aspm(sc, 0, IFM_UNKNOWN); 3474 4329 /* Reclaim Rx buffers that have been processed. */ 3475 4330 if (sc->alc_cdata.alc_rxhead != NULL) 3476 4331 m_freem(sc->alc_cdata.alc_rxhead); … … alc_stop_mac(struct alc_softc *sc) 3508 4363 uint32_t reg; 3509 4364 int i; 3510 4365 3511 ALC_LOCK_ASSERT(sc); 3512 4366 alc_stop_queue(sc); 3513 4367 /* Disable Rx/Tx MAC. */ 3514 4368 reg = CSR_READ_4(sc, ALC_MAC_CFG); 3515 4369 if ((reg & (MAC_CFG_TX_ENB | MAC_CFG_RX_ENB)) != 0) { … … alc_stop_mac(struct alc_softc *sc) 3518 4372 } 3519 4373 for (i = ALC_TIMEOUT; i > 0; i--) { 3520 4374 reg = CSR_READ_4(sc, ALC_IDLE_STATUS); 3521 if ( reg== 0)4375 if ((reg & (IDLE_STATUS_RXMAC | IDLE_STATUS_TXMAC)) == 0) 3522 4376 break; 3523 4377 DELAY(10); 3524 4378 } … … alc_start_queue(struct alc_softc *sc) 3543 4397 3544 4398 /* Enable RxQ. */ 3545 4399 cfg = CSR_READ_4(sc, ALC_RXQ_CFG); 3546 cfg &= ~RXQ_CFG_ENB; 3547 cfg |= qcfg[1]; 4400 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) { 4401 cfg &= ~RXQ_CFG_ENB; 4402 cfg |= qcfg[1]; 4403 } else 4404 cfg |= RXQ_CFG_QUEUE0_ENB; 3548 4405 CSR_WRITE_4(sc, ALC_RXQ_CFG, cfg); 3549 4406 /* Enable TxQ. */ 3550 4407 cfg = CSR_READ_4(sc, ALC_TXQ_CFG); … … alc_stop_queue(struct alc_softc *sc) 3558 4415 uint32_t reg; 3559 4416 int i; 3560 4417 3561 ALC_LOCK_ASSERT(sc);3562 3563 4418 /* Disable RxQ. */ 3564 4419 reg = CSR_READ_4(sc, ALC_RXQ_CFG); 3565 if ((reg & RXQ_CFG_ENB) != 0) { 3566 reg &= ~RXQ_CFG_ENB; 3567 CSR_WRITE_4(sc, ALC_RXQ_CFG, reg); 4420 if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) == 0) { 4421 if ((reg & RXQ_CFG_ENB) != 0) { 4422 reg &= ~RXQ_CFG_ENB; 4423 CSR_WRITE_4(sc, ALC_RXQ_CFG, reg); 4424 } 4425 } else { 4426 if ((reg & RXQ_CFG_QUEUE0_ENB) != 0) { 4427 reg &= ~RXQ_CFG_QUEUE0_ENB; 4428 CSR_WRITE_4(sc, ALC_RXQ_CFG, reg); 4429 } 3568 4430 } 3569 4431 /* Disable TxQ. */ 3570 4432 reg = CSR_READ_4(sc, ALC_TXQ_CFG); … … alc_stop_queue(struct alc_softc *sc) 3572 4434 reg &= ~TXQ_CFG_ENB; 3573 4435 CSR_WRITE_4(sc, ALC_TXQ_CFG, reg); 3574 4436 } 4437 DELAY(40); 3575 4438 for (i = ALC_TIMEOUT; i > 0; i--) { 3576 4439 reg = CSR_READ_4(sc, ALC_IDLE_STATUS); 3577 4440 if ((reg & (IDLE_STATUS_RXQ | IDLE_STATUS_TXQ)) == 0) -
src/add-ons/kernel/drivers/network/atheros813x/dev/alc/if_alcreg.h
diff --git a/src/add-ons/kernel/drivers/network/atheros813x/dev/alc/if_alcreg.h b/src/add-ons/kernel/drivers/network/atheros813x/dev/alc/if_alcreg.h index 3011abf..3aaae86 100644
a b 44 44 #define DEVICEID_ATHEROS_AR8151_V2 0x1083 /* L1D V2.0 */ 45 45 #define DEVICEID_ATHEROS_AR8152_B 0x2060 /* L2C V1.1 */ 46 46 #define DEVICEID_ATHEROS_AR8152_B2 0x2062 /* L2C V2.0 */ 47 #define DEVICEID_ATHEROS_AR8161 0x1091 48 #define DEVICEID_ATHEROS_E2200 0xE091 49 #define DEVICEID_ATHEROS_E2400 0xE0A1 50 #define DEVICEID_ATHEROS_E2500 0xE0B1 51 #define DEVICEID_ATHEROS_AR8162 0x1090 52 #define DEVICEID_ATHEROS_AR8171 0x10A1 53 #define DEVICEID_ATHEROS_AR8172 0x10A0 47 54 48 55 #define ATHEROS_AR8152_B_V10 0xC0 49 56 #define ATHEROS_AR8152_B_V11 0xC1 50 57 58 /* 59 * Atheros AR816x/AR817x revisions 60 */ 61 #define AR816X_REV_A0 0 62 #define AR816X_REV_A1 1 63 #define AR816X_REV_B0 2 64 #define AR816X_REV_C0 3 65 66 #define AR816X_REV_SHIFT 3 67 #define AR816X_REV(x) ((x) >> AR816X_REV_SHIFT) 68 51 69 /* 0x0000 - 0x02FF : PCIe configuration space */ 52 70 53 71 #define ALC_PEX_UNC_ERR_SEV 0x10C … … 63 81 #define PEX_UNC_ERR_SEV_ECRC 0x00080000 64 82 #define PEX_UNC_ERR_SEV_UR 0x00100000 65 83 84 #define ALC_EEPROM_LD 0x204 /* AR816x */ 85 #define EEPROM_LD_START 0x00000001 86 #define EEPROM_LD_IDLE 0x00000010 87 #define EEPROM_LD_DONE 0x00000000 88 #define EEPROM_LD_PROGRESS 0x00000020 89 #define EEPROM_LD_EXIST 0x00000100 90 #define EEPROM_LD_EEPROM_EXIST 0x00000200 91 #define EEPROM_LD_FLASH_EXIST 0x00000400 92 #define EEPROM_LD_FLASH_END_ADDR_MASK 0x03FF0000 93 #define EEPROM_LD_FLASH_END_ADDR_SHIFT 16 94 66 95 #define ALC_TWSI_CFG 0x218 67 96 #define TWSI_CFG_SW_LD_START 0x00000800 68 97 #define TWSI_CFG_HW_LD_START 0x00001000 69 98 #define TWSI_CFG_LD_EXIST 0x00400000 70 99 100 #define ALC_SLD 0x218 /* AR816x */ 101 #define SLD_START 0x00000800 102 #define SLD_PROGRESS 0x00001000 103 #define SLD_IDLE 0x00002000 104 #define SLD_SLVADDR_MASK 0x007F0000 105 #define SLD_EXIST 0x00800000 106 #define SLD_FREQ_MASK 0x03000000 107 #define SLD_FREQ_100K 0x00000000 108 #define SLD_FREQ_200K 0x01000000 109 #define SLD_FREQ_300K 0x02000000 110 #define SLD_FREQ_400K 0x03000000 111 71 112 #define ALC_PCIE_PHYMISC 0x1000 72 113 #define PCIE_PHYMISC_FORCE_RCV_DET 0x00000004 73 114 … … 77 118 #define PCIE_PHYMISC2_SERDES_CDR_SHIFT 16 78 119 #define PCIE_PHYMISC2_SERDES_TH_SHIFT 18 79 120 121 #define ALC_PDLL_TRNS1 0x1104 122 #define PDLL_TRNS1_D3PLLOFF_ENB 0x00000800 123 80 124 #define ALC_TWSI_DEBUG 0x1108 81 125 #define TWSI_DEBUG_DEV_EXIST 0x20000000 82 126 … … 103 147 #define PM_CFG_SERDES_PD_EX_L1 0x00000040 104 148 #define PM_CFG_SERDES_BUDS_RX_L1_ENB 0x00000080 105 149 #define PM_CFG_L0S_ENTRY_TIMER_MASK 0x00000F00 150 #define PM_CFG_RX_L1_AFTER_L0S 0x00000800 106 151 #define PM_CFG_ASPM_L0S_ENB 0x00001000 107 152 #define PM_CFG_CLK_SWH_L1 0x00002000 108 153 #define PM_CFG_CLK_PWM_VER1_1 0x00004000 109 154 #define PM_CFG_PCIE_RECV 0x00008000 110 155 #define PM_CFG_L1_ENTRY_TIMER_MASK 0x000F0000 156 #define PM_CFG_L1_ENTRY_TIMER_816X_MASK 0x00070000 157 #define PM_CFG_TX_L1_AFTER_L0S 0x00080000 111 158 #define PM_CFG_PM_REQ_TIMER_MASK 0x00F00000 112 159 #define PM_CFG_LCKDET_TIMER_MASK 0x0F000000 113 160 #define PM_CFG_EN_BUFS_RX_L0S 0x10000000 … … 121 168 122 169 #define PM_CFG_L0S_ENTRY_TIMER_DEFAULT 6 123 170 #define PM_CFG_L1_ENTRY_TIMER_DEFAULT 1 171 #define PM_CFG_L1_ENTRY_TIMER_816X_DEFAULT 4 124 172 #define PM_CFG_LCKDET_TIMER_DEFAULT 12 125 173 #define PM_CFG_PM_REQ_TIMER_DEFAULT 12 174 #define PM_CFG_PM_REQ_TIMER_816X_DEFAULT 15 126 175 127 176 #define ALC_LTSSM_ID_CFG 0x12FC 128 177 #define LTSSM_ID_WRO_ENB 0x00001000 … … 131 180 #define MASTER_RESET 0x00000001 132 181 #define MASTER_TEST_MODE_MASK 0x0000000C 133 182 #define MASTER_BERT_START 0x00000010 183 #define MASTER_WAKEN_25M 0x00000020 134 184 #define MASTER_OOB_DIS_OFF 0x00000040 135 185 #define MASTER_SA_TIMER_ENB 0x00000080 136 186 #define MASTER_MTIMER_ENB 0x00000100 … … 171 221 */ 172 222 #define ALC_IM_TX_TIMER_DEFAULT 1000 /* 1ms */ 173 223 174 #define ALC_GPHY_CFG 0x140C /* 16 bits*/224 #define ALC_GPHY_CFG 0x140C /* 16 bits, 32 bits on AR816x */ 175 225 #define GPHY_CFG_EXT_RESET 0x0001 176 226 #define GPHY_CFG_RTL_MODE 0x0002 177 227 #define GPHY_CFG_LED_MODE 0x0004 … … 188 238 #define GPHY_CFG_PHY_PLL_ON 0x2000 189 239 #define GPHY_CFG_PWDOWN_HW 0x4000 190 240 #define GPHY_CFG_PHY_PLL_BYPASS 0x8000 241 #define GPHY_CFG_100AB_ENB 0x00020000 191 242 192 243 #define ALC_IDLE_STATUS 0x1410 193 244 #define IDLE_STATUS_RXMAC 0x00000001 … … 212 263 #define MDIO_CLK_25_10 0x04000000 213 264 #define MDIO_CLK_25_14 0x05000000 214 265 #define MDIO_CLK_25_20 0x06000000 215 #define MDIO_CLK_25_ 28 0x07000000266 #define MDIO_CLK_25_128 0x07000000 216 267 #define MDIO_OP_BUSY 0x08000000 217 268 #define MDIO_AP_ENB 0x10000000 269 #define MDIO_MODE_EXT 0x40000000 218 270 #define MDIO_DATA_SHIFT 0 219 271 #define MDIO_REG_ADDR_SHIFT 16 220 272 … … 248 300 #define SERDES_MAC_CLK_SLOWDOWN 0x00020000 249 301 #define SERDES_PHY_CLK_SLOWDOWN 0x00040000 250 302 303 #define ALC_LPI_CTL 0x1440 304 #define LPI_CTL_ENB 0x00000001 305 306 #define ALC_EXT_MDIO 0x1448 307 #define EXT_MDIO_REG_MASK 0x0000FFFF 308 #define EXT_MDIO_DEVADDR_MASK 0x001F0000 309 #define EXT_MDIO_REG_SHIFT 0 310 #define EXT_MDIO_DEVADDR_SHIFT 16 311 312 #define EXT_MDIO_REG(x) \ 313 (((x) << EXT_MDIO_REG_SHIFT) & EXT_MDIO_REG_MASK) 314 #define EXT_MDIO_DEVADDR(x) \ 315 (((x) << EXT_MDIO_DEVADDR_SHIFT) & EXT_MDIO_DEVADDR_MASK) 316 317 #define ALC_IDLE_DECISN_TIMER 0x1474 318 #define IDLE_DECISN_TIMER_DEFAULT_1MS 0x400 319 251 320 #define ALC_MAC_CFG 0x1480 252 321 #define MAC_CFG_TX_ENB 0x00000001 253 322 #define MAC_CFG_RX_ENB 0x00000002 … … 278 347 #define MAC_CFG_SINGLE_PAUSE_ENB 0x10000000 279 348 #define MAC_CFG_HASH_ALG_CRC32 0x20000000 280 349 #define MAC_CFG_SPEED_MODE_SW 0x40000000 350 #define MAC_CFG_FAST_PAUSE 0x80000000 281 351 #define MAC_CFG_PREAMBLE_SHIFT 10 282 352 #define MAC_CFG_PREAMBLE_DEFAULT 7 283 353 … … 378 448 379 449 #define ALC_RSS_IDT_TABLE0 0x14E0 380 450 451 #define ALC_TD_PRI2_HEAD_ADDR_LO 0x14E0 /* AR816x */ 452 381 453 #define ALC_RSS_IDT_TABLE1 0x14E4 382 454 455 #define ALC_TD_PRI3_HEAD_ADDR_LO 0x14E4 /* AR816x */ 456 383 457 #define ALC_RSS_IDT_TABLE2 0x14E8 384 458 385 459 #define ALC_RSS_IDT_TABLE3 0x14EC … … 422 496 #define ALC_SRAM_RX_FIFO_ADDR 0x1520 423 497 424 498 #define ALC_SRAM_RX_FIFO_LEN 0x1524 499 #define SRAM_RX_FIFO_LEN_MASK 0x00000FFF 500 #define SRAM_RX_FIFO_LEN_SHIFT 0 425 501 426 502 #define ALC_SRAM_TX_FIFO_ADDR 0x1528 427 503 … … 478 554 479 555 #define ALC_TDH_HEAD_ADDR_LO 0x157C 480 556 557 #define ALC_TD_PRI1_HEAD_ADDR_LO 0x157C /* AR816x */ 558 481 559 #define ALC_TDL_HEAD_ADDR_LO 0x1580 482 560 561 #define ALC_TD_PRI0_HEAD_ADDR_LO 0x1580 /* AR816x */ 562 483 563 #define ALC_TD_RING_CNT 0x1584 484 564 #define TD_RING_CNT_MASK 0x0000FFFF 485 565 #define TD_RING_CNT_SHIFT 0 … … 499 579 500 580 #define ALC_TSO_OFFLOAD_THRESH 0x1594 /* 8 bytes unit */ 501 581 #define TSO_OFFLOAD_THRESH_MASK 0x000007FF 582 #define TSO_OFFLOAD_ERRLGPKT_DROP_ENB 0x00000800 502 583 #define TSO_OFFLOAD_THRESH_SHIFT 0 503 584 #define TSO_OFFLOAD_THRESH_UNIT 8 504 585 #define TSO_OFFLOAD_THRESH_UNIT_SHIFT 3 … … 546 627 (RXQ_CFG_QUEUE0_ENB | RXQ_CFG_QUEUE1_ENB | \ 547 628 RXQ_CFG_QUEUE2_ENB | RXQ_CFG_QUEUE3_ENB) 548 629 630 /* AR816x specific bits */ 631 #define RXQ_CFG_816X_RSS_HASH_IPV4 0x00000004 632 #define RXQ_CFG_816X_RSS_HASH_IPV4_TCP 0x00000008 633 #define RXQ_CFG_816X_RSS_HASH_IPV6 0x00000010 634 #define RXQ_CFG_816X_RSS_HASH_IPV6_TCP 0x00000020 635 #define RXQ_CFG_816X_RSS_HASH_MASK 0x0000003C 636 #define RXQ_CFG_816X_IPV6_PARSE_ENB 0x00000080 637 #define RXQ_CFG_816X_IDT_TBL_SIZE_MASK 0x0001FF00 638 #define RXQ_CFG_816X_IDT_TBL_SIZE_SHIFT 8 639 #define RXQ_CFG_816X_IDT_TBL_SIZE_DEFAULT 0x100 640 549 641 #define ALC_RX_RD_FREE_THRESH 0x15A4 /* 8 bytes unit. */ 550 642 #define RX_RD_FREE_THRESH_HI_MASK 0x0000003F 551 643 #define RX_RD_FREE_THRESH_LO_MASK 0x00000FC0 … … 559 651 #define RX_FIFO_PAUSE_THRESH_HI_MASK 0x0FFF0000 560 652 #define RX_FIFO_PAUSE_THRESH_LO_SHIFT 0 561 653 #define RX_FIFO_PAUSE_THRESH_HI_SHIFT 16 654 /* 655 * Size = tx-packet(1522) + IPG(12) + SOF(8) + 64(Pause) + IPG(12) + SOF(8) + 656 * rx-packet(1522) + delay-of-link(64) 657 * = 3212. 658 */ 659 #define RX_FIFO_PAUSE_816X_RSVD 3212 562 660 563 661 #define ALC_RD_DMA_CFG 0x15AC 564 662 #define RD_DMA_CFG_THRESH_MASK 0x00000FFF /* 8 bytes unit */ … … 582 680 #define DMA_CFG_OUT_ORDER 0x00000004 583 681 #define DMA_CFG_RCB_64 0x00000000 584 682 #define DMA_CFG_RCB_128 0x00000008 683 #define DMA_CFG_PEND_AUTO_RST 0x00000008 585 684 #define DMA_CFG_RD_BURST_128 0x00000000 586 685 #define DMA_CFG_RD_BURST_256 0x00000010 587 686 #define DMA_CFG_RD_BURST_512 0x00000020 … … 601 700 #define DMA_CFG_SMB_ENB 0x00200000 602 701 #define DMA_CFG_CMB_NOW 0x00400000 603 702 #define DMA_CFG_SMB_DIS 0x01000000 703 #define DMA_CFG_RD_CHNL_SEL_MASK 0x0C000000 704 #define DMA_CFG_RD_CHNL_SEL_1 0x00000000 705 #define DMA_CFG_RD_CHNL_SEL_2 0x04000000 706 #define DMA_CFG_RD_CHNL_SEL_3 0x08000000 707 #define DMA_CFG_RD_CHNL_SEL_4 0x0C000000 708 #define DMA_CFG_WSRAM_RDCTL 0x10000000 709 #define DMA_CFG_RD_PEND_CLR 0x20000000 710 #define DMA_CFG_WR_PEND_CLR 0x40000000 604 711 #define DMA_CFG_SMB_NOW 0x80000000 605 712 #define DMA_CFG_RD_BURST_MASK 0x07 606 713 #define DMA_CFG_RD_BURST_SHIFT 4 … … 623 730 #define CMB_TX_TIMER_MASK 0x0000FFFF 624 731 #define CMB_TX_TIMER_SHIFT 0 625 732 733 #define ALC_MSI_MAP_TBL1 0x15D0 734 735 #define ALC_MSI_ID_MAP 0x15D4 736 737 #define ALC_MSI_MAP_TBL2 0x15D8 738 626 739 #define ALC_MBOX_RD0_PROD_IDX 0x15E0 627 740 628 741 #define ALC_MBOX_RD1_PROD_IDX 0x15E4 … … 640 753 #define MBOX_TD_PROD_HI_IDX_SHIFT 0 641 754 #define MBOX_TD_PROD_LO_IDX_SHIFT 16 642 755 756 #define ALC_MBOX_TD_PRI1_PROD_IDX 0x15F0 /* 16 bits AR816x */ 757 758 #define ALC_MBOX_TD_PRI0_PROD_IDX 0x15F2 /* 16 bits AR816x */ 759 643 760 #define ALC_MBOX_TD_CONS_IDX 0x15F4 644 761 #define MBOX_TD_CONS_HI_IDX_MASK 0x0000FFFF 645 762 #define MBOX_TD_CONS_LO_IDX_MASK 0xFFFF0000 646 763 #define MBOX_TD_CONS_HI_IDX_SHIFT 0 647 764 #define MBOX_TD_CONS_LO_IDX_SHIFT 16 648 765 766 #define ALC_MBOX_TD_PRI1_CONS_IDX 0x15F4 /* 16 bits AR816x */ 767 768 #define ALC_MBOX_TD_PRI0_CONS_IDX 0x15F6 /* 16 bits AR816x */ 769 649 770 #define ALC_MBOX_RD01_CONS_IDX 0x15F8 650 771 #define MBOX_RD0_CONS_IDX_MASK 0x0000FFFF 651 772 #define MBOX_RD1_CONS_IDX_MASK 0xFFFF0000 … … 674 795 #define INTR_GPHY 0x00001000 675 796 #define INTR_GPHY_LOW_PW 0x00002000 676 797 #define INTR_TXQ_TO_RST 0x00004000 677 #define INTR_TX_PKT 0x00008000798 #define INTR_TX_PKT0 0x00008000 678 799 #define INTR_RX_PKT0 0x00010000 679 800 #define INTR_RX_PKT1 0x00020000 680 801 #define INTR_RX_PKT2 0x00040000 … … 688 809 #define INTR_PHY_LINK_DOWN 0x04000000 689 810 #define INTR_DIS_INT 0x80000000 690 811 812 /* INTR status for AR816x/AR817x 4 TX queues, 8 RX queues */ 813 #define INTR_TX_PKT1 0x00000020 814 #define INTR_TX_PKT2 0x00000040 815 #define INTR_TX_PKT3 0x00000080 816 #define INTR_RX_PKT4 0x08000000 817 #define INTR_RX_PKT5 0x10000000 818 #define INTR_RX_PKT6 0x20000000 819 #define INTR_RX_PKT7 0x40000000 820 691 821 /* Interrupt Mask Register */ 692 822 #define ALC_INTR_MASK 0x1604 693 823 … … 699 829 (INTR_RD0_UNDERRUN | INTR_RD1_UNDERRUN | \ 700 830 INTR_RD2_UNDERRUN | INTR_RD3_UNDERRUN) 701 831 #else 832 #define INTR_TX_PKT INTR_TX_PKT0 702 833 #define INTR_RX_PKT INTR_RX_PKT0 703 834 #define INTR_RD_UNDERRUN INTR_RD0_UNDERRUN 704 835 #endif … … 720 851 #define HDS_CFG_BACKFILLSIZE_SHIFT 8 721 852 #define HDS_CFG_MAX_HDRSIZE_SHIFT 20 722 853 854 #define ALC_MBOX_TD_PRI3_PROD_IDX 0x1618 /* 16 bits AR816x */ 855 856 #define ALC_MBOX_TD_PRI2_PROD_IDX 0x161A /* 16 bits AR816x */ 857 858 #define ALC_MBOX_TD_PRI3_CONS_IDX 0x161C /* 16 bits AR816x */ 859 860 #define ALC_MBOX_TD_PRI2_CONS_IDX 0x161E /* 16 bits AR816x */ 861 723 862 /* AR813x/AR815x registers for MAC statistics */ 724 863 #define ALC_RX_MIB_BASE 0x1700 725 864 726 865 #define ALC_TX_MIB_BASE 0x1760 727 866 867 #define ALC_DRV 0x1804 /* AR816x */ 868 #define DRV_ASPM_SPD10LMT_1M 0x00000000 869 #define DRV_ASPM_SPD10LMT_10M 0x00000001 870 #define DRV_ASPM_SPD10LMT_100M 0x00000002 871 #define DRV_ASPM_SPD10LMT_NO 0x00000003 872 #define DRV_ASPM_SPD10LMT_MASK 0x00000003 873 #define DRV_ASPM_SPD100LMT_1M 0x00000000 874 #define DRV_ASPM_SPD100LMT_10M 0x00000004 875 #define DRV_ASPM_SPD100LMT_100M 0x00000008 876 #define DRV_ASPM_SPD100LMT_NO 0x0000000C 877 #define DRV_ASPM_SPD100LMT_MASK 0x0000000C 878 #define DRV_ASPM_SPD1000LMT_100M 0x00000000 879 #define DRV_ASPM_SPD1000LMT_NO 0x00000010 880 #define DRV_ASPM_SPD1000LMT_1M 0x00000020 881 #define DRV_ASPM_SPD1000LMT_10M 0x00000030 882 #define DRV_ASPM_SPD1000LMT_MASK 0x00000000 883 #define DRV_WOLCAP_BIOS_EN 0x00000100 884 #define DRV_WOLMAGIC_EN 0x00000200 885 #define DRV_WOLLINKUP_EN 0x00000400 886 #define DRV_WOLPATTERN_EN 0x00000800 887 #define DRV_AZ_EN 0x00001000 888 #define DRV_WOLS5_BIOS_EN 0x00010000 889 #define DRV_WOLS5_EN 0x00020000 890 #define DRV_DISABLE 0x00040000 891 #define DRV_PHY_MASK 0x1FE00000 892 #define DRV_PHY_EEE 0x00200000 893 #define DRV_PHY_APAUSE 0x00400000 894 #define DRV_PHY_PAUSE 0x00800000 895 #define DRV_PHY_DUPLEX 0x01000000 896 #define DRV_PHY_10 0x02000000 897 #define DRV_PHY_100 0x04000000 898 #define DRV_PHY_1000 0x08000000 899 #define DRV_PHY_AUTO 0x10000000 900 #define DRV_PHY_SHIFT 21 901 728 902 #define ALC_CLK_GATING_CFG 0x1814 729 903 #define CLK_GATING_DMAW_ENB 0x0001 730 904 #define CLK_GATING_DMAR_ENB 0x0002 … … 737 911 738 912 #define ALC_DEBUG_DATA1 0x1904 739 913 914 #define ALC_MSI_RETRANS_TIMER 0x1920 915 #define MSI_RETRANS_TIMER_MASK 0x0000FFFF 916 #define MSI_RETRANS_MASK_SEL_STD 0x00000000 917 #define MSI_RETRANS_MASK_SEL_LINE 0x00010000 918 #define MSI_RETRANS_TIMER_SHIFT 0 919 920 #define ALC_WRR 0x1938 921 #define WRR_PRI0_MASK 0x0000001F 922 #define WRR_PRI1_MASK 0x00001F00 923 #define WRR_PRI2_MASK 0x001F0000 924 #define WRR_PRI3_MASK 0x1F000000 925 #define WRR_PRI_RESTRICT_MASK 0x60000000 926 #define WRR_PRI_RESTRICT_ALL 0x00000000 927 #define WRR_PRI_RESTRICT_HI 0x20000000 928 #define WRR_PRI_RESTRICT_HI2 0x40000000 929 #define WRR_PRI_RESTRICT_NONE 0x60000000 930 #define WRR_PRI0_SHIFT 0 931 #define WRR_PRI1_SHIFT 8 932 #define WRR_PRI2_SHIFT 16 933 #define WRR_PRI3_SHIFT 24 934 #define WRR_PRI_DEFAULT 4 935 #define WRR_PRI_RESTRICT_SHIFT 29 936 937 #define ALC_HQTD_CFG 0x193C 938 #define HQTD_CFG_Q1_BURST_MASK 0x0000000F 939 #define HQTD_CFG_Q2_BURST_MASK 0x000000F0 940 #define HQTD_CFG_Q3_BURST_MASK 0x00000F00 941 #define HQTD_CFG_BURST_ENB 0x80000000 942 #define HQTD_CFG_Q1_BURST_SHIFT 0 943 #define HQTD_CFG_Q2_BURST_SHIFT 4 944 #define HQTD_CFG_Q3_BURST_SHIFT 8 945 946 #define ALC_MISC 0x19C0 947 #define MISC_INTNLOSC_OPEN 0x00000008 948 #define MISC_ISO_ENB 0x00001000 949 #define MISC_PSW_OCP_MASK 0x00E00000 950 #define MISC_PSW_OCP_SHIFT 21 951 #define MISC_PSW_OCP_DEFAULT 7 952 953 #define ALC_MISC2 0x19C8 954 #define MISC2_CALB_START 0x00000001 955 956 #define ALC_MISC3 0x19CC 957 #define MISC3_25M_NOTO_INTNL 0x00000001 958 #define MISC3_25M_BY_SW 0x00000002 959 740 960 #define ALC_MII_DBG_ADDR 0x1D 741 961 #define ALC_MII_DBG_DATA 0x1E 742 962 … … 756 976 #define ANA_SEL_CLK125M_DSP 0x8000 757 977 #define ANA_MANUL_SWICH_ON_SHIFT 1 758 978 979 #define MII_DBG_ANACTL 0x00 980 #define DBG_ANACTL_DEFAULT 0x02EF 981 759 982 #define MII_ANA_CFG4 0x04 760 983 #define ANA_IECHO_ADJ_MASK 0x0F 761 984 #define ANA_IECHO_ADJ_3_MASK 0x000F … … 767 990 #define ANA_IECHO_ADJ_1_SHIFT 8 768 991 #define ANA_IECHO_ADJ_0_SHIFT 12 769 992 993 #define MII_DBG_SYSMODCTL 0x04 994 #define DBG_SYSMODCTL_DEFAULT 0xBB8B 995 770 996 #define MII_ANA_CFG5 0x05 771 997 #define ANA_SERDES_CDR_BW_MASK 0x0003 772 998 #define ANA_MS_PAD_DBG 0x0004 … … 783 1009 #define ANA_SERDES_CDR_BW_SHIFT 0 784 1010 #define ANA_SERDES_TH_LOS_SHIFT 4 785 1011 1012 #define MII_DBG_SRDSYSMOD 0x05 1013 #define DBG_SRDSYSMOD_DEFAULT 0x2C46 1014 786 1015 #define MII_ANA_CFG11 0x0B 787 1016 #define ANA_PS_HIB_EN 0x8000 788 1017 1018 #define MII_DBG_HIBNEG 0x0B 1019 #define DBG_HIBNEG_HIB_PULSE 0x1000 1020 #define DBG_HIBNEG_PSHIB_EN 0x8000 1021 #define DBG_HIBNEG_DEFAULT 0xBC40 1022 789 1023 #define MII_ANA_CFG18 0x12 790 1024 #define ANA_TEST_MODE_10BT_01MASK 0x0003 791 1025 #define ANA_LOOP_SEL_10BT 0x0004 … … 800 1034 #define ANA_TRIGGER_SEL_TIMER_SHIFT 12 801 1035 #define ANA_INTERVAL_SEL_TIMER_SHIFT 14 802 1036 1037 #define MII_DBG_TST10BTCFG 0x12 1038 #define DBG_TST10BTCFG_DEFAULT 0x4C04 1039 1040 #define MII_DBG_AZ_ANADECT 0x15 1041 #define DBG_AZ_ANADECT_DEFAULT 0x3220 1042 #define DBG_AZ_ANADECT_LONG 0x3210 1043 1044 #define MII_DBG_MSE16DB 0x18 1045 #define DBG_MSE16DB_UP 0x05EA 1046 #define DBG_MSE16DB_DOWN 0x02EA 1047 1048 #define MII_DBG_MSE20DB 0x1C 1049 #define DBG_MSE20DB_TH_MASK 0x01FC 1050 #define DBG_MSE20DB_TH_DEFAULT 0x2E 1051 #define DBG_MSE20DB_TH_HI 0x54 1052 #define DBG_MSE20DB_TH_SHIFT 2 1053 1054 #define MII_DBG_AGC 0x23 1055 #define DBG_AGC_2_VGA_MASK 0x3F00 1056 #define DBG_AGC_2_VGA_SHIFT 8 1057 #define DBG_AGC_LONG1G_LIMT 40 1058 #define DBG_AGC_LONG100M_LIMT 44 1059 803 1060 #define MII_ANA_CFG41 0x29 804 1061 #define ANA_TOP_PS_EN 0x8000 805 1062 1063 #define MII_DBG_LEGCYPS 0x29 1064 #define DBG_LEGCYPS_ENB 0x8000 1065 #define DBG_LEGCYPS_DEFAULT 0x129D 1066 806 1067 #define MII_ANA_CFG54 0x36 807 1068 #define ANA_LONG_CABLE_TH_100_MASK 0x003F 808 1069 #define ANA_DESERVED 0x0040 … … 813 1074 #define ANA_LONG_CABLE_TH_100_SHIFT 0 814 1075 #define ANA_SHORT_CABLE_TH_100_SHIFT 8 815 1076 1077 #define MII_DBG_TST100BTCFG 0x36 1078 #define DBG_TST100BTCFG_DEFAULT 0xE12C 1079 1080 #define MII_DBG_GREENCFG 0x3B 1081 #define DBG_GREENCFG_DEFAULT 0x7078 1082 1083 #define MII_DBG_GREENCFG2 0x3D 1084 #define DBG_GREENCFG2_GATE_DFSE_EN 0x0080 1085 #define DBG_GREENCFG2_BP_GREEN 0x8000 1086 1087 /* Device addr 3 */ 1088 #define MII_EXT_PCS 3 1089 1090 #define MII_EXT_CLDCTL3 0x8003 1091 #define EXT_CLDCTL3_BP_CABLE1TH_DET_GT 0x8000 1092 1093 #define MII_EXT_CLDCTL5 0x8005 1094 #define EXT_CLDCTL5_BP_VD_HLFBIAS 0x4000 1095 1096 #define MII_EXT_CLDCTL6 0x8006 1097 #define EXT_CLDCTL6_CAB_LEN_MASK 0x00FF 1098 #define EXT_CLDCTL6_CAB_LEN_SHIFT 0 1099 #define EXT_CLDCTL6_CAB_LEN_SHORT1G 116 1100 #define EXT_CLDCTL6_CAB_LEN_SHORT100M 152 1101 1102 #define MII_EXT_VDRVBIAS 0x8062 1103 #define EXT_VDRVBIAS_DEFAULT 3 1104 1105 /* Device addr 7 */ 1106 #define MII_EXT_ANEG 7 1107 1108 #define MII_EXT_ANEG_LOCAL_EEEADV 0x3C 1109 #define ANEG_LOCA_EEEADV_100BT 0x0002 1110 #define ANEG_LOCA_EEEADV_1000BT 0x0004 1111 1112 #define MII_EXT_ANEG_AFE 0x801A 1113 #define ANEG_AFEE_10BT_100M_TH 0x0040 1114 1115 #define MII_EXT_ANEG_S3DIG10 0x8023 1116 #define ANEG_S3DIG10_SL 0x0001 1117 #define ANEG_S3DIG10_DEFAULT 0 1118 1119 #define MII_EXT_ANEG_NLP78 0x8027 1120 #define ANEG_NLP78_120M_DEFAULT 0x8A05 1121 816 1122 /* Statistics counters collected by the MAC. */ 817 1123 struct smb { 818 1124 /* Rx stats. */ … … struct smb { 860 1166 uint32_t tx_multi_colls; 861 1167 uint32_t tx_late_colls; 862 1168 uint32_t tx_excess_colls; 863 uint32_t tx_abort;864 1169 uint32_t tx_underrun; 865 1170 uint32_t tx_desc_underrun; 866 1171 uint32_t tx_lenerrs; -
src/add-ons/kernel/drivers/network/atheros813x/dev/alc/if_alcvar.h
diff --git a/src/add-ons/kernel/drivers/network/atheros813x/dev/alc/if_alcvar.h b/src/add-ons/kernel/drivers/network/atheros813x/dev/alc/if_alcvar.h index f2d806f..a1c3382 100644
a b 52 52 /* Water mark to kick reclaiming Tx buffers. */ 53 53 #define ALC_TX_DESC_HIWAT ((ALC_TX_RING_CNT * 6) / 10) 54 54 55 /* 56 * AR816x controllers support up to 16 messages but this driver 57 * uses single message. 58 */ 55 59 #define ALC_MSI_MESSAGES 1 56 60 #define ALC_MSIX_MESSAGES 1 57 61 … … struct alc_softc { 224 228 #define ALC_FLAG_PM 0x0010 225 229 #define ALC_FLAG_FASTETHER 0x0020 226 230 #define ALC_FLAG_JUMBO 0x0040 227 #define ALC_FLAG_ASPM_MON 0x0080228 231 #define ALC_FLAG_CMB_BUG 0x0100 229 232 #define ALC_FLAG_SMB_BUG 0x0200 230 233 #define ALC_FLAG_L0S 0x0400 231 234 #define ALC_FLAG_L1S 0x0800 232 235 #define ALC_FLAG_APS 0x1000 233 #define ALC_FLAG_LINK 0x8000 236 #define ALC_FLAG_AR816X_FAMILY 0x2000 237 #define ALC_FLAG_LINK_WAR 0x4000 238 #define ALC_FLAG_E2X00 0x8000 239 #define ALC_FLAG_LINK 0x10000 234 240 235 241 struct callout alc_tick_ch; 236 242 struct alc_hw_stats alc_stats; -
src/libs/compat/freebsd_network/compat/net/if.h
diff --git a/src/libs/compat/freebsd_network/compat/net/if.h b/src/libs/compat/freebsd_network/compat/net/if.h index f162a24..e56059c 100644
a b struct if_data { 84 84 u_long ifi_imcasts; /* packets received via multicast */ 85 85 u_long ifi_omcasts; /* packets sent via multicast */ 86 86 u_long ifi_iqdrops; /* dropped on input, this interface */ 87 u_long ifi_oqdrops; /* dropped on output, this interface */ 87 88 u_long ifi_noproto; /* destined for unsupported protocol */ 88 89 u_long ifi_hwassist; /* HW offload capabilities */ 89 90 time_t ifi_epoch; /* uptime at attach or stat reset */ -
src/libs/compat/freebsd_network/compat/net/if_media.h
diff --git a/src/libs/compat/freebsd_network/compat/net/if_media.h b/src/libs/compat/freebsd_network/compat/net/if_media.h index 4561637..a6ce67a 100644
a b uint64_t ifmedia_baudrate(int); 145 145 #define IFM_10G_SR 19 /* 10GBase-SR 850nm Multi-mode */ 146 146 #define IFM_10G_CX4 20 /* 10GBase CX4 copper */ 147 147 #define IFM_2500_SX 21 /* 2500BaseSX - multi-mode fiber */ 148 #define IFM_UNKNOWN 25 /* media types not defined yet */ 149 148 150 149 151 /* note 31 is the max! */ 150 152 … … struct ifmedia_description { 352 354 { IFM_10G_LR, "10Gbase-LR" }, \ 353 355 { IFM_10G_SR, "10Gbase-SR" }, \ 354 356 { IFM_10G_CX4, "10Gbase-CX4" }, \ 357 { IFM_UNKNOWN, "Unknown" }, \ 355 358 { IFM_2500_SX, "2500BaseSX" }, \ 356 359 { 0, NULL }, \ 357 360 } -
src/libs/compat/freebsd_network/compat/net/if_var.h
diff --git a/src/libs/compat/freebsd_network/compat/net/if_var.h b/src/libs/compat/freebsd_network/compat/net/if_var.h index 3fa502e..6a766f5 100644
a b struct route; 89 89 90 90 #include <altq/if_altq.h> 91 91 92 typedef enum { 93 IFCOUNTER_IPACKETS = 0, 94 IFCOUNTER_IERRORS, 95 IFCOUNTER_OPACKETS, 96 IFCOUNTER_OERRORS, 97 IFCOUNTER_COLLISIONS, 98 IFCOUNTER_IBYTES, 99 IFCOUNTER_OBYTES, 100 IFCOUNTER_IMCASTS, 101 IFCOUNTER_OMCASTS, 102 IFCOUNTER_IQDROPS, 103 IFCOUNTER_OQDROPS, 104 IFCOUNTER_NOPROTO, 105 IFCOUNTERS /* Array size. */ 106 } ift_counter; 107 92 108 TAILQ_HEAD(ifnethead, ifnet); /* we use TAILQs so that the order of */ 93 109 TAILQ_HEAD(ifaddrhead, ifaddr); /* instantiation is preserved in the list */ 94 110 TAILQ_HEAD(ifprefixhead, ifprefix); … … typedef void if_init_f_t(void *); 227 243 #define if_imcasts if_data.ifi_imcasts 228 244 #define if_omcasts if_data.ifi_omcasts 229 245 #define if_iqdrops if_data.ifi_iqdrops 246 #define if_oqdrops if_data.ifi_oqdrops 230 247 #define if_noproto if_data.ifi_noproto 231 248 #define if_lastchange if_data.ifi_lastchange 232 249 #define if_recvquota if_data.ifi_recvquota … … typedef void *if_com_alloc_t(u_char type, struct ifnet *ifp); 662 679 typedef void if_com_free_t(void *com, u_char type); 663 680 void if_register_com_alloc(u_char type, if_com_alloc_t *a, if_com_free_t *f); 664 681 void if_deregister_com_alloc(u_char type); 682 void if_inc_counter(struct ifnet *, ift_counter, int64_t); 665 683 666 684 #define IF_LLADDR(ifp) LLADDR(&ifp->if_lladdr) 667 685 -
src/libs/compat/freebsd_network/if.c
diff --git a/src/libs/compat/freebsd_network/if.c b/src/libs/compat/freebsd_network/if.c index fc418c6..f208f79 100644
a b ether_ioctl(struct ifnet *ifp, u_long command, caddr_t data) 715 715 716 716 return 0; 717 717 } 718 719 void 720 if_inc_counter(struct ifnet *ifp, ift_counter cnt, int64_t inc) 721 { 722 switch (cnt) { 723 case IFCOUNTER_IPACKETS: 724 atomic_add(&ifp->if_ipackets, inc); 725 break; 726 case IFCOUNTER_IERRORS: 727 atomic_add(&ifp->if_ierrors, inc); 728 break; 729 case IFCOUNTER_OPACKETS: 730 atomic_add(&ifp->if_opackets, inc); 731 break; 732 case IFCOUNTER_OERRORS: 733 atomic_add(&ifp->if_oerrors, inc); 734 break; 735 case IFCOUNTER_COLLISIONS: 736 atomic_add(&ifp->if_collisions, inc); 737 break; 738 case IFCOUNTER_IBYTES: 739 atomic_add(&ifp->if_ibytes, inc); 740 break; 741 case IFCOUNTER_OBYTES: 742 atomic_add(&ifp->if_obytes, inc); 743 break; 744 case IFCOUNTER_IMCASTS: 745 atomic_add(&ifp->if_imcasts, inc); 746 break; 747 case IFCOUNTER_OMCASTS: 748 atomic_add(&ifp->if_omcasts, inc); 749 break; 750 case IFCOUNTER_IQDROPS: 751 atomic_add(&ifp->if_iqdrops, inc); 752 break; 753 case IFCOUNTER_OQDROPS: 754 atomic_add(&ifp->if_oqdrops, inc); 755 break; 756 case IFCOUNTER_NOPROTO: 757 atomic_add(&ifp->if_noproto, inc); 758 break; 759 case IFCOUNTERS: 760 KASSERT(cnt < IFCOUNTERS, ("%s: invalid cnt %d", __func__, cnt)); 761 } 762 }