if_ae.c (212968) | if_ae.c (213893) |
---|---|
1/*- 2 * Copyright (c) 2008 Stanislav Sedov <stas@FreeBSD.org>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 * Driver for Attansic Technology Corp. L2 FastEthernet adapter. 26 * 27 * This driver is heavily based on age(4) Attansic L1 driver by Pyun YongHyeon. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2008 Stanislav Sedov <stas@FreeBSD.org>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 14 unchanged lines hidden (view full) --- 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 * Driver for Attansic Technology Corp. L2 FastEthernet adapter. 26 * 27 * This driver is heavily based on age(4) Attansic L1 driver by Pyun YongHyeon. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/dev/ae/if_ae.c 212968 2010-09-21 17:25:15Z yongari $"); | 31__FBSDID("$FreeBSD: head/sys/dev/ae/if_ae.c 213893 2010-10-15 14:52:11Z marius $"); |
32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/bus.h> 36#include <sys/endian.h> 37#include <sys/kernel.h> 38#include <sys/malloc.h> 39#include <sys/mbuf.h> --- 315 unchanged lines hidden (view full) --- 355 ae_pcie_init(sc); 356 357 ae_retrieve_address(sc); /* Load MAC address. */ 358 359 error = ae_alloc_rings(sc); /* Allocate ring buffers. */ 360 if (error != 0) 361 goto fail; 362 | 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/bus.h> 36#include <sys/endian.h> 37#include <sys/kernel.h> 38#include <sys/malloc.h> 39#include <sys/mbuf.h> --- 315 unchanged lines hidden (view full) --- 355 ae_pcie_init(sc); 356 357 ae_retrieve_address(sc); /* Load MAC address. */ 358 359 error = ae_alloc_rings(sc); /* Allocate ring buffers. */ 360 if (error != 0) 361 goto fail; 362 |
363 /* Set default PHY address. */ 364 sc->phyaddr = AE_PHYADDR_DEFAULT; 365 | |
366 ifp = sc->ifp = if_alloc(IFT_ETHER); 367 if (ifp == NULL) { 368 device_printf(dev, "could not allocate ifnet structure.\n"); 369 error = ENXIO; 370 goto fail; 371 } 372 373 ifp->if_softc = sc; --- 11 unchanged lines hidden (view full) --- 385 ifp->if_capabilities |= IFCAP_WOL_MAGIC; 386 sc->flags |= AE_FLAG_PMG; 387 } 388 ifp->if_capenable = ifp->if_capabilities; 389 390 /* 391 * Configure and attach MII bus. 392 */ | 363 ifp = sc->ifp = if_alloc(IFT_ETHER); 364 if (ifp == NULL) { 365 device_printf(dev, "could not allocate ifnet structure.\n"); 366 error = ENXIO; 367 goto fail; 368 } 369 370 ifp->if_softc = sc; --- 11 unchanged lines hidden (view full) --- 382 ifp->if_capabilities |= IFCAP_WOL_MAGIC; 383 sc->flags |= AE_FLAG_PMG; 384 } 385 ifp->if_capenable = ifp->if_capabilities; 386 387 /* 388 * Configure and attach MII bus. 389 */ |
393 error = mii_phy_probe(dev, &sc->miibus, ae_mediachange, 394 ae_mediastatus); | 390 error = mii_attach(dev, &sc->miibus, ifp, ae_mediachange, 391 ae_mediastatus, BMSR_DEFCAPMASK, AE_PHYADDR_DEFAULT, 392 MII_OFFSET_ANY, 0); |
395 if (error != 0) { | 393 if (error != 0) { |
396 device_printf(dev, "no PHY found.\n"); | 394 device_printf(dev, "attaching PHYs failed\n"); |
397 goto fail; 398 } 399 400 ether_ifattach(ifp, sc->eaddr); 401 /* Tell the upper layer(s) we support long frames. */ 402 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); 403 404 /* --- 403 unchanged lines hidden (view full) --- 808 809 sc = device_get_softc(dev); 810 KASSERT(sc != NULL, ("[ae, %d]: sc is NULL", __LINE__)); 811 812 /* 813 * Locking is done in upper layers. 814 */ 815 | 395 goto fail; 396 } 397 398 ether_ifattach(ifp, sc->eaddr); 399 /* Tell the upper layer(s) we support long frames. */ 400 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); 401 402 /* --- 403 unchanged lines hidden (view full) --- 806 807 sc = device_get_softc(dev); 808 KASSERT(sc != NULL, ("[ae, %d]: sc is NULL", __LINE__)); 809 810 /* 811 * Locking is done in upper layers. 812 */ 813 |
816 if (phy != sc->phyaddr) 817 return (0); 818 | |
819 val = ((reg << AE_MDIO_REGADDR_SHIFT) & AE_MDIO_REGADDR_MASK) | 820 AE_MDIO_START | AE_MDIO_READ | AE_MDIO_SUP_PREAMBLE | 821 ((AE_MDIO_CLK_25_4 << AE_MDIO_CLK_SHIFT) & AE_MDIO_CLK_MASK); 822 AE_WRITE_4(sc, AE_MDIO_REG, val); 823 824 /* 825 * Wait for operation to complete. 826 */ --- 19 unchanged lines hidden (view full) --- 846 847 sc = device_get_softc(dev); 848 KASSERT(sc != NULL, ("[ae, %d]: sc is NULL", __LINE__)); 849 850 /* 851 * Locking is done in upper layers. 852 */ 853 | 814 val = ((reg << AE_MDIO_REGADDR_SHIFT) & AE_MDIO_REGADDR_MASK) | 815 AE_MDIO_START | AE_MDIO_READ | AE_MDIO_SUP_PREAMBLE | 816 ((AE_MDIO_CLK_25_4 << AE_MDIO_CLK_SHIFT) & AE_MDIO_CLK_MASK); 817 AE_WRITE_4(sc, AE_MDIO_REG, val); 818 819 /* 820 * Wait for operation to complete. 821 */ --- 19 unchanged lines hidden (view full) --- 841 842 sc = device_get_softc(dev); 843 KASSERT(sc != NULL, ("[ae, %d]: sc is NULL", __LINE__)); 844 845 /* 846 * Locking is done in upper layers. 847 */ 848 |
854 if (phy != sc->phyaddr) 855 return (0); 856 | |
857 aereg = ((reg << AE_MDIO_REGADDR_SHIFT) & AE_MDIO_REGADDR_MASK) | 858 AE_MDIO_START | AE_MDIO_SUP_PREAMBLE | 859 ((AE_MDIO_CLK_25_4 << AE_MDIO_CLK_SHIFT) & AE_MDIO_CLK_MASK) | 860 ((val << AE_MDIO_DATA_SHIFT) & AE_MDIO_DATA_MASK); 861 AE_WRITE_4(sc, AE_MDIO_REG, aereg); 862 863 /* 864 * Wait for operation to complete. --- 1403 unchanged lines hidden --- | 849 aereg = ((reg << AE_MDIO_REGADDR_SHIFT) & AE_MDIO_REGADDR_MASK) | 850 AE_MDIO_START | AE_MDIO_SUP_PREAMBLE | 851 ((AE_MDIO_CLK_25_4 << AE_MDIO_CLK_SHIFT) & AE_MDIO_CLK_MASK) | 852 ((val << AE_MDIO_DATA_SHIFT) & AE_MDIO_DATA_MASK); 853 AE_WRITE_4(sc, AE_MDIO_REG, aereg); 854 855 /* 856 * Wait for operation to complete. --- 1403 unchanged lines hidden --- |