Deleted Added
full compact
if_sk.c (209865) if_sk.c (213893)
1/* $OpenBSD: if_sk.c,v 2.33 2003/08/12 05:23:06 nate Exp $ */
2
3/*-
4 * Copyright (c) 1997, 1998, 1999, 2000
5 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 34 unchanged lines hidden (view full) ---

43 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
44 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
45 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
46 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
47 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
48 */
49
50#include <sys/cdefs.h>
1/* $OpenBSD: if_sk.c,v 2.33 2003/08/12 05:23:06 nate Exp $ */
2
3/*-
4 * Copyright (c) 1997, 1998, 1999, 2000
5 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 34 unchanged lines hidden (view full) ---

43 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
44 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
45 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
46 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
47 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
48 */
49
50#include <sys/cdefs.h>
51__FBSDID("$FreeBSD: head/sys/dev/sk/if_sk.c 209865 2010-07-09 21:21:08Z yongari $");
51__FBSDID("$FreeBSD: head/sys/dev/sk/if_sk.c 213893 2010-10-15 14:52:11Z marius $");
52
53/*
54 * SysKonnect SK-NET gigabit ethernet driver for FreeBSD. Supports
55 * the SK-984x series adapters, both single port and dual port.
56 * References:
57 * The XaQti XMAC II datasheet,
58 * http://www.freebsd.org/~wpaul/SysKonnect/xmacii_datasheet_rev_c_9-29.pdf
59 * The SysKonnect GEnesis manual, http://www.syskonnect.com

--- 75 unchanged lines hidden (view full) ---

135MODULE_DEPEND(sk, ether, 1, 1, 1);
136MODULE_DEPEND(sk, miibus, 1, 1, 1);
137
138/* "device miibus" required. See GENERIC if you get errors here. */
139#include "miibus_if.h"
140
141#ifndef lint
142static const char rcsid[] =
52
53/*
54 * SysKonnect SK-NET gigabit ethernet driver for FreeBSD. Supports
55 * the SK-984x series adapters, both single port and dual port.
56 * References:
57 * The XaQti XMAC II datasheet,
58 * http://www.freebsd.org/~wpaul/SysKonnect/xmacii_datasheet_rev_c_9-29.pdf
59 * The SysKonnect GEnesis manual, http://www.syskonnect.com

--- 75 unchanged lines hidden (view full) ---

135MODULE_DEPEND(sk, ether, 1, 1, 1);
136MODULE_DEPEND(sk, miibus, 1, 1, 1);
137
138/* "device miibus" required. See GENERIC if you get errors here. */
139#include "miibus_if.h"
140
141#ifndef lint
142static const char rcsid[] =
143 "$FreeBSD: head/sys/dev/sk/if_sk.c 209865 2010-07-09 21:21:08Z yongari $";
143 "$FreeBSD: head/sys/dev/sk/if_sk.c 213893 2010-10-15 14:52:11Z marius $";
144#endif
145
146static struct sk_type sk_devs[] = {
147 {
148 VENDORID_SK,
149 DEVICEID_SK_V1,
150 "SysKonnect Gigabit Ethernet (V1.0)"
151 },

--- 388 unchanged lines hidden (view full) ---

540
541static int
542sk_xmac_miibus_readreg(sc_if, phy, reg)
543 struct sk_if_softc *sc_if;
544 int phy, reg;
545{
546 int i;
547
144#endif
145
146static struct sk_type sk_devs[] = {
147 {
148 VENDORID_SK,
149 DEVICEID_SK_V1,
150 "SysKonnect Gigabit Ethernet (V1.0)"
151 },

--- 388 unchanged lines hidden (view full) ---

540
541static int
542sk_xmac_miibus_readreg(sc_if, phy, reg)
543 struct sk_if_softc *sc_if;
544 int phy, reg;
545{
546 int i;
547
548 if (sc_if->sk_phytype == SK_PHYTYPE_XMAC && phy != 0)
549 return(0);
550
551 SK_XM_WRITE_2(sc_if, XM_PHY_ADDR, reg|(phy << 8));
552 SK_XM_READ_2(sc_if, XM_PHY_DATA);
553 if (sc_if->sk_phytype != SK_PHYTYPE_XMAC) {
554 for (i = 0; i < SK_TIMEOUT; i++) {
555 DELAY(1);
556 if (SK_XM_READ_2(sc_if, XM_MMUCMD) &
557 XM_MMUCMD_PHYDATARDY)
558 break;

--- 64 unchanged lines hidden (view full) ---

623static int
624sk_marv_miibus_readreg(sc_if, phy, reg)
625 struct sk_if_softc *sc_if;
626 int phy, reg;
627{
628 u_int16_t val;
629 int i;
630
548 SK_XM_WRITE_2(sc_if, XM_PHY_ADDR, reg|(phy << 8));
549 SK_XM_READ_2(sc_if, XM_PHY_DATA);
550 if (sc_if->sk_phytype != SK_PHYTYPE_XMAC) {
551 for (i = 0; i < SK_TIMEOUT; i++) {
552 DELAY(1);
553 if (SK_XM_READ_2(sc_if, XM_MMUCMD) &
554 XM_MMUCMD_PHYDATARDY)
555 break;

--- 64 unchanged lines hidden (view full) ---

620static int
621sk_marv_miibus_readreg(sc_if, phy, reg)
622 struct sk_if_softc *sc_if;
623 int phy, reg;
624{
625 u_int16_t val;
626 int i;
627
631 if (phy != 0 ||
632 (sc_if->sk_phytype != SK_PHYTYPE_MARV_COPPER &&
633 sc_if->sk_phytype != SK_PHYTYPE_MARV_FIBER)) {
628 if (sc_if->sk_phytype != SK_PHYTYPE_MARV_COPPER &&
629 sc_if->sk_phytype != SK_PHYTYPE_MARV_FIBER) {
634 return(0);
635 }
636
637 SK_YU_WRITE_2(sc_if, YUKON_SMICR, YU_SMICR_PHYAD(phy) |
638 YU_SMICR_REGAD(reg) | YU_SMICR_OP_READ);
639
640 for (i = 0; i < SK_TIMEOUT; i++) {
641 DELAY(1);

--- 676 unchanged lines hidden (view full) ---

1318 */
1319static int
1320sk_attach(dev)
1321 device_t dev;
1322{
1323 struct sk_softc *sc;
1324 struct sk_if_softc *sc_if;
1325 struct ifnet *ifp;
630 return(0);
631 }
632
633 SK_YU_WRITE_2(sc_if, YUKON_SMICR, YU_SMICR_PHYAD(phy) |
634 YU_SMICR_REGAD(reg) | YU_SMICR_OP_READ);
635
636 for (i = 0; i < SK_TIMEOUT; i++) {
637 DELAY(1);

--- 676 unchanged lines hidden (view full) ---

1314 */
1315static int
1316sk_attach(dev)
1317 device_t dev;
1318{
1319 struct sk_softc *sc;
1320 struct sk_if_softc *sc_if;
1321 struct ifnet *ifp;
1326 int i, port, error;
1322 int error, i, phy, port;
1327 u_char eaddr[6];
1328
1329 if (dev == NULL)
1330 return(EINVAL);
1331
1332 error = 0;
1333 sc_if = device_get_softc(dev);
1334 sc = device_get_softc(device_get_parent(dev));

--- 156 unchanged lines hidden (view full) ---

1491 * Must appear after the call to ether_ifattach() because
1492 * ether_ifattach() sets ifi_hdrlen to the default value.
1493 */
1494 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
1495
1496 /*
1497 * Do miibus setup.
1498 */
1323 u_char eaddr[6];
1324
1325 if (dev == NULL)
1326 return(EINVAL);
1327
1328 error = 0;
1329 sc_if = device_get_softc(dev);
1330 sc = device_get_softc(device_get_parent(dev));

--- 156 unchanged lines hidden (view full) ---

1487 * Must appear after the call to ether_ifattach() because
1488 * ether_ifattach() sets ifi_hdrlen to the default value.
1489 */
1490 ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
1491
1492 /*
1493 * Do miibus setup.
1494 */
1495 phy = MII_PHY_ANY;
1499 switch (sc->sk_type) {
1500 case SK_GENESIS:
1501 sk_init_xmac(sc_if);
1496 switch (sc->sk_type) {
1497 case SK_GENESIS:
1498 sk_init_xmac(sc_if);
1499 if (sc_if->sk_phytype == SK_PHYTYPE_XMAC)
1500 phy = 0;
1502 break;
1503 case SK_YUKON:
1504 case SK_YUKON_LITE:
1505 case SK_YUKON_LP:
1506 sk_init_yukon(sc_if);
1501 break;
1502 case SK_YUKON:
1503 case SK_YUKON_LITE:
1504 case SK_YUKON_LP:
1505 sk_init_yukon(sc_if);
1506 phy = 0;
1507 break;
1508 }
1509
1510 SK_IF_UNLOCK(sc_if);
1507 break;
1508 }
1509
1510 SK_IF_UNLOCK(sc_if);
1511 if (mii_phy_probe(dev, &sc_if->sk_miibus,
1512 sk_ifmedia_upd, sk_ifmedia_sts)) {
1513 device_printf(sc_if->sk_if_dev, "no PHY found!\n");
1511 error = mii_attach(dev, &sc_if->sk_miibus, ifp, sk_ifmedia_upd,
1512 sk_ifmedia_sts, BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0);
1513 if (error != 0) {
1514 device_printf(sc_if->sk_if_dev, "attaching PHYs failed\n");
1514 ether_ifdetach(ifp);
1515 ether_ifdetach(ifp);
1515 error = ENXIO;
1516 goto fail;
1517 }
1518
1519fail:
1520 if (error) {
1521 /* Access should be ok even though lock has been dropped */
1522 sc->sk_if[port] = NULL;
1523 sk_detach(dev);

--- 2307 unchanged lines hidden ---
1516 goto fail;
1517 }
1518
1519fail:
1520 if (error) {
1521 /* Access should be ok even though lock has been dropped */
1522 sc->sk_if[port] = NULL;
1523 sk_detach(dev);

--- 2307 unchanged lines hidden ---