sky2 driver updates for 2.6.23
Subsystems (2)
PATCH 4/12 sky2: check for more work before leaving NAPI
In reply to Stephen HemmingerThis patch avoids generating another IRQ if more packets arrive while in the NAPI poll routine. Before marking device as finished, it rechecks that the status ring is empty.
drivers/net/sky2.c +17 -18
@@ -2477,8 +2477,7 @@ static void sky2_err_intr(struct sky2_hwstatic int sky2_poll (struct net_device *dev0,int *budget) {struct sky2_hw *hw = ((struct sky2_port *)netdev_priv (dev0))->hw; -int work_limit =min (dev0->quota, *budget); -int work_done =0 ; +int work_done;u32 status =sky2_read32 (hw,B0_Y2_SP_EISR );if (unlikely (status &Y2_IS_ERROR ))
@@ -2490,25 +2489,25 @@ static int sky2_poll(struct net_device *if (status &Y2_IS_IRQ_PHY2 )sky2_phy_intr (hw,1 ); - work_done =sky2_status_intr (hw, work_limit); -if (work_done < work_limit) { -/* Bug/Errata workaround? -* Need to kick the TX irq moderation timer. -*/ -if (sky2_read8 (hw,STAT_TX_TIMER_CTRL ) ==TIM_START ) { -sky2_write8 (hw,STAT_TX_TIMER_CTRL ,TIM_STOP ); -sky2_write8 (hw,STAT_TX_TIMER_CTRL ,TIM_START ); - } -netif_rx_complete (dev0); + work_done =sky2_status_intr (hw,min (dev0->quota, *budget)); + *budget -= work_done; + dev0->quota -= work_done; -/* end of interrupt, re-enables also acts as I/O synchronization */ -sky2_read32 (hw,B0_Y2_SP_LISR ); -return 0 ; - }else { - *budget -= work_done; - dev0->quota -= work_done; +/* More work? */ +if (hw->st_idx !=sky2_read16 (hw,STAT_PUT_IDX ))return 1 ; + +/* Bug/Errata workaround? +* Need to kick the TX irq moderation timer. +*/ +if (sky2_read8 (hw,STAT_TX_TIMER_CTRL ) ==TIM_START ) { +sky2_write8 (hw,STAT_TX_TIMER_CTRL ,TIM_STOP ); +sky2_write8 (hw,STAT_TX_TIMER_CTRL ,TIM_START ); } +netif_rx_complete (dev0); + +sky2_read32 (hw,B0_Y2_SP_LISR ); +return 0 ; }static irqreturn_t sky2_intr (int irq,void *dev_id)
Signature · 1 line
Stephen Hemminger <[email protected]>
cover sky2 driver updates for 2.6.23
Mostly small things, the first patch is a resend of the hang fix that should have been in 2.6.22, but went out too late on Friday to make it.
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 1/12 sky2: restore workarounds for lost interrupts
This patch restores a couple of workarounds from 2.6.16:
* restart transmit moderation timer in case it expires during IRQ routine
* default to having 10 HZ watchdog timer.
At this point it more important not to hang than to worry about the power cost.
drivers/net/sky2.c +8 -1
@@ -96,7 +96,7 @@ static int disable_msi = 0;module_param (disable_msi, int,0 );MODULE_PARM_DESC (disable_msi,"Disable Message Signaled Interrupt (MSI)" ); -static int idle_timeout =0 ; +static int idle_timeout =100 ;module_param (idle_timeout, int,0 );MODULE_PARM_DESC (idle_timeout,"Watchdog timer for lost interrupts (ms)" );
@@ -2490,6 +2490,13 @@ static int sky2_poll(struct net_device * work_done =sky2_status_intr (hw, work_limit);if (work_done < work_limit) { +/* Bug/Errata workaround? +* Need to kick the TX irq moderation timer. +*/ +if (sky2_read8 (hw,STAT_TX_TIMER_CTRL ) ==TIM_START ) { +sky2_write8 (hw,STAT_TX_TIMER_CTRL ,TIM_STOP ); +sky2_write8 (hw,STAT_TX_TIMER_CTRL ,TIM_START ); + }netif_rx_complete (dev0);/* end of interrupt, re-enables also acts as I/O synchronization */
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 2/12 sky2: carrier management
In reply to Stephen HemmingerMake sky2 handle carrier similar to other drivers, eliminate some possible races in carrier state transistions.
drivers/net/sky2.c +4 -7
@@ -1265,6 +1265,8 @@ static int sky2_up(struct net_device *deif (netif_msg_ifup (sky2)) printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); +netif_carrier_off (dev); +/* must be power of 2 */ sky2->tx_le = pci_alloc_consistent(hw->pdev, TX_RING_SIZE *
@@ -1616,7 +1618,6 @@ static int sky2_down(struct net_device */* Stop more packets from being queued */ netif_stop_queue (dev); -netif_carrier_off (dev);/* Disable port IRQ */ imask =sky2_read32 (hw,B0_IMSK );
@@ -1668,6 +1669,8 @@ static int sky2_down(struct net_device *sky2_phy_power (hw, port,0 ); +netif_carrier_off (dev); +/* turn off LED's */ sky2_write16 (hw,B0_Y2LED ,LED_STAT_OFF );
@@ -1732,7 +1735,6 @@ static void sky2_link_up(struct sky2_porgm_phy_write (hw, port,PHY_MARV_INT_MASK ,PHY_M_DEF_MSK );netif_carrier_on (sky2->netdev); -netif_wake_queue (sky2->netdev);/* Turn on link LED */ sky2_write8(hw, SK_REG(port, LNK_LED_REG),
@@ -1784,7 +1786,6 @@ static void sky2_link_down(struct sky2_pgma_write16 (hw, port,GM_GP_CTRL , reg);netif_carrier_off (sky2->netdev); -netif_stop_queue (sky2->netdev);/* Turn on link LED */ sky2_write8 (hw,SK_REG (port,LNK_LED_REG ),LINKLED_OFF );
@@ -3543,10 +3544,6 @@ static __devinit struct net_device *sky2memcpy_fromio (dev->dev_addr, hw->regs +B2_MAC_1 + port *8 ,ETH_ALEN );memcpy (dev->perm_addr, dev->dev_addr, dev->addr_len); -/* device is off until link detection */ -netif_carrier_off (dev); -netif_stop_queue (dev); -return dev; }
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 5/12 sky2: receive fill
In reply to Stephen HemmingerSimplify receive buffer refill logic. Rather than trying to update incrementally; do receive ring refill at end of receive processing.
drivers/net/sky2.c +14 -22
@@ -65,7 +65,6 @@#define RX_MAX_PENDING (RX_LE_SIZE/6 - 2)#define RX_DEF_PENDING RX_MAX_PENDING#define RX_SKB_ALIGN 8 -#define RX_BUF_WRITE 16#define TX_RING_SIZE 512#define TX_DEF_PENDING (TX_RING_SIZE - 1)
@@ -1138,6 +1137,11 @@ nomem:return NULL ; } +static inline void sky2_rx_update (struct sky2_port *sky2,unsigned rxq) +{ +sky2_put_idx (sky2->hw, rxq, sky2->rx_put); +} +/* * Allocate and setup receiver buffer pool. * Normal case this ends up creating one list element for skb
@@ -1229,7 +1233,7 @@ static int sky2_rx_start(struct sky2_por }/* Tell chip about available buffers */ -sky2_put_idx (hw, rxq, sky2->rx_put); +sky2_rx_update (sky2, rxq);return 0 ; nomem:sky2_rx_clean (sky2);
@@ -2147,14 +2151,14 @@ static inline void sky2_tx_done(struct n/* Process status response ring */ static int sky2_status_intr (struct sky2_hw *hw,int to_do) { -struct sky2_port *sky2;int work_done =0 ; -unsigned buf_write[2 ] = {0 ,0 }; +unsigned rx[2 ] = {0 ,0 };u16 hwidx =sky2_read16 (hw,STAT_PUT_IDX );rmb ();while (hw->st_idx != hwidx) { +struct sky2_port *sky2;struct sky2_status_le *le = hw->st_le + hw->st_idx;unsigned port = le->css &CSS_LINK_BIT ;struct net_device *dev;
@@ -2171,10 +2175,11 @@ static int sky2_status_intr(struct sky2_switch (le->opcode & ~HW_OWNER ) {case OP_RXSTAT : + ++rx[port]; skb =sky2_receive (dev, length, status);if (unlikely (!skb)) { sky2->net_stats.rx_dropped++; - goto force_update; +break ; }/* This chip reports checksum status differently */
@@ -2201,13 +2206,6 @@ static int sky2_status_intr(struct sky2_#endif netif_receive_skb (skb); -/* Update receiver after 16 frames */ -if (++buf_write[port] ==RX_BUF_WRITE ) { -force_update: -sky2_put_idx (hw, rxqaddr[port], sky2->rx_put); - buf_write[port] =0 ; - } -/* Stop after net poll weight */ if (++work_done >= to_do) goto exit_loop;
@@ -2263,24 +2261,18 @@ force_update:if (net_ratelimit ()) printk(KERN_WARNING PFX"unknown status opcode 0x%x\n" , le->opcode); - goto exit_loop; } }/* Fully processed status ring so clear irq */ sky2_write32 (hw,STAT_CTRL ,SC_STAT_CLR_IRQ ); -mmiowb (); exit_loop: -if (buf_write[0 ]) { - sky2 =netdev_priv (hw->dev[0 ]); -sky2_put_idx (hw,Q_R1 , sky2->rx_put); - } +if (rx[0 ]) +sky2_rx_update (netdev_priv (hw->dev[0 ]),Q_R1 ); -if (buf_write[1 ]) { - sky2 =netdev_priv (hw->dev[1 ]); -sky2_put_idx (hw,Q_R2 , sky2->rx_put); - } +if (rx[1 ]) +sky2_rx_update (netdev_priv (hw->dev[1 ]),Q_R2 );return work_done; }
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 8/12 sky2: check drop truncated packets
In reply to Stephen HemmingerIf packet larger than MTU is received, the driver uses hardware to truncate the packet. Use the status registers to catch/drop them.
drivers/net/sky2.c +8 -0
@@ -2109,6 +2109,9 @@ static struct sk_buff *sky2_receive(struif (!(status &GMR_FS_RX_OK )) goto resubmit; +if (status >>16 != length) + goto len_mismatch; +if (length < copybreak) skb =receive_copy (sky2, re, length);else
@@ -2118,6 +2121,11 @@ resubmit:return skb; +len_mismatch: +/* Truncation of overlength packets +causes PHY length to not match MAC length */ + ++sky2->net_stats.rx_length_errors; + error: ++sky2->net_stats.rx_errors;if (status &GMR_FS_RX_FF_OV ) {
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 9/12 sky2: use roundup() macro
In reply to Stephen HemmingerUse roundup() macro to size receive buffer.
drivers/net/sky2.c +1 -2
@@ -1180,8 +1180,7 @@ static int sky2_rx_start(struct sky2_porrx_set_checksum (sky2);/* Space needed for frame data + headers rounded up */ - size =ALIGN (sky2->netdev->mtu +ETH_HLEN +VLAN_HLEN ,8 ) - +8 ; + size =roundup (sky2->netdev->mtu +ETH_HLEN +VLAN_HLEN ,8 );/* Stopping point for hardware truncation */ thresh = (size -8 ) /sizeof (u32);
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 3/12 sky2: debug interface
In reply to Stephen HemmingerAdd an optional debug interface for displaying state of transmit/receive rings. Creates a file debugfs/sky2/ethX for each device that is up.
--- drivers/net/Kconfig | 10 ++ drivers/net/sky2.c | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++- drivers/net/sky2.h | 4 + 3 files changed, 188 insertions(+), 2 deletions(-)
drivers/net/Kconfig +10 -0
@@ -2133,6 +2133,16 @@ config SKY2 To compile this driver as a module, choose M here: the module will be called sky2. This is recommended. +config SKY2_DEBUG + bool "Debugging interface" + depends on SKY2 && DEBUG_FS + help + This option adds the ability to dump driver state for debugging. + The file debugfs/sky2/ethX displays the state of the internal + transmit and receive rings. + + If unsure, say N. + config SK98LIN tristate "Marvell Yukon Chipset / SysKonnect SK-98xx Support (DEPRECATED)" depends on PCI
drivers/net/sky2.c +194 -2
231 lines not on this page · raw message
drivers/net/sky2.h +4 -0
@@ -1998,6 +1998,7 @@ struct sky2_port {struct sky2_tx_le *tx_le;u16 tx_cons;/* next le to check */ u16 tx_prod;/* next le to use */ +u16 tx_next;/* debug only */ u32 tx_addr64;u16 tx_pending;u16 tx_last_mss;
@@ -2028,6 +2029,9 @@ struct sky2_port {enum flow_control flow_mode;enum flow_control flow_status; +#ifdef CONFIG_SKY2_DEBUG +struct dentry *debugfs; +#endif struct net_device_stats net_stats; };
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 7/12 sky2: add support for read/write of EEPROM
In reply to Stephen HemmingerAdd get/set eeprom support for sky2.
--- drivers/net/sky2.c | 140 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 115 insertions(+), 25 deletions(-)
drivers/net/sky2.c +115 -25
@@ -77,6 +77,9 @@#define NAPI_WEIGHT 64#define PHY_RETRIES 1000 +#define SKY2_EEPROM_MAGIC 0x9955aabb + +#define RING_NEXT (x,s) (((x)+1) & ((s)-1)) static const u32 default_msg =
@@ -3429,34 +3432,121 @@ static int sky2_set_tso(struct net_devicreturn ethtool_op_set_tso (dev, data); } +static int sky2_get_eeprom_len (struct net_device *dev) +{ +struct sky2_port *sky2 =netdev_priv (dev); +u16 reg2; + + reg2 =sky2_pci_read32 (sky2->hw,PCI_DEV_REG2 ); +return 1 << ( ((reg2 &PCI_VPD_ROM_SZ ) >>14 ) +8 ); +} + +static u32 sky2_vpd_read (struct sky2_hw *hw,int cap,u16 offset) +{ +sky2_pci_write16 (hw, cap +PCI_VPD_ADDR , offset); + +while (!(sky2_pci_read16 (hw, cap +PCI_VPD_ADDR ) &PCI_VPD_ADDR_F )) +cpu_relax (); +return sky2_pci_read32 (hw, cap +PCI_VPD_DATA ); +} + +static void sky2_vpd_write (struct sky2_hw *hw,int cap,u16 offset,u32 val) +{ +sky2_pci_write32 (hw, cap +PCI_VPD_DATA , val); +sky2_pci_write16 (hw, cap +PCI_VPD_ADDR , offset |PCI_VPD_ADDR_F ); +do { +cpu_relax (); + }while (sky2_pci_read16 (hw, cap +PCI_VPD_ADDR ) &PCI_VPD_ADDR_F ); +} + +static int sky2_get_eeprom (struct net_device *dev,struct ethtool_eeprom *eeprom, +u8 *data) +{ +struct sky2_port *sky2 =netdev_priv (dev); +int cap =pci_find_capability (sky2->hw->pdev,PCI_CAP_ID_VPD ); +int length = eeprom->len; +u16 offset = eeprom->offset; + +if (!cap) +return -EINVAL ; + + eeprom->magic =SKY2_EEPROM_MAGIC ; + +while (length >0 ) { +u32 val =sky2_vpd_read (sky2->hw, cap, offset); +int n =min_t (int, length,sizeof (val)); + +memcpy (data, &val, n); + length -= n; + data += n; + offset += n; + } +return 0 ; +} + +static int sky2_set_eeprom (struct net_device *dev,struct ethtool_eeprom *eeprom, +u8 *data) +{ +struct sky2_port *sky2 =netdev_priv (dev); +int cap =pci_find_capability (sky2->hw->pdev,PCI_CAP_ID_VPD ); +int length = eeprom->len; +u16 offset = eeprom->offset; + +if (!cap) +return -EINVAL ; + +if (eeprom->magic !=SKY2_EEPROM_MAGIC ) +return -EINVAL ; + +while (length >0 ) { +u32 val; +int n =min_t (int, length,sizeof (val)); + +if (n <sizeof (val)) + val =sky2_vpd_read (sky2->hw, cap, offset); +memcpy (&val, data, n); + +sky2_vpd_write (sky2->hw, cap, offset, val); + + length -= n; + data += n; + offset += n; + } +return 0 ; +} + +static const struct ethtool_ops sky2_ethtool_ops = { - .get_settings = sky2_get_settings, - .set_settings = sky2_set_settings, - .get_drvinfo = sky2_get_drvinfo, - .get_wol = sky2_get_wol, - .set_wol = sky2_set_wol, - .get_msglevel = sky2_get_msglevel, - .set_msglevel = sky2_set_msglevel, - .nway_reset = sky2_nway_reset, - .get_regs_len = sky2_get_regs_len, - .get_regs = sky2_get_regs, - .get_link = ethtool_op_get_link, - .get_sg = ethtool_op_get_sg, - .set_sg = ethtool_op_set_sg, - .get_tx_csum = ethtool_op_get_tx_csum, - .set_tx_csum = sky2_set_tx_csum, - .get_tso = ethtool_op_get_tso, - .set_tso = sky2_set_tso, - .get_rx_csum = sky2_get_rx_csum, - .set_rx_csum = sky2_set_rx_csum, - .get_strings = sky2_get_strings, - .get_coalesce = sky2_get_coalesce, - .set_coalesce = sky2_set_coalesce, - .get_ringparam = sky2_get_ringparam, - .set_ringparam = sky2_set_ringparam, + .get_settings = sky2_get_settings, + .set_settings = sky2_set_settings, + .get_drvinfo = sky2_get_drvinfo, + .get_wol = sky2_get_wol, + .set_wol = sky2_set_wol, + .get_msglevel = sky2_get_msglevel, + .set_msglevel = sky2_set_msglevel, + .nway_reset = sky2_nway_reset, + .get_regs_len = sky2_get_regs_len, + .get_regs = sky2_get_regs, + .get_link = ethtool_op_get_link, + .get_eeprom_len = sky2_get_eeprom_len, + .get_eeprom = sky2_get_eeprom, + .set_eeprom = sky2_set_eeprom, + .get_sg = ethtool_op_get_sg, + .set_sg = ethtool_op_set_sg, + .get_tx_csum = ethtool_op_get_tx_csum, + .set_tx_csum = sky2_set_tx_csum, + .get_tso = ethtool_op_get_tso, + .set_tso = sky2_set_tso, + .get_rx_csum = sky2_get_rx_csum, + .set_rx_csum = sky2_set_rx_csum, + .get_strings = sky2_get_strings, + .get_coalesce = sky2_get_coalesce, + .set_coalesce = sky2_set_coalesce, + .get_ringparam = sky2_get_ringparam, + .set_ringparam = sky2_set_ringparam, .get_pauseparam = sky2_get_pauseparam, .set_pauseparam = sky2_set_pauseparam, - .phys_id = sky2_phys_id, + .phys_id = sky2_phys_id, .get_stats_count = sky2_get_stats_count, .get_ethtool_stats = sky2_get_ethtool_stats, .get_perm_addr = ethtool_op_get_perm_addr,
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 6/12 sky2: unmark as EXPERIMENTAL
In reply to Stephen Hemmingerdrivers/net/Kconfig +1 -1
@@ -2118,7 +2118,7 @@ config SKGE will be called skge. This is recommended. config SKY2 - tristate "SysKonnect Yukon2 support (EXPERIMENTAL)" + tristate "SysKonnect Yukon2 support" depends on PCI select CRC32 ---help---
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 12/12 sky2: 1.16 version
In reply to Stephen Hemmingerdrivers/net/sky2.c +1 -1
@@ -51,7 +51,7 @@#include "sky2.h" #define DRV_NAME "sky2" -#define DRV_VERSION "1.15" +#define DRV_VERSION "1.16"#define PFX DRV_NAME " "/*
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 11/12 sky2: remove some leftover debug messages
In reply to Stephen HemmingerEliminate extra debug messages
--- drivers/net/sky2.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/sky2.c +0 -4
@@ -2058,8 +2058,6 @@ static struct sk_buff *receive_new(strucstruct sk_buff *skb, *nskb;unsigned hdr_space = sky2->rx_data_size; -pr_debug (PFX "receive new length=%d\n" , length); -/* Don't be tricky about reusing pages (yet) */ nskb =sky2_rx_alloc (sky2);if (unlikely (!nskb))
@@ -2728,8 +2726,6 @@ static void sky2_restart(struct work_strstruct net_device *dev;int i, err; -dev_dbg (&hw->pdev->dev,"restarting\n" ); -del_timer_sync (&hw->idle_timer);rtnl_lock ();
Signature · 1 line
Stephen Hemminger <[email protected]>
PATCH 10/12 sky2: use upper_32_bits() macro
In reply to Stephen HemmingerUse upper_32_bits() inline
drivers/net/sky2.c +7 -12
@@ -893,24 +893,18 @@ static inline struct sky2_rx_le *sky2_nereturn le; } -/* Return high part of DMA address (could be 32 or 64 bit) */ -static inline u32 high32 (dma_addr_t a) -{ -return sizeof (a) >sizeof (u32) ? (a >>16 ) >>16 :0 ; -} -/* Build description to hardware for one receive segment */ static void sky2_rx_add (struct sky2_port *sky2,u8 op,dma_addr_t map,unsigned len) {struct sky2_rx_le *le; -u32 hi =high32 (map); +u32 hi =upper_32_bits (map);if (sky2->rx_addr64 != hi) { le =sky2_next_rx (sky2); le->addr =cpu_to_le32 (hi); le->opcode =OP_ADDR64 |HW_OWNER ; - sky2->rx_addr64 =high32 (map + len); + sky2->rx_addr64 =upper_32_bits (map + len); } le =sky2_next_rx (sky2);
@@ -1424,14 +1418,15 @@ static int sky2_xmit_frame(struct sk_buf len =skb_headlen (skb); mapping =pci_map_single (hw->pdev, skb->data, len,PCI_DMA_TODEVICE ); - addr64 =high32 (mapping); + addr64 =upper_32_bits (mapping);/* Send high bits if changed or crosses boundary */ -if (addr64 != sky2->tx_addr64 ||high32 (mapping + len) != sky2->tx_addr64) { +if (addr64 != sky2->tx_addr64 || +upper_32_bits (mapping + len) != sky2->tx_addr64) { le =get_tx_le (sky2); le->addr =cpu_to_le32 (addr64); le->opcode =OP_ADDR64 |HW_OWNER ; - sky2->tx_addr64 =high32 (mapping + len); + sky2->tx_addr64 =upper_32_bits (mapping + len); }/* Check for TCP Segmentation Offload */
@@ -1511,7 +1506,7 @@ static int sky2_xmit_frame(struct sk_buf mapping =pci_map_page (hw->pdev, frag->page, frag->page_offset, frag->size,PCI_DMA_TODEVICE ); - addr64 =high32 (mapping); + addr64 =upper_32_bits (mapping);if (addr64 != sky2->tx_addr64) { le =get_tx_le (sky2); le->addr =cpu_to_le32 (addr64);
Signature · 1 line
Stephen Hemminger <[email protected]>
Re: [PATCH 01/12] sky2: restore workarounds for lost interrupts
In reply to Stephen HemmingerQuoted 7 lines · Stephen Hemminger
This patch restores a couple of workarounds from 2.6.16:
* restart transmit moderation timer in case it expires during IRQ routine
* default to having 10 HZ watchdog timer.
At this point it more important not to hang than to worry about the power cost.Signed-off-by Stephen Hemminger <[email protected]>
applied 1-12