X-Git-Url: http://bbs.cooldavid.org/git/?p=jme.git;a=blobdiff_plain;f=jme.c;h=c5f92023afa456322cf1042eca14af0e0270d0e1;hp=b0b1ee3255b4b78156880b03c1bfbbabc18fc24e;hb=8e14c278ad90df8fdeb4c0e8b95e3ae3c3835d83;hpb=619f07cea61ca6558de86f0b112165f37430f7b6 diff --git a/jme.c b/jme.c index b0b1ee3..c5f9202 100644 --- a/jme.c +++ b/jme.c @@ -21,7 +21,6 @@ * */ -#include #include #include #include @@ -38,6 +37,8 @@ #include #include #include +#include +#include #include "jme.h" static int force_pseudohp = -1; @@ -190,7 +191,7 @@ jme_reset_mac_processor(struct jme_adapter *jme) else gpreg0 = GPREG0_DEFAULT; jwrite32(jme, JME_GPREG0, gpreg0); - jwrite32(jme, JME_GPREG1, 0); + jwrite32(jme, JME_GPREG1, GPREG1_DEFAULT); } static inline void @@ -288,7 +289,11 @@ jme_set_rx_pcc(struct jme_adapter *jme, int p) wmb(); if (!(test_bit(JME_FLAG_POLL, &jme->flags))) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_rx_status(jme, "Switched to PCC_P%d\n", p); +#else + netif_info(jme, rx_status, jme->dev, "Switched to PCC_P%d\n", p); +#endif } static void @@ -322,20 +327,6 @@ jme_stop_irq(struct jme_adapter *jme) jwrite32f(jme, JME_IENC, INTR_ENABLE); } -static inline void -jme_enable_shadow(struct jme_adapter *jme) -{ - jwrite32(jme, - JME_SHBA_LO, - ((u32)jme->shadow_dma & ~((u32)0x1F)) | SHBA_POSTEN); -} - -static inline void -jme_disable_shadow(struct jme_adapter *jme) -{ - jwrite32(jme, JME_SHBA_LO, 0x0); -} - static u32 jme_linkstat_from_phy(struct jme_adapter *jme) { @@ -350,13 +341,13 @@ jme_linkstat_from_phy(struct jme_adapter *jme) } static inline void -jme_set_gmii(struct jme_adapter *jme) +jme_set_phyfifoa(struct jme_adapter *jme) { jme_mdio_write(jme->dev, jme->mii_if.phy_id, 27, 0x0004); } static inline void -jme_set_rgmii(struct jme_adapter *jme) +jme_set_phyfifob(struct jme_adapter *jme) { jme_mdio_write(jme->dev, jme->mii_if.phy_id, 27, 0x0000); } @@ -365,7 +356,7 @@ static int jme_check_link(struct net_device *netdev, int testonly) { struct jme_adapter *jme = netdev_priv(netdev); - u32 phylink, ghc, cnt = JME_SPDRSV_TIMEOUT, bmcr; + u32 phylink, ghc, cnt = JME_SPDRSV_TIMEOUT, bmcr, gpreg1; char linkmsg[64]; int rc = 0; @@ -429,45 +420,32 @@ jme_check_link(struct net_device *netdev, int testonly) jme->phylink = phylink; - ghc = jme->reg_ghc & ~(GHC_SPEED_10M | - GHC_SPEED_100M | - GHC_SPEED_1000M | - GHC_DPX); + ghc = jme->reg_ghc & ~(GHC_SPEED | GHC_DPX | + GHC_TO_CLK_PCIE | GHC_TXMAC_CLK_PCIE | + GHC_TO_CLK_GPHY | GHC_TXMAC_CLK_GPHY); switch (phylink & PHY_LINK_SPEED_MASK) { case PHY_LINK_SPEED_10M: - ghc |= GHC_SPEED_10M; + ghc |= GHC_SPEED_10M | + GHC_TO_CLK_PCIE | GHC_TXMAC_CLK_PCIE; strcat(linkmsg, "10 Mbps, "); - if (jme->rev == 0x11) - jme_set_gmii(jme); break; case PHY_LINK_SPEED_100M: - ghc |= GHC_SPEED_100M; + ghc |= GHC_SPEED_100M | + GHC_TO_CLK_PCIE | GHC_TXMAC_CLK_PCIE; strcat(linkmsg, "100 Mbps, "); - if (jme->rev == 0x11) - jme_set_rgmii(jme); break; case PHY_LINK_SPEED_1000M: - ghc |= GHC_SPEED_1000M; + ghc |= GHC_SPEED_1000M | + GHC_TO_CLK_GPHY | GHC_TXMAC_CLK_GPHY; strcat(linkmsg, "1000 Mbps, "); - if (jme->rev == 0x11) - jme_set_gmii(jme); break; default: break; } - ghc |= (phylink & PHY_LINK_DUPLEX) ? GHC_DPX : 0; - - strcat(linkmsg, (phylink & PHY_LINK_DUPLEX) ? - "Full-Duplex, " : - "Half-Duplex, "); - - if (phylink & PHY_LINK_MDI_STAT) - strcat(linkmsg, "MDI-X"); - else - strcat(linkmsg, "MDI"); if (phylink & PHY_LINK_DUPLEX) { jwrite32(jme, JME_TXMCS, TXMCS_DEFAULT); + ghc |= GHC_DPX; } else { jwrite32(jme, JME_TXMCS, TXMCS_DEFAULT | TXMCS_BACKOFF | @@ -479,16 +457,52 @@ jme_check_link(struct net_device *netdev, int testonly) ((8 << TXTRHD_TXRL_SHIFT) & TXTRHD_TXRL)); } - jme->reg_ghc = ghc; + gpreg1 = GPREG1_DEFAULT; + if (is_buggy250(jme->pdev->device, jme->chiprev)) { + if (!(phylink & PHY_LINK_DUPLEX)) + gpreg1 |= GPREG1_HALFMODEPATCH; + switch (phylink & PHY_LINK_SPEED_MASK) { + case PHY_LINK_SPEED_10M: + jme_set_phyfifoa(jme); + gpreg1 |= GPREG1_RSSPATCH; + break; + case PHY_LINK_SPEED_100M: + jme_set_phyfifob(jme); + gpreg1 |= GPREG1_RSSPATCH; + break; + case PHY_LINK_SPEED_1000M: + jme_set_phyfifoa(jme); + break; + default: + break; + } + } + + jwrite32(jme, JME_GPREG1, gpreg1); jwrite32(jme, JME_GHC, ghc); + jme->reg_ghc = ghc; + strcat(linkmsg, (phylink & PHY_LINK_DUPLEX) ? + "Full-Duplex, " : + "Half-Duplex, "); + strcat(linkmsg, (phylink & PHY_LINK_MDI_STAT) ? + "MDI-X" : + "MDI"); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_link(jme, "Link is up at %s.\n", linkmsg); +#else + netif_info(jme, link, jme->dev, "Link is up at %s.\n", linkmsg); +#endif netif_carrier_on(netdev); } else { if (testonly) goto out; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_link(jme, "Link is down.\n"); +#else + netif_info(jme, link, jme->dev, "Link is down.\n"); +#endif jme->phylink = 0; netif_carrier_off(netdev); } @@ -507,12 +521,8 @@ jme_setup_tx_resources(struct jme_adapter *jme) &(txring->dmaalloc), GFP_ATOMIC); - if (!txring->alloc) { - txring->desc = NULL; - txring->dmaalloc = 0; - txring->dma = 0; - return -ENOMEM; - } + if (!txring->alloc) + goto err_set_null; /* * 16 Bytes align @@ -524,6 +534,11 @@ jme_setup_tx_resources(struct jme_adapter *jme) atomic_set(&txring->next_to_clean, 0); atomic_set(&txring->nr_free, jme->tx_ring_size); + txring->bufinf = kmalloc(sizeof(struct jme_buffer_info) * + jme->tx_ring_size, GFP_ATOMIC); + if (unlikely(!(txring->bufinf))) + goto err_free_txring; + /* * Initialize Transmit Descriptors */ @@ -532,6 +547,20 @@ jme_setup_tx_resources(struct jme_adapter *jme) sizeof(struct jme_buffer_info) * jme->tx_ring_size); return 0; + +err_free_txring: + dma_free_coherent(&(jme->pdev->dev), + TX_RING_ALLOC_SIZE(jme->tx_ring_size), + txring->alloc, + txring->dmaalloc); + +err_set_null: + txring->desc = NULL; + txring->dmaalloc = 0; + txring->dma = 0; + txring->bufinf = NULL; + + return -ENOMEM; } static void @@ -539,19 +568,22 @@ jme_free_tx_resources(struct jme_adapter *jme) { int i; struct jme_ring *txring = &(jme->txring[0]); - struct jme_buffer_info *txbi = txring->bufinf; + struct jme_buffer_info *txbi; if (txring->alloc) { - for (i = 0 ; i < jme->tx_ring_size ; ++i) { - txbi = txring->bufinf + i; - if (txbi->skb) { - dev_kfree_skb(txbi->skb); - txbi->skb = NULL; + if (txring->bufinf) { + for (i = 0 ; i < jme->tx_ring_size ; ++i) { + txbi = txring->bufinf + i; + if (txbi->skb) { + dev_kfree_skb(txbi->skb); + txbi->skb = NULL; + } + txbi->mapping = 0; + txbi->len = 0; + txbi->nr_desc = 0; + txbi->start_xmit = 0; } - txbi->mapping = 0; - txbi->len = 0; - txbi->nr_desc = 0; - txbi->start_xmit = 0; + kfree(txring->bufinf); } dma_free_coherent(&(jme->pdev->dev), @@ -563,11 +595,11 @@ jme_free_tx_resources(struct jme_adapter *jme) txring->desc = NULL; txring->dmaalloc = 0; txring->dma = 0; + txring->bufinf = NULL; } txring->next_to_use = 0; atomic_set(&txring->next_to_clean, 0); atomic_set(&txring->nr_free, 0); - } static inline void @@ -638,7 +670,7 @@ jme_disable_tx_engine(struct jme_adapter *jme) static void jme_set_clean_rxdesc(struct jme_adapter *jme, int i) { - struct jme_ring *rxring = jme->rxring; + struct jme_ring *rxring = &(jme->rxring[0]); register struct rxdesc *rxdesc = rxring->desc; struct jme_buffer_info *rxbi = rxring->bufinf; rxdesc += i; @@ -667,6 +699,9 @@ jme_make_new_rx_buf(struct jme_adapter *jme, int i) jme->dev->mtu + RX_EXTRA_LEN); if (unlikely(!skb)) return -ENOMEM; +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) + skb->dev = jme->dev; +#endif rxbi->skb = skb; rxbi->len = skb_tailroom(skb); @@ -705,8 +740,11 @@ jme_free_rx_resources(struct jme_adapter *jme) struct jme_ring *rxring = &(jme->rxring[0]); if (rxring->alloc) { - for (i = 0 ; i < jme->rx_ring_size ; ++i) - jme_free_rx_buf(jme, i); + if (rxring->bufinf) { + for (i = 0 ; i < jme->rx_ring_size ; ++i) + jme_free_rx_buf(jme, i); + kfree(rxring->bufinf); + } dma_free_coherent(&(jme->pdev->dev), RX_RING_ALLOC_SIZE(jme->rx_ring_size), @@ -716,6 +754,7 @@ jme_free_rx_resources(struct jme_adapter *jme) rxring->desc = NULL; rxring->dmaalloc = 0; rxring->dma = 0; + rxring->bufinf = NULL; } rxring->next_to_use = 0; atomic_set(&rxring->next_to_clean, 0); @@ -731,12 +770,8 @@ jme_setup_rx_resources(struct jme_adapter *jme) RX_RING_ALLOC_SIZE(jme->rx_ring_size), &(rxring->dmaalloc), GFP_ATOMIC); - if (!rxring->alloc) { - rxring->desc = NULL; - rxring->dmaalloc = 0; - rxring->dma = 0; - return -ENOMEM; - } + if (!rxring->alloc) + goto err_set_null; /* * 16 Bytes align @@ -747,9 +782,16 @@ jme_setup_rx_resources(struct jme_adapter *jme) rxring->next_to_use = 0; atomic_set(&rxring->next_to_clean, 0); + rxring->bufinf = kmalloc(sizeof(struct jme_buffer_info) * + jme->rx_ring_size, GFP_ATOMIC); + if (unlikely(!(rxring->bufinf))) + goto err_free_rxring; + /* * Initiallize Receive Descriptors */ + memset(rxring->bufinf, 0, + sizeof(struct jme_buffer_info) * jme->rx_ring_size); for (i = 0 ; i < jme->rx_ring_size ; ++i) { if (unlikely(jme_make_new_rx_buf(jme, i))) { jme_free_rx_resources(jme); @@ -760,6 +802,19 @@ jme_setup_rx_resources(struct jme_adapter *jme) } return 0; + +err_free_rxring: + dma_free_coherent(&(jme->pdev->dev), + RX_RING_ALLOC_SIZE(jme->rx_ring_size), + rxring->alloc, + rxring->dmaalloc); +err_set_null: + rxring->desc = NULL; + rxring->dmaalloc = 0; + rxring->dma = 0; + rxring->bufinf = NULL; + + return -ENOMEM; } static inline void @@ -775,9 +830,9 @@ jme_enable_rx_engine(struct jme_adapter *jme) /* * Setup RX DMA Bass Address */ - jwrite32(jme, JME_RXDBA_LO, (__u64)jme->rxring[0].dma & 0xFFFFFFFFUL); + jwrite32(jme, JME_RXDBA_LO, (__u64)(jme->rxring[0].dma) & 0xFFFFFFFFUL); jwrite32(jme, JME_RXDBA_HI, (__u64)(jme->rxring[0].dma) >> 32); - jwrite32(jme, JME_RXNDA, (__u64)jme->rxring[0].dma & 0xFFFFFFFFUL); + jwrite32(jme, JME_RXNDA, (__u64)(jme->rxring[0].dma) & 0xFFFFFFFFUL); /* * Setup RX Descriptor Count @@ -841,27 +896,39 @@ jme_rxsum_ok(struct jme_adapter *jme, u16 flags) if (!(flags & (RXWBFLAG_TCPON | RXWBFLAG_UDPON | RXWBFLAG_IPV4))) return false; - if (unlikely(!(flags & RXWBFLAG_MF) && - (flags & RXWBFLAG_TCPON) && !(flags & RXWBFLAG_TCPCS))) { - msg_rx_err(jme, "TCP Checksum error.\n"); - goto out_sumerr; + if (unlikely((flags & (RXWBFLAG_MF | RXWBFLAG_TCPON | RXWBFLAG_TCPCS)) + == RXWBFLAG_TCPON)) { + if (flags & RXWBFLAG_IPV4) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) + msg_rx_err(jme, "TCP Checksum error\n"); +#else + netif_err(jme, rx_err, jme->dev, "TCP Checksum error\n"); +#endif + return false; } - if (unlikely(!(flags & RXWBFLAG_MF) && - (flags & RXWBFLAG_UDPON) && !(flags & RXWBFLAG_UDPCS))) { - msg_rx_err(jme, "UDP Checksum error.\n"); - goto out_sumerr; + if (unlikely((flags & (RXWBFLAG_MF | RXWBFLAG_UDPON | RXWBFLAG_UDPCS)) + == RXWBFLAG_UDPON)) { + if (flags & RXWBFLAG_IPV4) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) + msg_rx_err(jme, "UDP Checksum error.\n"); +#else + netif_err(jme, rx_err, jme->dev, "UDP Checksum error.\n"); +#endif + return false; } - if (unlikely((flags & RXWBFLAG_IPV4) && !(flags & RXWBFLAG_IPCS))) { + if (unlikely((flags & (RXWBFLAG_IPV4 | RXWBFLAG_IPCS)) + == RXWBFLAG_IPV4)) { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_rx_err(jme, "IPv4 Checksum error.\n"); - goto out_sumerr; +#else + netif_err(jme, rx_err, jme->dev, "IPv4 Checksum error.\n"); +#endif + return false; } return true; - -out_sumerr: - return false; } static void @@ -897,26 +964,27 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx) skb_put(skb, framesize); skb->protocol = eth_type_trans(skb, jme->dev); - if (jme_rxsum_ok(jme, rxdesc->descwb.flags)) + if (jme_rxsum_ok(jme, le16_to_cpu(rxdesc->descwb.flags))) skb->ip_summed = CHECKSUM_UNNECESSARY; else skb->ip_summed = CHECKSUM_NONE; - if (rxdesc->descwb.flags & RXWBFLAG_TAGON) { + if (rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_TAGON)) { if (jme->vlgrp) { jme->jme_vlan_rx(skb, jme->vlgrp, - le32_to_cpu(rxdesc->descwb.vlan)); + le16_to_cpu(rxdesc->descwb.vlan)); NET_STAT(jme).rx_bytes += 4; + } else { + dev_kfree_skb(skb); } } else { jme->jme_rx(skb); } - if ((le16_to_cpu(rxdesc->descwb.flags) & RXWBFLAG_DEST) == - RXWBFLAG_DEST_MUL) + if ((rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_DEST)) == + cpu_to_le16(RXWBFLAG_DEST_MUL)) ++(NET_STAT(jme).multicast); - jme->dev->last_rx = jiffies; NET_STAT(jme).rx_bytes += framesize; ++(NET_STAT(jme).rx_packets); } @@ -942,13 +1010,14 @@ jme_process_receive(struct jme_adapter *jme, int limit) goto out_inc; i = atomic_read(&rxring->next_to_clean); - while (limit-- > 0) { + while (limit > 0) { rxdesc = rxring->desc; rxdesc += i; - if ((rxdesc->descwb.flags & RXWBFLAG_OWN) || + if ((rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_OWN)) || !(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL)) goto out; + --limit; desccnt = rxdesc->descwb.desccnt & RXWBDCNT_DCNT; @@ -1011,8 +1080,8 @@ jme_dynamic_pcc(struct jme_adapter *jme) if ((NET_STAT(jme).rx_bytes - dpi->last_bytes) > PCC_P3_THRESHOLD) jme_attempt_pcc(dpi, PCC_P3); - else if ((NET_STAT(jme).rx_packets - dpi->last_pkts) > PCC_P2_THRESHOLD - || dpi->intr_cnt > PCC_INTR_THRESHOLD) + else if ((NET_STAT(jme).rx_packets - dpi->last_pkts) > PCC_P2_THRESHOLD || + dpi->intr_cnt > PCC_INTR_THRESHOLD) jme_attempt_pcc(dpi, PCC_P2); else jme_attempt_pcc(dpi, PCC_P1); @@ -1147,9 +1216,17 @@ jme_link_change_tasklet(unsigned long arg) while (!atomic_dec_and_test(&jme->link_changing)) { atomic_inc(&jme->link_changing); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_intr(jme, "Get link change lock failed.\n"); - while(atomic_read(&jme->link_changing) != 1) +#else + netif_info(jme, intr, jme->dev, "Get link change lock failed.\n"); +#endif + while (atomic_read(&jme->link_changing) != 1) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_intr(jme, "Waiting link change lock.\n"); +#else + netif_info(jme, intr, jme->dev, "Waiting link change lock.\n"); +#endif } if (jme_check_link(netdev, 1) && jme->old_mtu == netdev->mtu) @@ -1235,7 +1312,7 @@ static int jme_poll(JME_NAPI_HOLDER(holder), JME_NAPI_WEIGHT(budget)) { struct jme_adapter *jme = jme_napi_priv(holder); - struct net_device *netdev = jme->dev; + DECLARE_NETDEV int rest; rest = jme_process_receive(jme, JME_NAPI_WEIGHT_VAL(budget)); @@ -1267,7 +1344,11 @@ jme_rx_empty_tasklet(unsigned long arg) if (unlikely(!netif_carrier_ok(jme->dev))) return; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_rx_status(jme, "RX Queue Full!\n"); +#else + netif_info(jme, rx_status, jme->dev, "RX Queue Full!\n"); +#endif jme_rx_clean_tasklet(arg); @@ -1282,12 +1363,16 @@ jme_rx_empty_tasklet(unsigned long arg) static void jme_wake_queue_if_stopped(struct jme_adapter *jme) { - struct jme_ring *txring = jme->txring; + struct jme_ring *txring = &(jme->txring[0]); smp_wmb(); if (unlikely(netif_queue_stopped(jme->dev) && atomic_read(&txring->nr_free) >= (jme->tx_wake_threshold))) { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_tx_done(jme, "TX Queue Waked.\n"); +#else + netif_info(jme, tx_done, jme->dev, "TX Queue Waked.\n"); +#endif netif_wake_queue(jme->dev); } @@ -1436,8 +1521,13 @@ out_reenable: jwrite32f(jme, JME_IENS, INTR_ENABLE); } +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18) +static irqreturn_t +jme_intr(int irq, void *dev_id, struct pt_regs *regs) +#else static irqreturn_t jme_intr(int irq, void *dev_id) +#endif { struct net_device *netdev = dev_id; struct jme_adapter *jme = netdev_priv(netdev); @@ -1448,7 +1538,7 @@ jme_intr(int irq, void *dev_id) /* * Check if it's really an interrupt for us */ - if (unlikely(intrstat == 0)) + if (unlikely((intrstat & INTR_ENABLE) == 0)) return IRQ_NONE; /* @@ -1462,19 +1552,19 @@ jme_intr(int irq, void *dev_id) return IRQ_HANDLED; } +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18) +static irqreturn_t +jme_msi(int irq, void *dev_id, struct pt_regs *regs) +#else static irqreturn_t jme_msi(int irq, void *dev_id) +#endif { struct net_device *netdev = dev_id; struct jme_adapter *jme = netdev_priv(netdev); u32 intrstat; - pci_dma_sync_single_for_cpu(jme->pdev, - jme->shadow_dma, - sizeof(u32) * SHADOW_REG_NR, - PCI_DMA_FROMDEVICE); - intrstat = jme->shadow_regs[SHADOW_IEVE]; - jme->shadow_regs[SHADOW_IEVE] = 0; + intrstat = jread32(jme, JME_IEVE); jme_intr_msi(jme, intrstat); @@ -1504,8 +1594,13 @@ jme_request_irq(struct jme_adapter *jme) { int rc; struct net_device *netdev = jme->dev; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18) + irqreturn_t (*handler)(int, void *, struct pt_regs *) = jme_intr; + int irq_flags = SA_SHIRQ; +#else irq_handler_t handler = jme_intr; int irq_flags = IRQF_SHARED; +#endif if (!pci_enable_msi(jme->pdev)) { set_bit(JME_FLAG_MSI, &jme->flags); @@ -1552,6 +1647,7 @@ jme_open(struct net_device *netdev) jme_clear_pm(jme); JME_NAPI_ENABLE(jme); + tasklet_enable(&jme->linkch_task); tasklet_enable(&jme->txclean_task); tasklet_hi_enable(&jme->rxclean_task); tasklet_hi_enable(&jme->rxempty_task); @@ -1560,7 +1656,6 @@ jme_open(struct net_device *netdev) if (rc) goto err_out; - jme_enable_shadow(jme); jme_start_irq(jme); if (test_bit(JME_FLAG_SSET, &jme->flags)) @@ -1578,6 +1673,7 @@ err_out: return rc; } +#ifdef CONFIG_PM static void jme_set_100m_half(struct jme_adapter *jme) { @@ -1610,6 +1706,7 @@ jme_wait_link(struct jme_adapter *jme) phylink = jme_linkstat_from_phy(jme); } } +#endif static inline void jme_phy_off(struct jme_adapter *jme) @@ -1626,15 +1723,14 @@ jme_close(struct net_device *netdev) netif_carrier_off(netdev); jme_stop_irq(jme); - jme_disable_shadow(jme); jme_free_irq(jme); JME_NAPI_DISABLE(jme); - tasklet_kill(&jme->linkch_task); - tasklet_kill(&jme->txclean_task); - tasklet_kill(&jme->rxclean_task); - tasklet_kill(&jme->rxempty_task); + tasklet_disable(&jme->linkch_task); + tasklet_disable(&jme->txclean_task); + tasklet_disable(&jme->rxclean_task); + tasklet_disable(&jme->rxempty_task); jme_reset_ghc_speed(jme); jme_disable_rx_engine(jme); @@ -1652,7 +1748,7 @@ static int jme_alloc_txdesc(struct jme_adapter *jme, struct sk_buff *skb) { - struct jme_ring *txring = jme->txring; + struct jme_ring *txring = &(jme->txring[0]); int idx, nr_alloc, mask = jme->tx_ring_mask; idx = txring->next_to_use; @@ -1706,7 +1802,7 @@ jme_fill_tx_map(struct pci_dev *pdev, static void jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx) { - struct jme_ring *txring = jme->txring; + struct jme_ring *txring = &(jme->txring[0]); struct txdesc *txdesc = txring->desc, *ctxdesc; struct jme_buffer_info *txbi = txring->bufinf, *ctxbi; u8 hidma = jme->dev->features & NETIF_F_HIGHDMA; @@ -1735,8 +1831,13 @@ jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx) static int jme_expand_header(struct jme_adapter *jme, struct sk_buff *skb) { - if (unlikely(skb_shinfo(skb)->gso_size && - skb_header_cloned(skb) && + if (unlikely( +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,17) + skb_shinfo(skb)->tso_size +#else + skb_shinfo(skb)->gso_size +#endif + && skb_header_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) { dev_kfree_skb(skb); return -1; @@ -1746,10 +1847,13 @@ jme_expand_header(struct jme_adapter *jme, struct sk_buff *skb) } static int -jme_tx_tso(struct sk_buff *skb, - u16 *mss, u8 *flags) +jme_tx_tso(struct sk_buff *skb, __le16 *mss, u8 *flags) { - *mss = skb_shinfo(skb)->gso_size << TXDESC_MSS_SHIFT; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,17) + *mss = cpu_to_le16(skb_shinfo(skb)->tso_size << TXDESC_MSS_SHIFT); +#else + *mss = cpu_to_le16(skb_shinfo(skb)->gso_size << TXDESC_MSS_SHIFT); +#endif if (*mss) { *flags |= TXFLAG_LSEN; @@ -1779,9 +1883,22 @@ jme_tx_tso(struct sk_buff *skb, static void jme_tx_csum(struct jme_adapter *jme, struct sk_buff *skb, u8 *flags) { - if (skb->ip_summed == CHECKSUM_PARTIAL) { +#ifdef CHECKSUM_PARTIAL + if (skb->ip_summed == CHECKSUM_PARTIAL) +#else + if (skb->ip_summed == CHECKSUM_HW) +#endif + { u8 ip_proto; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21) + if (skb->protocol == htons(ETH_P_IP)) + ip_proto = ip_hdr(skb)->protocol; + else if (skb->protocol == htons(ETH_P_IPV6)) + ip_proto = ipv6_hdr(skb)->nexthdr; + else + ip_proto = 0; +#else switch (skb->protocol) { case htons(ETH_P_IP): ip_proto = ip_hdr(skb)->protocol; @@ -1793,6 +1910,7 @@ jme_tx_csum(struct jme_adapter *jme, struct sk_buff *skb, u8 *flags) ip_proto = 0; break; } +#endif switch (ip_proto) { case IPPROTO_TCP: @@ -1802,25 +1920,29 @@ jme_tx_csum(struct jme_adapter *jme, struct sk_buff *skb, u8 *flags) *flags |= TXFLAG_UDPCS; break; default: +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_tx_err(jme, "Error upper layer protocol.\n"); +#else + netif_err(jme, tx_err, jme->dev, "Error upper layer protocol.\n"); +#endif break; } } } static inline void -jme_tx_vlan(struct sk_buff *skb, u16 *vlan, u8 *flags) +jme_tx_vlan(struct sk_buff *skb, __le16 *vlan, u8 *flags) { if (vlan_tx_tag_present(skb)) { *flags |= TXFLAG_TAGON; - *vlan = vlan_tx_tag_get(skb); + *vlan = cpu_to_le16(vlan_tx_tag_get(skb)); } } static int -jme_fill_first_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx) +jme_fill_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx) { - struct jme_ring *txring = jme->txring; + struct jme_ring *txring = &(jme->txring[0]); struct txdesc *txdesc; struct jme_buffer_info *txbi; u8 flags; @@ -1848,6 +1970,7 @@ jme_fill_first_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx) if (jme_tx_tso(skb, &txdesc->desc1.mss, &flags)) jme_tx_csum(jme, skb, &flags); jme_tx_vlan(skb, &txdesc->desc1.vlan, &flags); + jme_map_tx_skb(jme, skb, idx); txdesc->desc1.flags = flags; /* * Set tx buffer info after telling NIC to send @@ -1867,7 +1990,7 @@ jme_fill_first_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx) static void jme_stop_queue_if_full(struct jme_adapter *jme) { - struct jme_ring *txring = jme->txring; + struct jme_ring *txring = &(jme->txring[0]); struct jme_buffer_info *txbi = txring->bufinf; int idx = atomic_read(&txring->next_to_clean); @@ -1876,12 +1999,20 @@ jme_stop_queue_if_full(struct jme_adapter *jme) smp_wmb(); if (unlikely(atomic_read(&txring->nr_free) < (MAX_SKB_FRAGS+2))) { netif_stop_queue(jme->dev); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_tx_queued(jme, "TX Queue Paused.\n"); +#else + netif_info(jme, tx_queued, jme->dev, "TX Queue Paused.\n"); +#endif smp_wmb(); if (atomic_read(&txring->nr_free) >= (jme->tx_wake_threshold)) { netif_wake_queue(jme->dev); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_tx_queued(jme, "TX Queue Fast Waked.\n"); +#else + netif_info(jme, tx_queued, jme->dev, "TX Queue Fast Waked.\n"); +#endif } } @@ -1889,7 +2020,11 @@ jme_stop_queue_if_full(struct jme_adapter *jme) (jiffies - txbi->start_xmit) >= TX_TIMEOUT && txbi->skb)) { netif_stop_queue(jme->dev); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_tx_queued(jme, "TX Queue Stopped %d@%lu.\n", idx, jiffies); +#else + netif_info(jme, tx_queued, jme->dev, "TX Queue Stopped %d@%lu.\n", idx, jiffies); +#endif } } @@ -1897,7 +2032,11 @@ jme_stop_queue_if_full(struct jme_adapter *jme) * This function is already protected by netif_tx_lock() */ +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,31) static int +#else +static netdev_tx_t +#endif jme_start_xmit(struct sk_buff *skb, struct net_device *netdev) { struct jme_adapter *jme = netdev_priv(netdev); @@ -1912,19 +2051,24 @@ jme_start_xmit(struct sk_buff *skb, struct net_device *netdev) if (unlikely(idx < 0)) { netif_stop_queue(netdev); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_tx_err(jme, "BUG! Tx ring full when queue awake!\n"); +#else + netif_err(jme, tx_err, jme->dev, "BUG! Tx ring full when queue awake!\n"); +#endif return NETDEV_TX_BUSY; } - jme_map_tx_skb(jme, skb, idx); - jme_fill_first_tx_desc(jme, skb, idx); + jme_fill_tx_desc(jme, skb, idx); jwrite32(jme, JME_TXCS, jme->reg_txcs | TXCS_SELECT_QUEUE0 | TXCS_QUEUE0S | TXCS_ENABLE); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,29) netdev->trans_start = jiffies; +#endif tx_dbg(jme, "xmit: %d+%d@%lu\n", idx, skb_shinfo(skb)->nr_frags + 2, @@ -1965,7 +2109,9 @@ jme_set_multi(struct net_device *netdev) { struct jme_adapter *jme = netdev_priv(netdev); u32 mc_hash[2] = {}; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) int i; +#endif spin_lock_bh(&jme->rxmcs_lock); @@ -1976,15 +2122,28 @@ jme_set_multi(struct net_device *netdev) } else if (netdev->flags & IFF_ALLMULTI) { jme->reg_rxmcs |= RXMCS_ALLMULFRAME; } else if (netdev->flags & IFF_MULTICAST) { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34) struct dev_mc_list *mclist; +#else + struct netdev_hw_addr *ha; +#endif int bit_nr; jme->reg_rxmcs |= RXMCS_MULFRAME | RXMCS_MULFILTERED; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) for (i = 0, mclist = netdev->mc_list; mclist && i < netdev->mc_count; ++i, mclist = mclist->next) { - +#elif LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34) + netdev_for_each_mc_addr(mclist, netdev) { +#else + netdev_for_each_mc_addr(ha, netdev) { +#endif +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,34) bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3F; +#else + bit_nr = ether_crc(ETH_ALEN, ha->addr) & 0x3F; +#endif mc_hash[bit_nr >> 5] |= 1 << (bit_nr & 0x1F); } @@ -2022,13 +2181,20 @@ jme_change_mtu(struct net_device *netdev, int new_mtu) if (new_mtu > 1900) { netdev->features &= ~(NETIF_F_HW_CSUM | - NETIF_F_TSO | - NETIF_F_TSO6); + NETIF_F_TSO +#ifdef NETIF_F_TSO6 + | NETIF_F_TSO6 +#endif + ); } else { if (test_bit(JME_FLAG_TXCSUM, &jme->flags)) netdev->features |= NETIF_F_HW_CSUM; if (test_bit(JME_FLAG_TSO, &jme->flags)) - netdev->features |= NETIF_F_TSO | NETIF_F_TSO6; + netdev->features |= NETIF_F_TSO +#ifdef NETIF_F_TSO6 + | NETIF_F_TSO6 +#endif + ; } netdev->mtu = new_mtu; @@ -2053,13 +2219,64 @@ jme_tx_timeout(struct net_device *netdev) jme_reset_link(jme); } +static inline void jme_pause_rx(struct jme_adapter *jme) +{ + atomic_dec(&jme->link_changing); + + jme_set_rx_pcc(jme, PCC_OFF); + if (test_bit(JME_FLAG_POLL, &jme->flags)) { + JME_NAPI_DISABLE(jme); + } else { + tasklet_disable(&jme->rxclean_task); + tasklet_disable(&jme->rxempty_task); + } +} + +static inline void jme_resume_rx(struct jme_adapter *jme) +{ + struct dynpcc_info *dpi = &(jme->dpi); + + if (test_bit(JME_FLAG_POLL, &jme->flags)) { + JME_NAPI_ENABLE(jme); + } else { + tasklet_hi_enable(&jme->rxclean_task); + tasklet_hi_enable(&jme->rxempty_task); + } + dpi->cur = PCC_P1; + dpi->attempt = PCC_P1; + dpi->cnt = 0; + jme_set_rx_pcc(jme, PCC_P1); + + atomic_inc(&jme->link_changing); +} + static void jme_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) { struct jme_adapter *jme = netdev_priv(netdev); + jme_pause_rx(jme); jme->vlgrp = grp; + jme_resume_rx(jme); +} + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21) +static void +jme_vlan_rx_kill_vid(struct net_device *netdev, unsigned short vid) +{ + struct jme_adapter *jme = netdev_priv(netdev); + + if(jme->vlgrp) { + jme_pause_rx(jme); +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20) + jme->vlgrp->vlan_devices[vid] = NULL; +#else + vlan_group_set_device(jme->vlgrp, vid, NULL); +#endif + jme_resume_rx(jme); + } } +#endif static void jme_get_drvinfo(struct net_device *netdev, @@ -2167,8 +2384,8 @@ jme_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ecmd) if (netif_running(netdev)) return -EBUSY; - if (ecmd->use_adaptive_rx_coalesce - && test_bit(JME_FLAG_POLL, &jme->flags)) { + if (ecmd->use_adaptive_rx_coalesce && + test_bit(JME_FLAG_POLL, &jme->flags)) { clear_bit(JME_FLAG_POLL, &jme->flags); jme->jme_rx = netif_rx; jme->jme_vlan_rx = vlan_hwaccel_rx; @@ -2177,8 +2394,8 @@ jme_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *ecmd) dpi->cnt = 0; jme_set_rx_pcc(jme, PCC_P1); jme_interrupt_mode(jme); - } else if (!(ecmd->use_adaptive_rx_coalesce) - && !(test_bit(JME_FLAG_POLL, &jme->flags))) { + } else if (!(ecmd->use_adaptive_rx_coalesce) && + !(test_bit(JME_FLAG_POLL, &jme->flags))) { set_bit(JME_FLAG_POLL, &jme->flags); jme->jme_rx = netif_receive_skb; jme->jme_vlan_rx = vlan_hwaccel_receive_skb; @@ -2411,10 +2628,18 @@ jme_set_tso(struct net_device *netdev, u32 on) if (on) { set_bit(JME_FLAG_TSO, &jme->flags); if (netdev->mtu <= 1900) - netdev->features |= NETIF_F_TSO | NETIF_F_TSO6; + netdev->features |= NETIF_F_TSO +#ifdef NETIF_F_TSO6 + | NETIF_F_TSO6 +#endif + ; } else { clear_bit(JME_FLAG_TSO, &jme->flags); - netdev->features &= ~(NETIF_F_TSO | NETIF_F_TSO6); + netdev->features &= ~(NETIF_F_TSO +#ifdef NETIF_F_TSO6 + | NETIF_F_TSO6 +#endif + ); } return 0; @@ -2441,7 +2666,11 @@ jme_smb_read(struct jme_adapter *jme, unsigned int addr) val = jread32(jme, JME_SMBCSR); } if (!to) { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_hw(jme, "SMB Bus Busy.\n"); +#else + netif_err(jme, hw, jme->dev, "SMB Bus Busy.\n"); +#endif return 0xFF; } @@ -2457,7 +2686,11 @@ jme_smb_read(struct jme_adapter *jme, unsigned int addr) val = jread32(jme, JME_SMBINTF); } if (!to) { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_hw(jme, "SMB Bus Busy.\n"); +#else + netif_err(jme, hw, jme->dev, "SMB Bus Busy.\n"); +#endif return 0xFF; } @@ -2477,7 +2710,11 @@ jme_smb_write(struct jme_adapter *jme, unsigned int addr, u8 data) val = jread32(jme, JME_SMBCSR); } if (!to) { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_hw(jme, "SMB Bus Busy.\n"); +#else + netif_err(jme, hw, jme->dev, "SMB Bus Busy.\n"); +#endif return; } @@ -2494,7 +2731,11 @@ jme_smb_write(struct jme_adapter *jme, unsigned int addr, u8 data) val = jread32(jme, JME_SMBINTF); } if (!to) { +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) msg_hw(jme, "SMB Bus Busy.\n"); +#else + netif_err(jme, hw, jme->dev, "SMB Bus Busy.\n"); +#endif return; } @@ -2546,7 +2787,11 @@ jme_set_eeprom(struct net_device *netdev, return 0; } +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18) +static struct ethtool_ops jme_ethtool_ops = { +#else static const struct ethtool_ops jme_ethtool_ops = { +#endif .get_drvinfo = jme_get_drvinfo, .get_regs_len = jme_get_regs_len, .get_regs = jme_get_regs, @@ -2575,16 +2820,41 @@ static const struct ethtool_ops jme_ethtool_ops = { static int jme_pci_dma64(struct pci_dev *pdev) { - if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK)) + if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 && +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) + !pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) +#else + !pci_set_dma_mask(pdev, DMA_64BIT_MASK) +#endif + ) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) + if (!pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) +#else if (!pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) +#endif return 1; - if (!pci_set_dma_mask(pdev, DMA_40BIT_MASK)) + if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 && +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) + !pci_set_dma_mask(pdev, DMA_BIT_MASK(40)) +#else + !pci_set_dma_mask(pdev, DMA_40BIT_MASK) +#endif + ) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) + if (!pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(40))) +#else if (!pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK)) +#endif return 1; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) + if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) + if (!pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) +#else if (!pci_set_dma_mask(pdev, DMA_32BIT_MASK)) if (!pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) +#endif return 0; return -1; @@ -2607,8 +2877,22 @@ jme_check_hw_ver(struct jme_adapter *jme) chipmode = jread32(jme, JME_CHIPMODE); jme->fpgaver = (chipmode & CM_FPGAVER_MASK) >> CM_FPGAVER_SHIFT; - jme->chipver = (chipmode & CM_CHIPVER_MASK) >> CM_CHIPVER_SHIFT; -} + jme->chiprev = (chipmode & CM_CHIPREV_MASK) >> CM_CHIPREV_SHIFT; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) +static const struct net_device_ops jme_netdev_ops = { + .ndo_open = jme_open, + .ndo_stop = jme_close, + .ndo_validate_addr = eth_validate_addr, + .ndo_start_xmit = jme_start_xmit, + .ndo_set_mac_address = jme_set_macaddr, + .ndo_set_multicast_list = jme_set_multi, + .ndo_change_mtu = jme_change_mtu, + .ndo_tx_timeout = jme_tx_timeout, + .ndo_vlan_rx_register = jme_vlan_rx_register, +}; +#endif static int __devinit jme_init_one(struct pci_dev *pdev, @@ -2659,21 +2943,30 @@ jme_init_one(struct pci_dev *pdev, rc = -ENOMEM; goto err_out_release_regions; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29) + netdev->netdev_ops = &jme_netdev_ops; +#else netdev->open = jme_open; netdev->stop = jme_close; netdev->hard_start_xmit = jme_start_xmit; netdev->set_mac_address = jme_set_macaddr; netdev->set_multicast_list = jme_set_multi; netdev->change_mtu = jme_change_mtu; - netdev->ethtool_ops = &jme_ethtool_ops; netdev->tx_timeout = jme_tx_timeout; - netdev->watchdog_timeo = TX_TIMEOUT; netdev->vlan_rx_register = jme_vlan_rx_register; +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21) + netdev->vlan_rx_kill_vid = jme_vlan_rx_kill_vid; +#endif NETDEV_GET_STATS(netdev, &jme_get_stats); +#endif + netdev->ethtool_ops = &jme_ethtool_ops; + netdev->watchdog_timeo = TX_TIMEOUT; netdev->features = NETIF_F_HW_CSUM | NETIF_F_SG | NETIF_F_TSO | +#ifdef NETIF_F_TSO6 NETIF_F_TSO6 | +#endif NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; if (using_dac) @@ -2705,14 +2998,6 @@ jme_init_one(struct pci_dev *pdev, rc = -ENOMEM; goto err_out_free_netdev; } - jme->shadow_regs = pci_alloc_consistent(pdev, - sizeof(u32) * SHADOW_REG_NR, - &(jme->shadow_dma)); - if (!(jme->shadow_regs)) { - jeprintk(pdev, "Allocating shadow register mapping error.\n"); - rc = -ENOMEM; - goto err_out_unmap; - } if (no_pseudohp) { apmc = jread32(jme, JME_APMC) & ~JME_APMC_PSEUDO_HP_EN; @@ -2734,20 +3019,21 @@ jme_init_one(struct pci_dev *pdev, atomic_set(&jme->rx_empty, 1); tasklet_init(&jme->pcc_task, - &jme_pcc_tasklet, + jme_pcc_tasklet, (unsigned long) jme); tasklet_init(&jme->linkch_task, - &jme_link_change_tasklet, + jme_link_change_tasklet, (unsigned long) jme); tasklet_init(&jme->txclean_task, - &jme_tx_clean_tasklet, + jme_tx_clean_tasklet, (unsigned long) jme); tasklet_init(&jme->rxclean_task, - &jme_rx_clean_tasklet, + jme_rx_clean_tasklet, (unsigned long) jme); tasklet_init(&jme->rxempty_task, - &jme_rx_empty_tasklet, + jme_rx_empty_tasklet, (unsigned long) jme); + tasklet_disable_nosync(&jme->linkch_task); tasklet_disable_nosync(&jme->txclean_task); tasklet_disable_nosync(&jme->rxclean_task); tasklet_disable_nosync(&jme->rxempty_task); @@ -2797,7 +3083,7 @@ jme_init_one(struct pci_dev *pdev, if (!jme->mii_if.phy_id) { rc = -EIO; jeprintk(pdev, "Can not find phy_id.\n"); - goto err_out_free_shadow; + goto err_out_unmap; } jme->reg_ghc |= GHC_LINK_POLL; @@ -2812,7 +3098,7 @@ jme_init_one(struct pci_dev *pdev, jme->mii_if.mdio_write = jme_mdio_write; jme_clear_pm(jme); - jme_set_gmii(jme); + jme_set_phyfifoa(jme); pci_read_config_byte(pdev, PCI_REVISION_ID, &jme->rev); if (!jme->fpgaver) jme_phy_init(jme); @@ -2826,7 +3112,7 @@ jme_init_one(struct pci_dev *pdev, if (rc) { jeprintk(pdev, "Reload eeprom for reading MAC Address error.\n"); - goto err_out_free_shadow; + goto err_out_unmap; } jme_load_macaddr(netdev); @@ -2842,29 +3128,38 @@ jme_init_one(struct pci_dev *pdev, rc = register_netdev(netdev); if (rc) { jeprintk(pdev, "Cannot register net device.\n"); - goto err_out_free_shadow; + goto err_out_unmap; } - msg_probe(jme, - "JMC250 gigabit%s ver:%u rev:%1x.%1x " - "macaddr:%02x:%02x:%02x:%02x:%02x:%02x\n", +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,33) + msg_probe(jme, "%s%s ver:%x rev:%x " + "macaddr: %02x:%02x:%02x:%02x:%02x:%02x\n", + (jme->pdev->device == PCI_DEVICE_ID_JMICRON_JMC250) ? + "JMC250 Gigabit Ethernet" : + (jme->pdev->device == PCI_DEVICE_ID_JMICRON_JMC260) ? + "JMC260 Fast Ethernet" : "Unknown", (jme->fpgaver != 0) ? " (FPGA)" : "", - (jme->fpgaver != 0) ? jme->fpgaver : jme->chipver, - jme->rev & 0xf, (jme->rev >> 4) & 0xf, - netdev->dev_addr[0], - netdev->dev_addr[1], - netdev->dev_addr[2], - netdev->dev_addr[3], - netdev->dev_addr[4], - netdev->dev_addr[5]); + (jme->fpgaver != 0) ? jme->fpgaver : jme->chiprev, + jme->rev, + netdev->dev_addr[0], + netdev->dev_addr[1], + netdev->dev_addr[2], + netdev->dev_addr[3], + netdev->dev_addr[4], + netdev->dev_addr[5]); +#else + netif_info(jme, probe, jme->dev, "%s%s ver:%x rev:%x macaddr:%pM\n", + (jme->pdev->device == PCI_DEVICE_ID_JMICRON_JMC250) ? + "JMC250 Gigabit Ethernet" : + (jme->pdev->device == PCI_DEVICE_ID_JMICRON_JMC260) ? + "JMC260 Fast Ethernet" : "Unknown", + (jme->fpgaver != 0) ? " (FPGA)" : "", + (jme->fpgaver != 0) ? jme->fpgaver : jme->chiprev, + jme->rev, netdev->dev_addr); +#endif return 0; -err_out_free_shadow: - pci_free_consistent(pdev, - sizeof(u32) * SHADOW_REG_NR, - jme->shadow_regs, - jme->shadow_dma); err_out_unmap: iounmap(jme->regs); err_out_free_netdev: @@ -2885,10 +3180,6 @@ jme_remove_one(struct pci_dev *pdev) struct jme_adapter *jme = netdev_priv(netdev); unregister_netdev(netdev); - pci_free_consistent(pdev, - sizeof(u32) * SHADOW_REG_NR, - jme->shadow_regs, - jme->shadow_dma); iounmap(jme->regs); pci_set_drvdata(pdev, NULL); free_netdev(netdev); @@ -2897,6 +3188,7 @@ jme_remove_one(struct pci_dev *pdev) } +#ifdef CONFIG_PM static int jme_suspend(struct pci_dev *pdev, pm_message_t state) { @@ -2913,8 +3205,6 @@ jme_suspend(struct pci_dev *pdev, pm_message_t state) tasklet_disable(&jme->rxclean_task); tasklet_disable(&jme->rxempty_task); - jme_disable_shadow(jme); - if (netif_carrier_ok(netdev)) { if (test_bit(JME_FLAG_POLL, &jme->flags)) jme_polling_mode(jme); @@ -2966,7 +3256,6 @@ jme_resume(struct pci_dev *pdev) else jme_reset_phy_processor(jme); - jme_enable_shadow(jme); jme_start_irq(jme); netif_device_attach(netdev); @@ -2976,8 +3265,13 @@ jme_resume(struct pci_dev *pdev) return 0; } +#endif +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,24) static struct pci_device_id jme_pci_tbl[] = { +#else +static DEFINE_PCI_DEVICE_TABLE(jme_pci_tbl) = { +#endif { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMC250) }, { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMC260) }, { } @@ -2997,7 +3291,7 @@ static struct pci_driver jme_driver = { static int __init jme_init_module(void) { - printk(KERN_INFO PFX "JMicron JMC250 gigabit ethernet " + printk(KERN_INFO PFX "JMicron JMC2XX ethernet " "driver version %s\n", DRV_VERSION); return pci_register_driver(&jme_driver); }