Re: [PATCH] NET: dmfe: don't access configuration space in D3 state
On Saturday 24 November 2007 05:10:37 Jeff Garzik wrote: Maxim Levitsky wrote: From 7e24227257f315e52fe0b494dc1253d2a0ce5dff Mon Sep 17 00:00:00 2001 From: Maxim Levitsky [EMAIL PROTECTED] Date: Fri, 23 Nov 2007 01:15:36 +0200 Subject: [PATCH] NET: dmfe: don't access configuration space in D3 state Accidently I reversed the order of pci_save_state and pci_set_power_state in .suspend()/.resume() callbacks Signed-off-by: Maxim Levitsky [EMAIL PROTECTED] --- drivers/net/tulip/dmfe.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) applied #upstream-fixes, after hand-editing patch changelog taking by git-am from email body Hi, Thanks, Next time I will be more careful with changelogs. Best regards, Maxim Levitsky - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
NET: dmfe.c : fix access to card's pci config space in D3
Hi, I somehow assumed that pci_save_state should be called while device is powered off, but actually the opposite is true. Thus I am sending this patch to fix it. Sorry for this mistake, Best regards, Maxim Levitsky - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] NET: dmfe: don't access configuration space in D3 state
From 7e24227257f315e52fe0b494dc1253d2a0ce5dff Mon Sep 17 00:00:00 2001 From: Maxim Levitsky [EMAIL PROTECTED] Date: Fri, 23 Nov 2007 01:15:36 +0200 Subject: [PATCH] NET: dmfe: don't access configuration space in D3 state Accidently I reversed the order of pci_save_state and pci_set_power_state in .suspend()/.resume() callbacks Signed-off-by: Maxim Levitsky [EMAIL PROTECTED] --- drivers/net/tulip/dmfe.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c index 390d02d..9d199b0 100644 --- a/drivers/net/tulip/dmfe.c +++ b/drivers/net/tulip/dmfe.c @@ -2118,8 +2118,8 @@ static int dmfe_suspend(struct pci_dev *pci_dev, pm_message_t state) pci_enable_wake(pci_dev, PCI_D3cold, 1); /* Power down device*/ - pci_set_power_state(pci_dev, pci_choose_state (pci_dev,state)); pci_save_state(pci_dev); + pci_set_power_state(pci_dev, pci_choose_state (pci_dev,state)); return 0; } @@ -2129,8 +2129,8 @@ static int dmfe_resume(struct pci_dev *pci_dev) struct net_device *dev = pci_get_drvdata(pci_dev); u32 tmp; - pci_restore_state(pci_dev); pci_set_power_state(pci_dev, PCI_D0); + pci_restore_state(pci_dev); /* Re-initilize DM910X board */ dmfe_init_dm910x(dev); -- 1.5.3.4 - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [linux-pm] QUESTION: How to fix race between .suspend routine and watchdog timer
On Sunday 28 October 2007 00:24:10 Alan Stern wrote: On Sat, 27 Oct 2007, Maxim Levitsky wrote: Use del_timer_sync(). It guarantees that when it returns, the timer will be stopped and the timer routine will no longer be running on any CPU. Even if the timer re-enables itself, are you sure? Last time I looked at the source code, that's what it did. I'll look again... Yep, it still does. It checks to see if the timer routine is currently running; if so then it waits a little while and tries again. Alan Stern Thanks, a lot, Best regards, Maxim Levitsky - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [linux-pm] QUESTION: How to fix race between .suspend routine and watchdog timer
On Saturday 27 October 2007 21:17:55 Alan Stern wrote: On Fri, 26 Oct 2007, Maxim Levitsky wrote: Looking through the dmfe code, I noticed yet another possible race. A race between the .suspend, and a timer that serves both as a watchdog, and link state detector. Again I need to prevent it from running during the suspend/resume, but how? I can use del_timer in .suspend, and mod_timer in .resume, but that doesn't protect against race with already running timer. I can use del_timer_sync, but it states that it is useless if timer re-enables itself, and I agree with that. In dmfe case the timer does re-enable itself. That comment isn't right. del_timer_sync works perfectly well even if the timer routine re-enables itself, provided it stops doing so after a small number of iterations. Thanks for the info. but Due to the don't access the hardware, while powered-off rule, I must know that the timer isn't running. and won't be. So what function to use (if possible) to be sure that the timer won't run anymore? (Taking in the account the fact that it re-enables itself) Use del_timer_sync(). It guarantees that when it returns, the timer will be stopped and the timer routine will no longer be running on any CPU. Even if the timer re-enables itself, are you sure? Alan Stern Best regards, Maxim Levitsky - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [linux-pm] QUESTION: How to fix race between .suspend routine and watchdog timer
On Thursday 25 October 2007 19:02:12 Alan Stern wrote: On Thu, 25 Oct 2007, Maxim Levitsky wrote: Hi, Recently, trying to fix saa7134 suspend/resume problems I found that there is a race between IRQ handler and .suspend , and that I cant let driver access the device while its in D3 since it can lock up some systems. Now I am looking to fix those issues in two drivers that have my .suspend/.resume routines. the saa7134 capture chip and dmfe, the davicom network driver. Looking through the dmfe code, I noticed yet another possible race. A race between the .suspend, and a timer that serves both as a watchdog, and link state detector. Again I need to prevent it from running during the suspend/resume, but how? I can use del_timer in .suspend, and mod_timer in .resume, but that doesn't protect against race with already running timer. I can use del_timer_sync, but it states that it is useless if timer re-enables itself, and I agree with that. In dmfe case the timer does re-enable itself. That comment isn't right. del_timer_sync works perfectly well even if the timer routine re-enables itself, provided it stops doing so after a small number of iterations. Thanks for the info. but Due to the don't access the hardware, while powered-off rule, I must know that the timer isn't running. and won't be. So what function to use (if possible) to be sure that the timer won't run anymore? (Taking in the account the fact that it re-enables itself) I can put checks in the timer for -insuspend, and don't re enable it if set, but that opens a new can of worms with memory barriers, etc... You don't have to worry about any of that stuff. Just check the insuspend flag and don't re-enable the timer if it is set. Even without any memory barriers, the timer routine won't iterate more than once or twice. Alan Stern Thanks, Best regards, ` Maxim Levitsky - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
QUESTION: How to fix race between .suspend routine and watchdog timer
Hi, Recently, trying to fix saa7134 suspend/resume problems I found that there is a race between IRQ handler and .suspend , and that I cant let driver access the device while its in D3 since it can lock up some systems. Now I am looking to fix those issues in two drivers that have my .suspend/.resume routines. the saa7134 capture chip and dmfe, the davicom network driver. Looking through the dmfe code, I noticed yet another possible race. A race between the .suspend, and a timer that serves both as a watchdog, and link state detector. Again I need to prevent it from running during the suspend/resume, but how? I can use del_timer in .suspend, and mod_timer in .resume, but that doesn't protect against race with already running timer. I can use del_timer_sync, but it states that it is useless if timer re-enables itself, and I agree with that. In dmfe case the timer does re-enable itself. I can put checks in the timer for -insuspend, and don't re enable it if set, but that opens a new can of worms with memory barriers, etc... So please tell me how properly to do that. By the way, this problem, together with synchronize_irq it very generic, since most drivers have and irq handler, and a timeout timer. Best regards, Maxim Levitsky - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] [NETDEV] [001] dmfe : trivial/spelling fixes
On Thursday 08 February 2007 18:53, you wrote: On Thursday 08 February 2007 18:25, you wrote: On Wed, 2007-02-07 at 10:28 -0800, Levitsky Maxim wrote: --- linux-2.6.20-org/drivers/net/tulip/dmfe.c 2007-02-03 11:47:52.0 +0200 +++ linux-2.6.20-mod/drivers/net/tulip/dmfe.c 2007-02-07 14:41:29.0 +0200 @@ -722,7 +742,8 @@ static int dmfe_stop(struct DEVICE *dev) #if 0 /* show statistic counter */ - printk(DRV_NAME : FU:%lx EC:%lx LC:%lx NC:%lx LOC:%lx TXJT:%lx RESET:%lx RCR8:%lx FAL:%lx TT:%lx\n, + printk(DRV_NAME : FU:%lx EC:%lx LC:%lx NC:%lx LOC:%lx TXJT:%lx + RESET:%lx RCR8:%lx FAL:%lx TT:%lx\n, Perhaps you should fix this introduced hanging close quote too something like: printk(DRV_NAME : FU:%lx EC:%lx LC:%lx NC:%lx LOC:%lx TXJT:%lx RESET:%lx RCR8:%lx FAL:%lx TT:%lx\n, cheers, Joe Yes I will review everyting from start , and send it again , (it is much easier to do using gmail ;-) cheers , Maxim Levitsky forget to CC netdev@vger.kernel.org - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] [RESEND] dmfe: number of fixes and features
Hi, I am resending updated version of patches I sent yesterday. Now I use gmail so patches shouldn't be corrupted. Also I cleaned them a lot. Looking for your comments, Your truly, Maxim Levitsky - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2.6.20 1/5] dmfe : trivial/spelling fixes
From: Maxim Levitsky [EMAIL PROTECTED] Subject: [PATCH 2.6.20 1/5] dmfe : trivial/spelling fixes Fix a typo, wrap lines on 80-th column, change KERN_ERR to KERN_INFO for link status message Signed-off-by: Maxim Levitsky [EMAIL PROTECTED] --- --- linux-2.6.20-orig/drivers/net/tulip/dmfe.c 2007-02-03 11:47:52.0 +0200 +++ linux-2.6.20-test/drivers/net/tulip/dmfe.c 2007-02-08 20:29:33.0 +0200 @@ -143,9 +143,16 @@ #define DMFE_TX_TIMEOUT ((3*HZ)/2) /* tx packet time-out time 1.5 s */ #define DMFE_TX_KICK (HZ/2) /* tx packet Kick-out time 0.5 s */ -#define DMFE_DBUG(dbug_now, msg, value) if (dmfe_debug || (dbug_now)) printk(KERN_ERR DRV_NAME : %s %lx\n, (msg), (long) (value)) - -#define SHOW_MEDIA_TYPE(mode) printk(KERN_ERR DRV_NAME : Change Speed to %sMhz %s duplex\n,mode 1 ?100:10, mode 4 ? full:half); +#define DMFE_DBUG(dbug_now, msg, value) \ + do { \ + if (dmfe_debug || (dbug_now)) \ + printk(KERN_ERR DRV_NAME : %s %lx\n,\ + (msg), (long) (value)); \ + } while (0) + +#define SHOW_MEDIA_TYPE(mode) \ + printk (KERN_INFO DRV_NAME : Change Speed to %sMhz %s duplex\n , \ + (mode 1) ? 100:10, (mode 4) ? full:half); /* CR9 definition: SROM/MII */ @@ -163,10 +170,20 @@ #define SROM_V41_CODE 0x14 -#define SROM_CLK_WRITE(data, ioaddr) outl(data|CR9_SROM_READ| CR9_SRCS,ioaddr);udelay(5);outl(data|CR9_SROM_READ|CR9_SRCS| CR9_SRCLK,ioaddr);udelay(5);outl(data|CR9_SROM_READ| CR9_SRCS,ioaddr);udelay(5); +#define SROM_CLK_WRITE(data, ioaddr) \ + outl(data|CR9_SROM_READ|CR9_SRCS,ioaddr); \ + udelay(5); \ + outl(data|CR9_SROM_READ|CR9_SRCS|CR9_SRCLK,ioaddr); \ + udelay(5); \ + outl(data|CR9_SROM_READ|CR9_SRCS,ioaddr); \ + udelay(5); + +#define __CHK_IO_SIZE(pci_id, dev_rev) \ + (( ((pci_id)==PCI_DM9132_ID) || ((dev_rev) = 0x0230) ) ? \ + DM9102A_IO_SIZE: DM9102_IO_SIZE) -#define __CHK_IO_SIZE(pci_id, dev_rev) ( ((pci_id)==PCI_DM9132_ID) || ((dev_rev) = 0x0230) ) ? DM9102A_IO_SIZE: DM9102_IO_SIZE -#define CHK_IO_SIZE(pci_dev, dev_rev) __CHK_IO_SIZE(((pci_dev)-device 16) | (pci_dev)-vendor, dev_rev) +#define CHK_IO_SIZE(pci_dev, dev_rev) \ + (__CHK_IO_SIZE(((pci_dev)-device 16) | (pci_dev)-vendor, dev_rev)) /* Sten Check */ #define DEVICE net_device @@ -329,7 +346,7 @@ static void dmfe_program_DM9802(struct d static void dmfe_HPNA_remote_cmd_chk(struct dmfe_board_info * ); static void dmfe_set_phyxcer(struct dmfe_board_info *); -/* DM910X network baord routine */ +/* DM910X network board routine */ /* * Search DM910X board ,allocate space and register it @@ -356,7 +373,8 @@ static int __devinit dmfe_init_one (stru SET_NETDEV_DEV(dev, pdev-dev); if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) { - printk(KERN_WARNING DRV_NAME : 32-bit PCI DMA not available.\n); + printk(KERN_WARNING DRV_NAME + : 32-bit PCI DMA not available.\n); err = -ENODEV; goto err_out_free; } @@ -402,8 +420,11 @@ static int __devinit dmfe_init_one (stru db-dev = dev; /* Allocate Tx/Rx descriptor memory */ - db-desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, db-desc_pool_dma_ptr); - db-buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, db-buf_pool_dma_ptr); + db-desc_pool_ptr = pci_alloc_consistent(pdev, sizeof(struct tx_desc) * + DESC_ALL_CNT + 0x20, db-desc_pool_dma_ptr); + + db-buf_pool_ptr = pci_alloc_consistent(pdev, TX_BUF_ALLOC * + TX_DESC_CNT + 4, db-buf_pool_dma_ptr); db-first_tx_desc = (struct tx_desc *) db-desc_pool_ptr; db-first_tx_desc_dma = db-desc_pool_dma_ptr; @@ -440,7 +461,8 @@ static int __devinit dmfe_init_one (stru /* read 64 word srom data */ for (i = 0; i 64; i++) - ((u16 *) db-srom)[i] = cpu_to_le16(read_srom_word(db-ioaddr, i)); + ((u16 *) db-srom)[i] = + cpu_to_le16(read_srom_word(db-ioaddr, i)); /* Set Node address */ for (i = 0; i 6; i++) @@ -509,7 +531,8 @@ static int dmfe_open(struct DEVICE *dev) DMFE_DBUG(0, dmfe_open, 0); - ret = request_irq(dev-irq, dmfe_interrupt, IRQF_SHARED, dev-name, dev); + ret = request_irq(dev-irq, dmfe_interrupt, + IRQF_SHARED, dev-name, dev); if (ret) return ret; @@ -650,7 +673,8 @@ static int dmfe_start_xmit(struct sk_buf /* No Tx resource check, it never happen nromally */ if (db-tx_queue_cnt = TX_FREE_DESC_CNT) { spin_unlock_irqrestore(db-lock, flags); - printk(KERN_ERR DRV_NAME : No Tx resource %ld\n, db-tx_queue_cnt
[PATCH 2.6.20 2/5] dmfe: Fix two bugs
From: Maxim Levitsky [EMAIL PROTECTED] Subject : [PATCH 2.6.20 2/5] dmfe: Fix two bugs Fix a oops on module removal due to deallocating memory before unregistring driver Fix a NULL pointer dereference when dev_alloc_skb fails Signed-off-by: Maxim Levitsky [EMAIL PROTECTED] --- --- linux-2.6.20-mod/drivers/net/tulip/dmfe.c 2007-02-08 20:41:25.0 +0200 +++ linux-2.6.20-test/drivers/net/tulip/dmfe.c 2007-02-08 20:48:11.0 +0200 @@ -504,14 +504,17 @@ static void __devexit dmfe_remove_one (s DMFE_DBUG(0, dmfe_remove_one(), 0); if (dev) { + + unregister_netdev(dev); + pci_free_consistent(db-pdev, sizeof(struct tx_desc) * DESC_ALL_CNT + 0x20, db-desc_pool_ptr, db-desc_pool_dma_ptr); pci_free_consistent(db-pdev, TX_BUF_ALLOC * TX_DESC_CNT + 4, db-buf_pool_ptr, db-buf_pool_dma_ptr); - unregister_netdev(dev); pci_release_regions(pdev); free_netdev(dev); /* free board information */ + pci_set_drvdata(pdev, NULL); } @@ -930,7 +933,7 @@ static inline u32 cal_CRC(unsigned char static void dmfe_rx_packet(struct DEVICE *dev, struct dmfe_board_info * db) { struct rx_desc *rxptr; - struct sk_buff *skb; + struct sk_buff *skb, *newskb; int rxlen; u32 rdes0; @@ -984,8 +987,10 @@ static void dmfe_rx_packet(struct DEVICE /* Good packet, send to upper layer */ /* Shorst packet used new SKB */ if ( (rxlen RX_COPY_SIZE) - ( (skb = dev_alloc_skb(rxlen + 2) ) + ( (newskb = dev_alloc_skb(rxlen + 2) ) != NULL) ) { + + skb = newskb; /* size less than COPY_SIZE, allocate a rxlen SKB */ skb-dev = dev; skb_reserve(skb, 2); /* 16byte align */ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2.6.20 3/5] dmfe: Fix link detection
From: Maxim Levitsky [EMAIL PROTECTED] Subject: [PATCH 2.6.20 3/5] dmfe: Fix link detection Remove unused 'link_failed' and fix link detection on cards that use external PHY Signed-off-by: Maxim Levitsky [EMAIL PROTECTED] --- --- linux-2.6.20-mod/drivers/net/tulip/dmfe.c 2007-02-08 20:49:05.0 +0200 +++ linux-2.6.20-test/drivers/net/tulip/dmfe.c 2007-02-08 21:47:37.0 +0200 @@ -248,7 +248,6 @@ struct dmfe_board_info { u8 media_mode; /* user specify media mode */ u8 op_mode; /* real work media mode */ u8 phy_addr; - u8 link_failed; /* Ever link failed */ u8 wait_reset; /* Hardware failed, need to reset */ u8 dm910x_chk_mode; /* Operating mode check */ u8 first_in_callback; /* Flag to record state */ @@ -544,7 +543,6 @@ static int dmfe_open(struct DEVICE *dev) db-tx_packet_cnt = 0; db-tx_queue_cnt = 0; db-rx_avail_cnt = 0; - db-link_failed = 1; db-wait_reset = 0; db-first_in_callback = 0; @@ -1101,6 +1099,8 @@ static void dmfe_timer(unsigned long dat struct dmfe_board_info *db = netdev_priv(dev); unsigned long flags; + int link_ok, link_ok_phy; + DMFE_DBUG(0, dmfe_timer(), 0); spin_lock_irqsave(db-lock, flags); @@ -1166,22 +1166,43 @@ static void dmfe_timer(unsigned long dat else tmp_cr12 = inb(db-ioaddr + DCR12); /* DM9102/DM9102A */ + if ( ((db-chip_id == PCI_DM9102_ID) (db-chip_revision == 0x0230)) || ((db-chip_id == PCI_DM9132_ID) (db-chip_revision == 0x0210)) ) { /* DM9102A Chip */ if (tmp_cr12 2) - tmp_cr12 = 0x0; /* Link failed */ + link_ok = 0; else - tmp_cr12 = 0x3; /* Link OK */ + link_ok = 1; + } + else + /*0x43 is used instead of 0x3 because bit 6 should represent + link status of external PHY */ + link_ok = (tmp_cr12 0x43) ? 1 : 0; + + + /* If chip reports that link is failed it could be because external + PHY link status pin is not conected correctly to chip + To be sure ask PHY too. + */ + + /* need a dummy read because of PHY's register latch*/ + phy_read (db-ioaddr, db-phy_addr, 1, db-chip_id); + link_ok_phy = (phy_read (db-ioaddr, + db-phy_addr, 1, db-chip_id) 0x4) ? 1 : 0; + + if (link_ok_phy != link_ok) { + DMFE_DBUG (0, PHY and chip report different link status, 0); + link_ok = link_ok | link_ok_phy; } - if ( !(tmp_cr12 0x3) !db-link_failed ) { + if ( !link_ok netif_carrier_ok(dev) ) { /* Link Failed */ DMFE_DBUG(0, Link Failed, tmp_cr12); - db-link_failed = 1; - netif_carrier_off(db-dev); + + netif_carrier_off(dev); /* For Force 10/100M Half/Full mode: Enable Auto-Nego mode */ /* AUTO or force 1M Homerun/Longrun don't need */ @@ -1196,19 +1217,17 @@ static void dmfe_timer(unsigned long dat db-cr6_data=~0x0200; /* bit9=0, HD mode */ update_cr6(db-cr6_data, db-ioaddr); } - } else - if ((tmp_cr12 0x3) db-link_failed) { - DMFE_DBUG(0, Link link OK, tmp_cr12); - db-link_failed = 0; + + } else if (!netif_carrier_ok(dev)) { + + DMFE_DBUG(0, Link OK, tmp_cr12); /* Auto Sense Speed */ - if ( (db-media_mode DMFE_AUTO) - dmfe_sense_speed(db) ) - db-link_failed = 1; - else - netif_carrier_on(db-dev); + if (! (db-media_mode DMFE_AUTO) || !dmfe_sense_speed(db)) { + netif_carrier_on(dev); + SHOW_MEDIA_TYPE(db-op_mode); + } dmfe_process_mode(db); - /* SHOW_MEDIA_TYPE(db-op_mode); */ } /* HPNA remote command check */ @@ -1255,7 +1274,7 @@ static void dmfe_dynamic_reset(struct DE db-tx_packet_cnt = 0; db-tx_queue_cnt = 0; db-rx_avail_cnt = 0; - db-link_failed = 1; + netif_carrier_off(dev); db-wait_reset = 0; /* Re-initilize DM910X board */ - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2.6.20 5/5] dmfe: add support for wake on lan
From Maxim Levitsky [EMAIL PROTECTED] Subject: [PATCH 2.6.20 5/5] dmfe: add support for wake on lan This patch adds support for WOL on Magic Packet and on link change Signed-off-by: Maxim Levitsky [EMAIL PROTECTED] --- linux-2.6.20-mod/drivers/net/tulip/dmfe.c 2007-02-08 22:03:07.0 +0200 +++ linux-2.6.20-test/drivers/net/tulip/dmfe.c 2007-02-08 22:10:57.0 +0200 @@ -122,6 +122,11 @@ #define DM9801_NOISE_FLOOR 8 #define DM9802_NOISE_FLOOR 5 +#define DMFE_WOL_LINKCHANGE0x2000 +#define DMFE_WOL_SAMPLEPACKET 0x1000 +#define DMFE_WOL_MAGICPACKET 0x0800 + + #define DMFE_10MHF 0 #define DMFE_100MHF 1 #define DMFE_10MFD 4 @@ -248,6 +253,7 @@ struct dmfe_board_info { u8 wait_reset; /* Hardware failed, need to reset */ u8 dm910x_chk_mode; /* Operating mode check */ u8 first_in_callback; /* Flag to record state */ + u8 wol_mode;/* user WOL settings */ struct timer_list timer; /* System defined statistic counter */ @@ -430,6 +436,7 @@ static int __devinit dmfe_init_one (stru db-chip_id = ent-driver_data; db-ioaddr = pci_resource_start(pdev, 0); db-chip_revision = dev_rev; + db-wol_mode = 0; db-pdev = pdev; @@ -1064,7 +1071,11 @@ static void dmfe_set_filter_mode(struct spin_unlock_irqrestore(db-lock, flags); } -static void netdev_get_drvinfo(struct net_device *dev, +/* + * Ethtool interace + */ + +static void dmfe_ethtool_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { struct dmfe_board_info *np = netdev_priv(dev); @@ -1078,9 +1089,35 @@ static void netdev_get_drvinfo(struct ne dev-base_addr, dev-irq); } +static int dmfe_ethtool_set_wol(struct net_device *dev, + struct ethtool_wolinfo *wolinfo) +{ + struct dmfe_board_info *db = netdev_priv(dev); + + if (wolinfo-wolopts (WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | + WAKE_ARP | WAKE_MAGICSECURE)) + return -EOPNOTSUPP; + + db-wol_mode = wolinfo-wolopts; + return 0; +} + +static void dmfe_ethtool_get_wol(struct net_device *dev, +struct ethtool_wolinfo *wolinfo) +{ + struct dmfe_board_info *db = netdev_priv(dev); + + wolinfo-supported = WAKE_PHY | WAKE_MAGIC; + wolinfo-wolopts = db-wol_mode; + return; +} + + static const struct ethtool_ops netdev_ethtool_ops = { - .get_drvinfo= netdev_get_drvinfo, + .get_drvinfo= dmfe_ethtool_get_drvinfo, .get_link = ethtool_op_get_link, + .set_wol= dmfe_ethtool_set_wol, + .get_wol= dmfe_ethtool_get_wol, }; /* @@ -2056,6 +2093,7 @@ static int dmfe_suspend(struct pci_dev * { struct net_device *dev = pci_get_drvdata(pci_dev); struct dmfe_board_info *db = netdev_priv(dev); + u32 tmp; /* Disable upper layer interface */ netif_device_detach (dev); @@ -2071,6 +2109,20 @@ static int dmfe_suspend(struct pci_dev * /* Fre RX buffers */ dmfe_free_rxbuffer (db); + /* Enable WOL */ + pci_read_config_dword(pci_dev, 0x40, tmp); + tmp = ~(DMFE_WOL_LINKCHANGE|DMFE_WOL_MAGICPACKET); + + if (db-wol_mode WAKE_PHY) + tmp |= DMFE_WOL_LINKCHANGE; + if (db-wol_mode WAKE_MAGIC) + tmp |= DMFE_WOL_MAGICPACKET; + + pci_write_config_dword(pci_dev, 0x40, tmp); + + pci_enable_wake(pci_dev, PCI_D3hot, 1); + pci_enable_wake(pci_dev, PCI_D3cold, 1); + /* Power down device*/ pci_set_power_state (pci_dev, pci_choose_state (pci_dev,state)); pci_save_state (pci_dev); @@ -2081,13 +2133,23 @@ static int dmfe_suspend(struct pci_dev * static int dmfe_resume (struct pci_dev *pci_dev) { struct net_device *dev = pci_get_drvdata (pci_dev); + u32 tmp; pci_restore_state(pci_dev); pci_set_power_state(pci_dev ,PCI_D0); /* Re-initilize DM910X board */ dmfe_init_dm910x(dev); + + /* Disable WOL */ + pci_read_config_dword(pci_dev, 0x40, tmp); + tmp = (DMFE_WOL_LINKCHANGE | DMFE_WOL_MAGICPACKET); + pci_write_config_dword(pci_dev, 0x40, tmp); + + pci_enable_wake(pci_dev, PCI_D3hot, 0); + pci_enable_wake(pci_dev, PCI_D3cold, 0); + /* Restart upper layer interface */ netif_device_attach(dev); - To unsubscribe from this list: send the line unsubscribe netdev in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html