dmfe: number of fixes and features
Subsystems (2)
v2 cover dmfe: number of fixes and features
Hi,
Here I am resending revised and hopefully last version of patches I have prepared for DMFE driver.
As it was suggested to me I did revert commit 7628b0a8c01a02966d2228bdf741ddedb128e8f8 that adds basic link support. So those patches will apply cleanly to 2.6.19 or 2.6.20 with this commit reverted.
Looking for comments, Maxim Levitsky
PATCH RESEND v2 1/5 dmfe : trivial/spelling fixes
From: Maxim Levitsky <[email protected]>
Subject: [PATCH 2.6.20 001/005] [RESEND v2] dmfe : trivial/spelling fixes
Fix a typo, wrap lines on 80-th column, change KERN_ERR to KERN_INFO for link status message
---
drivers/net/tulip/dmfe.c +89 -37
@@ -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) >= 0x02000030) ) ? \ + DM9102A_IO_SIZE: DM9102_IO_SIZE) -#define __CHK_IO_SIZE (pci_id, dev_rev) ( ((pci_id)==PCI_DM9132_ID) || ((dev_rev) >= 0x02000030) ) ? 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 dstatic 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 (struSET_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; }
@@ -400,8 +418,11 @@ static int __devinit dmfe_init_one (stru db =netdev_priv (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;
@@ -437,7 +458,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++)
@@ -506,7 +528,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;
@@ -647,7 +670,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); + printk(KERN_ERR DRV_NAME ": No Tx resource %ld\n", + db->tx_queue_cnt);return 1 ; }
@@ -719,7 +743,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", db->tx_fifo_underrun, db->tx_excessive_collision, db->tx_late_collision, db->tx_no_carrier, db->tx_loss_carrier, db->tx_jabber_timeout, db->reset_count, db->reset_cr8,
@@ -916,7 +941,9 @@ static void dmfe_rx_packet(struct DEVICE db->rx_avail_cnt--; db->interval_rx_cnt++; -pci_unmap_single (db->pdev,le32_to_cpu (rxptr->rdes2),RX_ALLOC_SIZE ,PCI_DMA_FROMDEVICE ); +pci_unmap_single (db->pdev,le32_to_cpu (rxptr->rdes2), +RX_ALLOC_SIZE ,PCI_DMA_FROMDEVICE ); +if ( (rdes0 &0x300 ) !=0x300 ) {/* A packet without First/Last flag */ /* reuse this SKB */
@@ -1074,7 +1101,8 @@ static void dmfe_timer(unsigned long datif (db->chip_type && (db->chip_id==PCI_DM9102_ID )) { db->cr6_data &= ~0x40000 ;update_cr6 (db->cr6_data, db->ioaddr); -phy_write (db->ioaddr, db->phy_addr,0 ,0x1000 , db->chip_id); +phy_write (db->ioaddr, + db->phy_addr,0 ,0x1000 , db->chip_id); db->cr6_data |=0x40000 ;update_cr6 (db->cr6_data, db->ioaddr); db->timer.expires =DMFE_TIMER_WUT +HZ *2 ;
@@ -1148,7 +1176,8 @@ static void dmfe_timer(unsigned long dat/* For Force 10/100M Half/Full mode: Enable Auto-Nego mode */ /* AUTO or force 1M Homerun/Longrun don't need */ if ( !(db->media_mode &0x38 ) ) -phy_write (db->ioaddr, db->phy_addr,0 ,0x1000 , db->chip_id); +phy_write (db->ioaddr, db->phy_addr, +0 ,0x1000 , db->chip_id);/* AUTO mode, if INT phyxcer link failed, select EXT device */ if (db->media_mode &DMFE_AUTO ) {
@@ -1252,7 +1281,8 @@ static void dmfe_reuse_skb(struct dmfe_bif (!(rxptr->rdes0 &cpu_to_le32 (0x80000000 ))) { rxptr->rx_skb_ptr = skb; - rxptr->rdes2 =cpu_to_le32 (pci_map_single (db->pdev, skb->data,RX_ALLOC_SIZE ,PCI_DMA_FROMDEVICE ) ); + rxptr->rdes2 =cpu_to_le32 (pci_map_single (db->pdev, + skb->data,RX_ALLOC_SIZE ,PCI_DMA_FROMDEVICE ) );wmb (); rxptr->rdes0 =cpu_to_le32 (0x80000000 ); db->rx_avail_cnt++;
@@ -1284,8 +1314,11 @@ static void dmfe_descriptor_init(structoutl (db->first_tx_desc_dma, ioaddr +DCR4 );/* TX DESC address */ /* rx descriptor start pointer */ - db->first_rx_desc = (void *)db->first_tx_desc +sizeof (struct tx_desc ) *TX_DESC_CNT ; - db->first_rx_desc_dma = db->first_tx_desc_dma +sizeof (struct tx_desc ) *TX_DESC_CNT ; + db->first_rx_desc = (void *)db->first_tx_desc + +sizeof (struct tx_desc ) *TX_DESC_CNT ; + + db->first_rx_desc_dma = db->first_tx_desc_dma + +sizeof (struct tx_desc ) *TX_DESC_CNT ; db->rx_insert_ptr = db->first_rx_desc; db->rx_ready_ptr = db->first_rx_desc;outl (db->first_rx_desc_dma, ioaddr +DCR3 );/* RX DESC address */
@@ -1463,7 +1496,8 @@ static void allocate_rx_buffer(struct dmif ( ( skb =dev_alloc_skb (RX_ALLOC_SIZE ) ) ==NULL )break ; rxptr->rx_skb_ptr = skb;/* FIXME (?) */ - rxptr->rdes2 =cpu_to_le32 (pci_map_single (db->pdev, skb->data,RX_ALLOC_SIZE ,PCI_DMA_FROMDEVICE ) ); + rxptr->rdes2 =cpu_to_le32 (pci_map_single (db->pdev, skb->data, +RX_ALLOC_SIZE ,PCI_DMA_FROMDEVICE ) );wmb (); rxptr->rdes0 =cpu_to_le32 (0x80000000 ); rxptr = rxptr->next_rx_desc;
@@ -1503,7 +1537,8 @@ static u16 read_srom_word(long ioaddr, ifor (i =16 ; i >0 ; i--) {outl (CR9_SROM_READ |CR9_SRCS |CR9_SRCLK , cr9_ioaddr);udelay (5 ); - srom_data = (srom_data <<1 ) | ((inl (cr9_ioaddr) &CR9_CRDOUT ) ?1 :0 ); + srom_data = (srom_data <<1 ) | + ((inl (cr9_ioaddr) &CR9_CRDOUT ) ?1 :0 );outl (CR9_SROM_READ |CR9_SRCS , cr9_ioaddr);udelay (5 ); }
@@ -1530,9 +1565,11 @@ static u8 dmfe_sense_speed(struct dmfe_bif ( (phy_mode &0x24 ) ==0x24 ) {if (db->chip_id ==PCI_DM9132_ID )/* DM9132 */ - phy_mode =phy_read (db->ioaddr, db->phy_addr,7 , db->chip_id) &0xf000 ; + phy_mode =phy_read (db->ioaddr, + db->phy_addr,7 , db->chip_id) &0xf000 ;else /* DM9102/DM9102A */ - phy_mode =phy_read (db->ioaddr, db->phy_addr,17 , db->chip_id) &0xf000 ; + phy_mode =phy_read (db->ioaddr, + db->phy_addr,17 , db->chip_id) &0xf000 ;/* printk(DRV_NAME ": Phy_mode %x ",phy_mode); */ switch (phy_mode) {case 0x1000 : db->op_mode =DMFE_10MHF ;break ;
@@ -1569,8 +1606,11 @@ static void dmfe_set_phyxcer(struct dmfe/* DM9009 Chip: Phyxcer reg18 bit12=0 */ if (db->chip_id ==PCI_DM9009_ID ) { - phy_reg =phy_read (db->ioaddr, db->phy_addr,18 , db->chip_id) & ~0x1000 ; -phy_write (db->ioaddr, db->phy_addr,18 , phy_reg, db->chip_id); + phy_reg =phy_read (db->ioaddr, + db->phy_addr,18 , db->chip_id) & ~0x1000 ; + +phy_write (db->ioaddr, + db->phy_addr,18 , phy_reg, db->chip_id); }/* Phyxcer capability setting */
@@ -1643,10 +1683,12 @@ static void dmfe_process_mode(struct dmfcase DMFE_100MHF : phy_reg =0x2000 ;break ;case DMFE_100MFD : phy_reg =0x2100 ;break ; } -phy_write (db->ioaddr, db->phy_addr,0 , phy_reg, db->chip_id); +phy_write (db->ioaddr, + db->phy_addr,0 , phy_reg, db->chip_id);if ( db->chip_type && (db->chip_id ==PCI_DM9102_ID ) )mdelay (20 ); -phy_write (db->ioaddr, db->phy_addr,0 , phy_reg, db->chip_id); +phy_write (db->ioaddr, + db->phy_addr,0 , phy_reg, db->chip_id); } } }
@@ -1656,7 +1698,8 @@ static void dmfe_process_mode(struct dmf* Write a word to Phy register */ -static void phy_write (unsigned long iobase,u8 phy_addr,u8 offset,u16 phy_data,u32 chip_id) +static void phy_write (unsigned long iobase,u8 phy_addr,u8 offset, +u16 phy_data,u32 chip_id) {u16 i;unsigned long ioaddr;
@@ -1682,11 +1725,13 @@ static void phy_write(unsigned long ioba/* Send Phy address */ for (i =0x10 ; i >0 ; i = i >>1 ) -phy_write_1bit (ioaddr, phy_addr & i ?PHY_DATA_1 :PHY_DATA_0 ); +phy_write_1bit (ioaddr, + phy_addr & i ?PHY_DATA_1 :PHY_DATA_0 );/* Send register address */ for (i =0x10 ; i >0 ; i = i >>1 ) -phy_write_1bit (ioaddr, offset & i ?PHY_DATA_1 :PHY_DATA_0 ); +phy_write_1bit (ioaddr, + offset & i ?PHY_DATA_1 :PHY_DATA_0 );/* written trasnition */ phy_write_1bit (ioaddr,PHY_DATA_1 );
@@ -1694,7 +1739,8 @@ static void phy_write(unsigned long ioba/* Write a word data to PHY controller */ for ( i =0x8000 ; i >0 ; i >>=1 ) -phy_write_1bit (ioaddr, phy_data & i ?PHY_DATA_1 :PHY_DATA_0 ); +phy_write_1bit (ioaddr, + phy_data & i ?PHY_DATA_1 :PHY_DATA_0 ); } }
@@ -1731,11 +1777,13 @@ static u16 phy_read(unsigned long iobase/* Send Phy address */ for (i =0x10 ; i >0 ; i = i >>1 ) -phy_write_1bit (ioaddr, phy_addr & i ?PHY_DATA_1 :PHY_DATA_0 ); +phy_write_1bit (ioaddr, + phy_addr & i ?PHY_DATA_1 :PHY_DATA_0 );/* Send register address */ for (i =0x10 ; i >0 ; i = i >>1 ) -phy_write_1bit (ioaddr, offset & i ?PHY_DATA_1 :PHY_DATA_0 ); +phy_write_1bit (ioaddr, + offset & i ?PHY_DATA_1 :PHY_DATA_0 );/* Skip transition state */ phy_read_1bit (ioaddr);
@@ -1956,7 +2004,8 @@ static void dmfe_HPNA_remote_cmd_chk(str/* Check remote device status match our setting ot not */ if ( phy_reg != (db->HPNA_command &0x0f00 ) ) { -phy_write (db->ioaddr, db->phy_addr,16 , db->HPNA_command, db->chip_id); +phy_write (db->ioaddr, db->phy_addr,16 , db->HPNA_command, + db->chip_id); db->HPNA_timer=8 ; }else db->HPNA_timer=600 ;/* Match, every 10 minutes, check */
@@ -1996,8 +2045,11 @@ module_param(HPNA_tx_cmd, byte, 0);module_param (HPNA_NoiseFloor, byte,0 );module_param (SF_mode, byte,0 );MODULE_PARM_DESC (debug,"Davicom DM9xxx enable debugging (0-1)" ); -MODULE_PARM_DESC (mode,"Davicom DM9xxx: Bit 0: 10/100Mbps, bit 2: duplex, bit 8: HomePNA" ); -MODULE_PARM_DESC (SF_mode,"Davicom DM9xxx special function (bit 0: VLAN, bit 1 Flow Control, bit 2: TX pause packet)" ); +MODULE_PARM_DESC (mode,"Davicom DM9xxx: " +"Bit 0: 10/100Mbps, bit 2: duplex, bit 8: HomePNA" ); + +MODULE_PARM_DESC (SF_mode,"Davicom DM9xxx special function " +"(bit 0: VLAN, bit 1 Flow Control, bit 2: TX pause packet)" );/* Description: * when user used insmod to add module, system invoked init_module()
PATCH RESEND v2 2/5 dmfe : Fix two bugs
In reply to MaximFrom: Maxim Levitsky <[email protected]>
Subject: [PATCH 2.6.20 002/005] [RESEND v2] 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
---
drivers/net/tulip/dmfe.c +8 -3
@@ -501,14 +501,17 @@ static void __devexit dmfe_remove_one (sDMFE_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 ); }
@@ -927,7 +930,7 @@ static inline u32 cal_CRC(unsigned charstatic 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;
@@ -981,8 +984,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 */
Subject: [PATCH 2.6.20 003/005] [RESEND v2] dmfe: Fix link detection
In reply to MaximFrom: Maxim Levitsky <[email protected]>
Subject: [PATCH 2.6.20 003/005] [RESEND v2] dmfe: Fix link detection
Add link detection
---
drivers/net/tulip/dmfe.c +40 -18
@@ -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 */
@@ -447,6 +446,7 @@ static int __devinit dmfe_init_one (stru dev->poll_controller = &poll_dmfe;#endif dev->ethtool_ops = &netdev_ethtool_ops; +netif_carrier_off (dev);spin_lock_init (&db->lock);pci_read_config_dword (pdev,0x50 , &pci_pmr);
@@ -541,7 +541,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 ;
@@ -1082,6 +1081,7 @@ static void netdev_get_drvinfo(struct nestatic const struct ethtool_ops netdev_ethtool_ops = { .get_drvinfo = netdev_get_drvinfo, + .get_link = ethtool_op_get_link, };/*
@@ -1097,6 +1097,8 @@ static void dmfe_timer(unsigned long datstruct 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);
@@ -1168,15 +1170,35 @@ static void dmfe_timer(unsigned long dat (db->chip_revision == 0x02000010)) ) {/* 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 (dev);/* For Force 10/100M Half/Full mode: Enable Auto-Nego mode */ /* AUTO or force 1M Homerun/Longrun don't need */
@@ -1191,19 +1213,19 @@ static void dmfe_timer(unsigned long dat db->cr6_data&=~0x00000200 ;/* 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 ; - -/* Auto Sense Speed */ -if ( (db->media_mode &DMFE_AUTO ) && -dmfe_sense_speed (db) ) - db->link_failed =1 ; -dmfe_process_mode (db); -/* SHOW_MEDIA_TYPE(db->op_mode); */ + }else if (!netif_carrier_ok (dev)) { + +DMFE_DBUG (0 ,"Link link OK" , tmp_cr12); + +/* Auto Sense Speed */ +if ( !(db->media_mode &DMFE_AUTO ) || !dmfe_sense_speed (db)) { +netif_carrier_on (dev); +SHOW_MEDIA_TYPE (db->op_mode); } +dmfe_process_mode (db); + } +/* HPNA remote command check */ if (db->HPNA_command &0xf00 ) { db->HPNA_timer--;
@@ -1248,7 +1270,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 */
Subject: [PATCH 2.6.20 004/005] dmfe: Add support for suspend/resume
In reply to MaximQuoted 1 line
From Maxim Levitsky <[email protected]>
Subject: [PATCH 2.6.20 004/005] dmfe: Add support for suspend/resume
This adds support for suspend resume
---
drivers/net/tulip/dmfe.c +45 -3
@@ -55,9 +55,6 @@TODO - Implement pci_driver::suspend() and pci_driver::resume() - power management methods. - Check on 64 bit boxes. Check and fix on big endian boxes.
@@ -2050,11 +2047,56 @@ static struct pci_device_id dmfe_pci_tblMODULE_DEVICE_TABLE (pci, dmfe_pci_tbl); + +static int dmfe_suspend (struct pci_dev *pci_dev,pm_message_t state) +{ +struct net_device *dev =pci_get_drvdata (pci_dev); +struct dmfe_board_info *db =netdev_priv (dev); + +/* Disable upper layer interface */ +netif_device_detach (dev); + +/* Disable Tx/Rx */ + db->cr6_data &= ~(CR6_RXSC |CR6_TXSC ); +update_cr6 (db->cr6_data, dev->base_addr); + +/* Disable Interrupt */ +outl (0 , dev->base_addr +DCR7 ); +outl (inl (dev->base_addr +DCR5 ), dev->base_addr +DCR5 ); + +/* Fre RX buffers */ +dmfe_free_rxbuffer (db); + +/* Power down device*/ +pci_set_power_state (pci_dev,pci_choose_state (pci_dev,state)); +pci_save_state (pci_dev); + +return 0 ; +} + +static int dmfe_resume (struct pci_dev *pci_dev) +{ +struct net_device *dev =pci_get_drvdata (pci_dev); + +pci_restore_state (pci_dev); +pci_set_power_state (pci_dev ,PCI_D0 ); + +/* Re-initilize DM910X board */ +dmfe_init_dm910x (dev); + +/* Restart upper layer interface */ +netif_device_attach (dev); + +return 0 ; +} +static struct pci_driver dmfe_driver = { .name ="dmfe" , .id_table = dmfe_pci_tbl, .probe = dmfe_init_one, .remove =__devexit_p (dmfe_remove_one), + .suspend = dmfe_suspend, + .resume = dmfe_resume };MODULE_AUTHOR ("Sten Wang, [email protected]" );
Re: Subject: [PATCH 2.6.20 004/005] dmfe: Add support for suspend/resume
Hi!
Quoted 10 lines
drivers/net/tulip/dmfe.c +6
-0@@ -2050,11 +2047,56 @@ static struct pci_device_id dmfe_pci_tblMODULE_DEVICE_TABLE (pci, dmfe_pci_tbl); + +static int dmfe_suspend (struct pci_dev *pci_dev,pm_message_t state) +{ +struct net_device *dev =pci_get_drvdata (pci_dev); +struct dmfe_board_info *db =netdev_priv (dev); +
drivers/net/tulip/dmfe.c static struct pci_device_id dmfe_pci_tbl · line 2065
Quoted 10 lines
drivers/net/tulip/dmfe.c +10
-0+/* Disable upper layer interface */ +netif_device_detach (dev); + +/* Disable Tx/Rx */ + db->cr6_data &= ~(CR6_RXSC |CR6_TXSC ); +update_cr6 (db->cr6_data, dev->base_addr); + +/* Disable Interrupt */ +outl (0 , dev->base_addr +DCR7 ); +outl (inl (dev->base_addr +DCR5 ), dev->base_addr +DCR5 );
Please no space between function and "(".
drivers/net/tulip/dmfe.c static struct pci_device_id dmfe_pci_tbl · line 2067
Quoted 1 line
drivers/net/tulip/dmfe.c +1
-0+/* Fre RX buffers */
Free?
drivers/net/tulip/dmfe.c static struct pci_device_id dmfe_pci_tbl
Quoted 3 lines
drivers/net/tulip/dmfe.c +2
-0+dmfe_free_rxbuffer (db); +/* Power down device*/
" */"
drivers/net/tulip/dmfe.c static struct pci_device_id dmfe_pci_tbl · line 2071
Quoted 1 line
drivers/net/tulip/dmfe.c +1
-0+pci_set_power_state (pci_dev,pci_choose_state (pci_dev,state));
Let it be ", state", and delete spaces between function and "(".
drivers/net/tulip/dmfe.c static struct pci_device_id dmfe_pci_tbl · line 2077
Quoted 1 line
drivers/net/tulip/dmfe.c +1
-0+static int dmfe_resume (struct pci_dev *pci_dev)
delete spaces between function and "(".
drivers/net/tulip/dmfe.c static struct pci_device_id dmfe_pci_tbl · line 2083
Quoted 3 lines
drivers/net/tulip/dmfe.c +3
-0+pci_restore_state (pci_dev); +pci_set_power_state (pci_dev ,PCI_D0 ); +
", "
Otherwise looks ok to me.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: Subject: [PATCH 2.6.20 004/005] dmfe: Add support for suspend/resume
Quoted 16 lines · On Saturday 17 February 2007 13:50:29 Pavel Machek wrote:
Hi!
Quoted 14 lines
(quoted diff) +10
-0@@ -2050,11 +2047,56 @@ static struct pci_device_id dmfe_pci_tbl MODULE_DEVICE_TABLE(pci, dmfe_pci_tbl); + +static int dmfe_suspend(struct pci_dev *pci_dev, pm_message_t state) +{ + struct net_device *dev = pci_get_drvdata(pci_dev); + struct dmfe_board_info *db = netdev_priv(dev); + + /* Disable upper layer interface */ + netif_device_detach (dev); + + /* Disable Tx/Rx */
Quoted 8 lines
Review static struct pci_device_id dmfe_pci_tbl · line 2065
Quoted 6 lines
(quoted diff) +6
-0+ db->cr6_data &= ~(CR6_RXSC | CR6_TXSC); + update_cr6(db->cr6_data, dev->base_addr); + + /* Disable Interrupt */ + outl (0, dev->base_addr + DCR7); + outl (inl (dev->base_addr + DCR5), dev->base_addr + DCR5);Please no space between function and "(".
I missed that part of coding style about no space after function name
Quoted 4 lines
Review static struct pci_device_id dmfe_pci_tbl · line 2066
Quoted 2 lines
(quoted diff) +1
-0+ /* Fre RX buffers */Free?
Of course :-)
Quoted 10 lines
Review static struct pci_device_id dmfe_pci_tbl · line 2069
Quoted 4 lines
(quoted diff) +2
-0+ dmfe_free_rxbuffer (db); + /* Power down device*/" */"
Review static struct pci_device_id dmfe_pci_tbl · line 2070
Quoted 1 line
(quoted diff) +1
-0+ pci_set_power_state (pci_dev, pci_choose_state (pci_dev,state));Let it be ", state", and delete spaces between function and "(".
Sure
Quoted 6 lines
Review static struct pci_device_id dmfe_pci_tbl · line 2071
Quoted 3 lines
(quoted diff) +1
-0+static int dmfe_resume (struct pci_dev *pci_dev)delete spaces between function and "(".
Quoted 8 lines
Review static struct pci_device_id dmfe_pci_tbl · line 2074
Quoted 3 lines
(quoted diff) +3
-0+ pci_restore_state(pci_dev); + pci_set_power_state(pci_dev ,PCI_D0); +", "
Otherwise looks ok to me.
Hello , I am sorry that I missed some parts of coding style. I need to reread it :-)
There is a updated patch :
drivers/net/tulip/dmfe.c +45 -3
@@ -55,9 +55,6 @@TODO - Implement pci_driver::suspend() and pci_driver::resume() - power management methods. - Check on 64 bit boxes. Check and fix on big endian boxes.
@@ -2050,11 +2047,56 @@ static struct pci_device_id dmfe_pci_tblMODULE_DEVICE_TABLE (pci, dmfe_pci_tbl); + +static int dmfe_suspend (struct pci_dev *pci_dev,pm_message_t state) +{ +struct net_device *dev =pci_get_drvdata (pci_dev); +struct dmfe_board_info *db =netdev_priv (dev); + +/* Disable upper layer interface */ +netif_device_detach (dev); + +/* Disable Tx/Rx */ + db->cr6_data &= ~(CR6_RXSC |CR6_TXSC ); +update_cr6 (db->cr6_data, dev->base_addr); + +/* Disable Interrupt */ +outl (0 , dev->base_addr +DCR7 ); +outl (inl (dev->base_addr +DCR5 ), dev->base_addr +DCR5 ); + +/* Free RX buffers */ +dmfe_free_rxbuffer (db); + +/* Power down device*/ +pci_set_power_state (pci_dev,pci_choose_state (pci_dev, state)); +pci_save_state (pci_dev); + +return 0 ; +} + +static int dmfe_resume (struct pci_dev *pci_dev) +{ +struct net_device *dev =pci_get_drvdata (pci_dev); + +pci_restore_state (pci_dev); +pci_set_power_state (pci_dev,PCI_D0 ); + +/* Re-initialize DM910X board */ +dmfe_init_dm910x (dev); + +/* Restart upper layer interface */ +netif_device_attach (dev); + +return 0 ; +} +static struct pci_driver dmfe_driver = { .name ="dmfe" , .id_table = dmfe_pci_tbl, .probe = dmfe_init_one, .remove =__devexit_p (dmfe_remove_one), + .suspend = dmfe_suspend, + .resume = dmfe_resume };MODULE_AUTHOR ("Sten Wang, [email protected]" );
Re: Subject: [PATCH 2.6.20 004/005] dmfe: Add support for suspend/resume
Hi!
Quoted 4 lines
Hello , I am sorry that I missed some parts of coding style. I need to reread it :-)
There is a updated patch :
It looks better.
drivers/net/tulip/dmfe.c static struct pci_device_id dmfe_pci_tbl · line 2065
Quoted 3 lines
drivers/net/tulip/dmfe.c +3
-0+/* Disable Interrupt */ +outl (0 , dev->base_addr +DCR7 ); +outl (inl (dev->base_addr +DCR5 ), dev->base_addr +DCR5 );
I'd kill space after outl...
drivers/net/tulip/dmfe.c static struct pci_device_id dmfe_pci_tbl · line 2070
Quoted 4 lines
drivers/net/tulip/dmfe.c +4
-0+/* Free RX buffers */ +dmfe_free_rxbuffer (db); + +/* Power down device*/
and add space before */.
Congratulation, you passed coding-style-police-check ;-).
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: Subject: [PATCH 2.6.20 004/005] dmfe: Add support for suspend/resume
Quoted 21 lines · On Sunday 18 February 2007 00:52:15 Pavel Machek wrote:
Hi!
Quoted 4 lines
Hello , I am sorry that I missed some parts of coding style. I need to reread it :-)
There is a updated patch :
It looks better.
drivers/net/tulip/dmfe.c static struct pci_device_id dmfe_pci_tbl · line 2065
Quoted 3 lines
drivers/net/tulip/dmfe.c +3
-0+/* Disable Interrupt */ +outl (0 , dev->base_addr +DCR7 ); +outl (inl (dev->base_addr +DCR5 ), dev->base_addr +DCR5 );I'd kill space after outl...
drivers/net/tulip/dmfe.c static struct pci_device_id dmfe_pci_tbl · line 2070
Quoted 4 lines
drivers/net/tulip/dmfe.c +4
-0+/* Free RX buffers */ +dmfe_free_rxbuffer (db); + +/* Power down device*/ and add space before */.
Quoted 3 lines
Congratulation, you passed coding-style-police-check ;-).
Pavel
Hello,
Thanks for reply, I just want to ask one question:
Those patches are now merged in -mm, and I noticed that Andrew Morton after applying them did fix my bad coding style and check for CONFIG_PM=n that I didn't include
Now should I resend two last patches or not ?
Regards, Maxim Levitsky
PS: Actualy I have planned to send those patches a little bit later , and do more checks like the coding style stuff, mailer problems, etc... but I noticed that 2.6.20 breaks link detection on my card,
and I even saw report here on LKML about that, so I decided to send them now
Of cource I did check them for code correctness , and I actualy used them for about a month. I tried to do as little as possible changes, and verify each line.
Re: Subject: [PATCH 2.6.20 004/005] dmfe: Add support for suspend/resume
Hi!
Quoted 11 lines
Quoted 5 lines
and add space before */.
Congratulation, you passed coding-style-police-check ;-).
PavelHello,
Thanks for reply, I just want to ask one question:Those patches are now merged in -mm, and I noticed that Andrew Morton after applying them did fix my bad coding style and check for
CONFIG_PM=nthat I didn't include Now should I resend two last patches or not ?
Well, i guess you should wait for next -mm tree, and if you see some problem you fixed and akpm did not, fix it and send a incremental patch...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH RESEND v2 5/5 dmfe: add support for Wake on lan
In reply to MaximQuoted 1 line
From Maxim Levitsky <[email protected]>
Subject: [PATCH 2.6.20 005/005] [RESEND v2] dmfe: add support for Wake on lan
This patch adds support for WOL on Magic Packet and on link change
---
drivers/net/tulip/dmfe.c +64 -2
@@ -122,6 +122,11 @@#define DM9801_NOISE_FLOOR 8#define DM9802_NOISE_FLOOR 5 +#define DMFE_WOL_LINKCHANGE 0x20000000 +#define DMFE_WOL_SAMPLEPACKET 0x10000000 +#define DMFE_WOL_MAGICPACKET 0x08000000 + +#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 */
@@ -428,6 +434,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;
@@ -1062,7 +1069,11 @@ static void dmfe_set_filter_mode(structspin_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);
@@ -1076,9 +1087,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, };/*
@@ -2052,6 +2089,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);
@@ -2067,6 +2105,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);
@@ -2077,6 +2129,7 @@ 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 );
@@ -2084,6 +2137,15 @@ static int dmfe_resume (struct pci_dev */* 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);