X-Git-Url: http://bbs.cooldavid.org/git/?p=jme.git;a=blobdiff_plain;f=jme.c;h=1aefa694baf6379d5a43343b704010108992e0ac;hp=83eb75a1d6a04ce5df1f605871a25d4232a80100;hb=7ca9ebeed0c8f2d5ff017bfa190a850c19295dd5;hpb=3b70a6fa8a0860c52fc4cdc74c5006dba2eac82c diff --git a/jme.c b/jme.c index 83eb75a..1aefa69 100644 --- a/jme.c +++ b/jme.c @@ -288,7 +288,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 +326,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) { @@ -497,13 +487,21 @@ jme_check_link(struct net_device *netdev, int testonly) 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); } @@ -522,12 +520,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 @@ -539,6 +533,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 */ @@ -547,6 +546,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 @@ -554,19 +567,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), @@ -578,11 +594,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 @@ -653,7 +669,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; @@ -723,8 +739,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), @@ -734,6 +753,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); @@ -749,12 +769,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 @@ -765,9 +781,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); @@ -778,6 +801,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 @@ -793,9 +829,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 @@ -859,27 +895,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 @@ -921,10 +969,15 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx) skb->ip_summed = CHECKSUM_NONE; if (rxdesc->descwb.flags & cpu_to_le16(RXWBFLAG_TAGON)) { + spin_lock(&jme->vlgrp_lock); if (jme->vlgrp) { jme->jme_vlan_rx(skb, jme->vlgrp, le16_to_cpu(rxdesc->descwb.vlan)); + spin_unlock(&jme->vlgrp_lock); NET_STAT(jme).rx_bytes += 4; + } else { + spin_unlock(&jme->vlgrp_lock); + dev_kfree_skb(skb); } } else { jme->jme_rx(skb); @@ -959,13 +1012,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 & cpu_to_le16(RXWBFLAG_OWN)) || !(rxdesc->descwb.desccnt & RXWBDCNT_WBCPL)) goto out; + --limit; desccnt = rxdesc->descwb.desccnt & RXWBDCNT_DCNT; @@ -1028,8 +1082,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); @@ -1164,9 +1218,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"); +#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) @@ -1284,7 +1346,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); @@ -1299,12 +1365,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); } @@ -1496,12 +1566,7 @@ jme_msi(int irq, void *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); @@ -1584,6 +1649,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); @@ -1592,7 +1658,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)) @@ -1660,15 +1725,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); @@ -1686,7 +1750,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; @@ -1740,7 +1804,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; @@ -1770,7 +1834,7 @@ static int jme_expand_header(struct jme_adapter *jme, struct sk_buff *skb) { if (unlikely( -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,17) skb_shinfo(skb)->tso_size #else skb_shinfo(skb)->gso_size @@ -1787,7 +1851,7 @@ jme_expand_header(struct jme_adapter *jme, struct sk_buff *skb) static int jme_tx_tso(struct sk_buff *skb, __le16 *mss, u8 *flags) { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) +#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); @@ -1858,7 +1922,11 @@ 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; } } @@ -1876,7 +1944,7 @@ jme_tx_vlan(struct sk_buff *skb, __le16 *vlan, u8 *flags) static int 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; @@ -1924,7 +1992,7 @@ jme_fill_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); @@ -1933,12 +2001,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 } } @@ -1946,7 +2022,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 } } @@ -1954,7 +2034,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); @@ -1969,7 +2053,11 @@ 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; } @@ -1980,7 +2068,9 @@ jme_start_xmit(struct sk_buff *skb, struct net_device *netdev) 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, @@ -2021,7 +2111,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); @@ -2036,10 +2128,13 @@ jme_set_multi(struct net_device *netdev) 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) { - +#else + netdev_for_each_mc_addr(mclist, netdev) { +#endif bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3F; mc_hash[bit_nr >> 5] |= 1 << (bit_nr & 0x1F); } @@ -2121,8 +2216,28 @@ jme_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp) { struct jme_adapter *jme = netdev_priv(netdev); + spin_lock_bh(&jme->vlgrp_lock); jme->vlgrp = grp; + spin_unlock_bh(&jme->vlgrp_lock); +} + +#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); + + spin_lock_bh(&jme->vlgrp_lock); + if(jme->vlgrp) { +#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 + } + spin_unlock_bh(&jme->vlgrp_lock); } +#endif static void jme_get_drvinfo(struct net_device *netdev, @@ -2230,8 +2345,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; @@ -2240,8 +2355,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; @@ -2512,7 +2627,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; } @@ -2528,7 +2647,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; } @@ -2548,7 +2671,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; } @@ -2565,7 +2692,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; } @@ -2651,17 +2782,40 @@ static int jme_pci_dma64(struct pci_dev *pdev) { if (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 && - !pci_set_dma_mask(pdev, DMA_64BIT_MASK)) +#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 (pdev->device == PCI_DEVICE_ID_JMICRON_JMC250 && - !pci_set_dma_mask(pdev, DMA_40BIT_MASK)) +#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; @@ -2761,6 +2915,9 @@ jme_init_one(struct pci_dev *pdev, netdev->change_mtu = jme_change_mtu; netdev->tx_timeout = jme_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; @@ -2789,16 +2946,10 @@ jme_init_one(struct pci_dev *pdev, jme->jme_vlan_rx = vlan_hwaccel_rx; jme->old_mtu = netdev->mtu = 1500; jme->phylink = 0; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,21) - jme->tx_ring_size = 1 << 9; - jme->tx_wake_threshold = 1 << 8; - jme->rx_ring_size = 1 << 8; -#else jme->tx_ring_size = 1 << 10; + jme->tx_ring_mask = jme->tx_ring_size - 1; jme->tx_wake_threshold = 1 << 9; jme->rx_ring_size = 1 << 9; -#endif - jme->tx_ring_mask = jme->tx_ring_size - 1; jme->rx_ring_mask = jme->rx_ring_size - 1; jme->msg_enable = JME_DEF_MSG_ENABLE; jme->regs = ioremap(pci_resource_start(pdev, 0), @@ -2808,14 +2959,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; @@ -2830,6 +2973,7 @@ jme_init_one(struct pci_dev *pdev, spin_lock_init(&jme->phy_lock); spin_lock_init(&jme->macaddr_lock); spin_lock_init(&jme->rxmcs_lock); + spin_lock_init(&jme->vlgrp_lock); atomic_set(&jme->link_changing, 1); atomic_set(&jme->rx_cleaning, 1); @@ -2837,20 +2981,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); @@ -2900,7 +3045,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; @@ -2929,7 +3074,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); @@ -2945,25 +3090,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, "%s%s ver:%x rev:%x macaddr:%pM\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->chiprev, - jme->rev, netdev->dev_addr); + 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: @@ -2984,10 +3142,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); @@ -3013,8 +3167,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); @@ -3066,7 +3218,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); @@ -3078,7 +3229,11 @@ jme_resume(struct pci_dev *pdev) } #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) }, { }