Lines Matching full:skge
3 * Ethernet adapters. Derived from Linux skge driver (v1.13), which was
43 #include "skge.h"
66 static void genesis_link_up(struct skge_port *skge);
135 static void skge_led(struct skge_port *skge, enum led_mode mode)
137 struct skge_hw *hw = skge->hw;
138 int port = skge->port;
197 (skge->speed == SPEED_100 ?
218 * struct skge_port *skge = netdev_priv(dev);
221 * pci_read_config_dword(skge->hw->pdev, PCI_DEV_REG2, ®2);
253 * struct skge_port *skge = netdev_priv(dev);
254 * struct pci_dev *pdev = skge->hw->pdev;
279 * struct skge_port *skge = netdev_priv(dev);
280 * struct pci_dev *pdev = skge->hw->pdev;
340 static void skge_rx_setup(struct skge_port *skge __unused,
380 static void skge_rx_clean(struct skge_port *skge)
382 struct skge_ring *ring = &skge->rx_ring;
396 static void skge_link_up(struct skge_port *skge)
398 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG),
401 netdev_link_up(skge->netdev);
404 skge->netdev->name, skge->speed,
405 skge->duplex == DUPLEX_FULL ? "full" : "half");
408 static void skge_link_down(struct skge_port *skge)
410 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF);
411 netdev_link_down(skge->netdev);
413 DBG2(PFX "%s: Link is down.\n", skge->netdev->name);
420 struct skge_port *skge = netdev_priv(dev);
425 skge_link_down(skge);
558 struct skge_port *skge = netdev_priv(dev);
570 if (skge->autoneg == AUTONEG_ENABLE) {
588 skge->duplex = DUPLEX_FULL;
591 skge->duplex = DUPLEX_HALF;
602 skge->flow_status = FLOW_STAT_SYMMETRIC;
605 skge->flow_status = FLOW_STAT_REM_SEND;
608 skge->flow_status = FLOW_STAT_LOC_SEND;
611 skge->flow_status = FLOW_STAT_NONE;
613 skge->speed = SPEED_1000;
617 genesis_link_up(skge);
623 static void bcom_phy_init(struct skge_port *skge)
625 struct skge_hw *hw = skge->hw;
626 int port = skge->port;
688 if (skge->autoneg == AUTONEG_ENABLE) {
695 if (skge->advertising & ADVERTISED_1000baseT_Half)
697 if (skge->advertising & ADVERTISED_1000baseT_Full)
703 if (skge->duplex == DUPLEX_FULL)
711 phy_pause_map[skge->flow_control] | PHY_AN_CSMA);
720 static void xm_phy_init(struct skge_port *skge)
722 struct skge_hw *hw = skge->hw;
723 int port = skge->port;
726 if (skge->autoneg == AUTONEG_ENABLE) {
727 if (skge->advertising & ADVERTISED_1000baseT_Half)
729 if (skge->advertising & ADVERTISED_1000baseT_Full)
732 ctrl |= fiber_pause_map[skge->flow_control];
740 if (skge->duplex == DUPLEX_FULL)
751 skge->use_xm_link_timer = 1;
756 struct skge_port *skge = netdev_priv(dev);
757 struct skge_hw *hw = skge->hw;
758 int port = skge->port;
770 if (skge->autoneg == AUTONEG_ENABLE) {
788 skge->duplex = DUPLEX_FULL;
791 skge->duplex = DUPLEX_HALF;
800 if ((skge->flow_control == FLOW_MODE_SYMMETRIC ||
801 skge->flow_control == FLOW_MODE_SYM_OR_REM) &&
803 skge->flow_status = FLOW_STAT_SYMMETRIC;
804 else if (skge->flow_control == FLOW_MODE_SYM_OR_REM &&
807 skge->flow_status = FLOW_STAT_REM_SEND;
808 else if (skge->flow_control == FLOW_MODE_LOC_SEND &&
811 skge->flow_status = FLOW_STAT_LOC_SEND;
813 skge->flow_status = FLOW_STAT_NONE;
815 skge->speed = SPEED_1000;
819 genesis_link_up(skge);
829 static void xm_link_timer(struct skge_port *skge)
831 struct net_device *dev = skge->netdev;
832 struct skge_hw *hw = skge->hw;
833 int port = skge->port;
857 struct skge_port *skge = netdev_priv(dev);
898 xm_phy_init(skge);
901 bcom_phy_init(skge);
925 if (skge->duplex == DUPLEX_HALF) {
1000 static void genesis_stop(struct skge_port *skge)
1002 struct skge_hw *hw = skge->hw;
1003 int port = skge->port;
1047 static void genesis_link_up(struct skge_port *skge)
1049 struct skge_hw *hw = skge->hw;
1050 int port = skge->port;
1060 if (skge->flow_status == FLOW_STAT_NONE ||
1061 skge->flow_status == FLOW_STAT_LOC_SEND)
1071 if (skge->flow_status== FLOW_STAT_SYMMETRIC ||
1072 skge->flow_status == FLOW_STAT_LOC_SEND) {
1110 if (hw->phy_type != SK_PHY_XMAC && skge->duplex == DUPLEX_FULL)
1127 skge_link_up(skge);
1131 static inline void bcom_phy_intr(struct skge_port *skge)
1133 struct skge_hw *hw = skge->hw;
1134 int port = skge->port;
1139 skge->netdev->name, isrc);
1214 struct skge_port *skge = netdev_priv(hw->dev[port]);
1217 if (skge->autoneg == AUTONEG_ENABLE) {
1230 if (skge->autoneg == AUTONEG_DISABLE)
1240 if (skge->autoneg == AUTONEG_ENABLE) {
1242 if (skge->advertising & ADVERTISED_1000baseT_Full)
1244 if (skge->advertising & ADVERTISED_1000baseT_Half)
1246 if (skge->advertising & ADVERTISED_100baseT_Full)
1248 if (skge->advertising & ADVERTISED_100baseT_Half)
1250 if (skge->advertising & ADVERTISED_10baseT_Full)
1252 if (skge->advertising & ADVERTISED_10baseT_Half)
1256 adv |= phy_pause_map[skge->flow_control];
1258 if (skge->advertising & ADVERTISED_1000baseT_Full)
1260 if (skge->advertising & ADVERTISED_1000baseT_Half)
1263 adv |= fiber_pause_map[skge->flow_control];
1272 if (skge->duplex == DUPLEX_FULL)
1275 switch (skge->speed) {
1293 if (skge->autoneg == AUTONEG_ENABLE)
1330 struct skge_port *skge = netdev_priv(hw->dev[port]);
1366 if (skge->autoneg == AUTONEG_DISABLE) {
1371 switch (skge->speed) {
1385 if (skge->duplex == DUPLEX_FULL)
1390 switch (skge->flow_control) {
1494 static void yukon_stop(struct skge_port *skge)
1496 struct skge_hw *hw = skge->hw;
1497 int port = skge->port;
1526 static void yukon_link_up(struct skge_port *skge)
1528 struct skge_hw *hw = skge->hw;
1529 int port = skge->port;
1536 if (skge->duplex == DUPLEX_FULL || skge->autoneg == AUTONEG_ENABLE)
1544 skge_link_up(skge);
1547 static void yukon_link_down(struct skge_port *skge)
1549 struct skge_hw *hw = skge->hw;
1550 int port = skge->port;
1557 if (skge->flow_status == FLOW_STAT_REM_SEND) {
1564 skge_link_down(skge);
1569 static void yukon_phy_intr(struct skge_port *skge)
1571 struct skge_hw *hw = skge->hw;
1572 int port = skge->port;
1580 skge->netdev->name, istatus, phystat);
1599 skge->duplex = (phystat & PHY_M_PS_FULL_DUP)
1601 skge->speed = yukon_speed(hw, phystat);
1606 skge->flow_status = FLOW_STAT_SYMMETRIC;
1609 skge->flow_status = FLOW_STAT_REM_SEND;
1612 skge->flow_status = FLOW_STAT_LOC_SEND;
1615 skge->flow_status = FLOW_STAT_NONE;
1618 if (skge->flow_status == FLOW_STAT_NONE ||
1619 (skge->speed < SPEED_1000 && skge->duplex == DUPLEX_HALF))
1623 yukon_link_up(skge);
1628 skge->speed = yukon_speed(hw, phystat);
1631 skge->duplex = (phystat & PHY_M_PS_FULL_DUP) ? DUPLEX_FULL : DUPLEX_HALF;
1634 yukon_link_up(skge);
1636 yukon_link_down(skge);
1641 skge->netdev->name, reason);
1677 static void skge_qset(struct skge_port *skge, u16 q,
1680 struct skge_hw *hw = skge->hw;
1682 u64 base = skge->dma + (e->desc - skge->mem);
1696 struct skge_port *skge = netdev_priv(dev);
1698 free(skge->rx_ring.start);
1699 skge->rx_ring.start = NULL;
1701 free(skge->tx_ring.start);
1702 skge->tx_ring.start = NULL;
1704 free_dma(skge->mem, RING_SIZE);
1705 skge->mem = NULL;
1706 skge->dma = 0;
1711 struct skge_port *skge = netdev_priv(dev);
1712 struct skge_hw *hw = skge->hw;
1713 int port = skge->port;
1719 skge->mem = malloc_dma(RING_SIZE, SKGE_RING_ALIGN);
1720 skge->dma = virt_to_bus(skge->mem);
1721 if (!skge->mem)
1723 memset(skge->mem, 0, RING_SIZE);
1725 assert(!(skge->dma & 7));
1728 if ((u64)skge->dma >> 32 != ((u64) skge->dma + RING_SIZE) >> 32) {
1734 err = skge_ring_alloc(&skge->rx_ring, skge->mem, skge->dma, NUM_RX_DESC);
1739 * This is assured by calling memset() on skge->mem and using zalloc()
1744 err = skge_ring_alloc(&skge->tx_ring, skge->mem + RX_RING_SIZE,
1745 skge->dma + RX_RING_SIZE, NUM_TX_DESC);
1760 skge_qset(skge, rxqaddr[port], skge->rx_ring.to_clean);
1762 assert(!(skge->tx_ring.to_use != skge->tx_ring.to_clean));
1764 skge_qset(skge, txqaddr[port], skge->tx_ring.to_use);
1769 skge_led(skge, LED_MODE_ON);
1777 skge_rx_clean(skge);
1794 struct skge_port *skge = netdev_priv(dev);
1795 struct skge_hw *hw = skge->hw;
1796 int port = skge->port;
1798 if (skge->mem == NULL)
1804 skge->use_xm_link_timer = 0;
1811 skge_write8(skge->hw, SK_REG(skge->port, LNK_LED_REG), LED_OFF);
1813 genesis_stop(skge);
1815 yukon_stop(skge);
1848 skge_led(skge, LED_MODE_OFF);
1852 skge_rx_clean(skge);
1867 struct skge_port *skge = netdev_priv(dev);
1868 struct skge_hw *hw = skge->hw;
1874 if (skge_tx_avail(&skge->tx_ring) < 1)
1877 e = skge->tx_ring.to_use;
1895 skge_write8(hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_START);
1898 dev->name, e - skge->tx_ring.start, (unsigned int)len);
1900 skge->tx_ring.to_use = e->next;
1903 if (skge_tx_avail(&skge->tx_ring) <= 1) {
1913 struct skge_port *skge = netdev_priv(dev);
1916 for (e = skge->tx_ring.to_clean; e != skge->tx_ring.to_use; e = e->next) {
1921 skge->tx_ring.to_clean = e;
1946 struct skge_port *skge = netdev_priv(dev);
1947 struct skge_ring *ring = &skge->tx_ring;
1950 skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
1960 skge->tx_ring.to_clean = e;
1968 struct skge_port *skge = netdev_priv(dev);
1969 struct skge_ring *ring = &skge->rx_ring;
1990 skge_rx_setup(skge, e, iob, RX_BUF_SIZE);
2001 skge_rx_setup(skge, e, NULL, 0);
2010 struct skge_port *skge = netdev_priv(dev);
2011 struct skge_ring *ring = &skge->rx_ring;
2036 if ((bad_phy_status(skge->hw, rd->status)) ||
2037 (phy_length(skge->hw, rd->status) != len)) {
2057 struct skge_port *skge = netdev_priv(dev);
2058 struct skge_hw *hw = skge->hw;
2067 if (skge->use_xm_link_timer)
2068 xm_link_timer(skge);
2073 skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
2079 skge_write8(hw, Q_ADDR(rxqaddr[skge->port], Q_CSR), CSR_START);
2092 struct skge_port *skge = netdev_priv(dev);
2095 yukon_phy_intr(skge);
2097 bcom_phy_intr(skge);
2299 struct skge_port *skge;
2300 struct net_device *dev = alloc_etherdev(sizeof(*skge));
2309 skge = netdev_priv(dev);
2310 skge->netdev = dev;
2311 skge->hw = hw;
2314 skge->autoneg = AUTONEG_ENABLE;
2315 skge->flow_control = FLOW_MODE_SYM_OR_REM;
2316 skge->duplex = -1;
2317 skge->speed = -1;
2318 skge->advertising = skge_supported_modes(hw);
2322 skge->port = port;
2456 struct skge_port *skge = netdev_priv(dev);
2457 struct skge_hw *hw = skge->hw;
2460 hw->intr_mask |= portmask[skge->port];
2462 hw->intr_mask &= ~portmask[skge->port];