r8169: miscalculation of available Tx descriptors
Subsystems (2)
PATCH 1/4 r8169: miscalculation of available Tx descriptors
The count of available entries in the Tx descriptors ring is badly wrong.
Signed-off-by Francois Romieu <[email protected]>
drivers/net/r8169.c renamed from drivers/net/r8169.c~r8169-130 +9 -5
@@ -77,6 +77,9 @@ VERSION 1.6LK <2004/04/14> #define dprintk(fmt, args...) do {} while (0)#endif /* RTL8169_DEBUG */ +#define TX_BUFFS_AVAIL (tp) \ + (tp->dirty_tx + NUM_TX_DESC - tp->cur_tx - 1) +#ifdef CONFIG_R8169_NAPI #define rtl8169_rx_skb netif_receive_skb#define rtl8169_rx_hwaccel_skb vlan_hwaccel_rx
@@ -1766,8 +1769,7 @@ static int rtl8169_start_xmit(struct sk_u32 status, len;u32 opts1; -if (unlikely (tp->cur_tx - tp->dirty_tx <skb_shinfo (skb)->nr_frags)) { -netif_stop_queue (dev); +if (unlikely (TX_BUFFS_AVAIL (tp) <skb_shinfo (skb)->nr_frags)) { printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n", dev->name);return 1 ;
@@ -1816,10 +1818,10 @@ static int rtl8169_start_xmit(struct sk_RTL_W8 (TxPoll,0x40 );//set polling bit -if (tp->cur_tx - tp->dirty_tx <MAX_SKB_FRAGS ) { +if (TX_BUFFS_AVAIL (tp) <MAX_SKB_FRAGS ) {netif_stop_queue (dev);smp_rmb (); -if (tp->cur_tx - tp->dirty_tx >=MAX_SKB_FRAGS ) +if (TX_BUFFS_AVAIL (tp) >=MAX_SKB_FRAGS )netif_wake_queue (dev); }
@@ -1874,8 +1876,10 @@ rtl8169_tx_interrupt(struct net_device *if (tp->dirty_tx != dirty_tx) { tp->dirty_tx = dirty_tx;smp_wmb (); -if (netif_queue_stopped (dev)) +if (netif_queue_stopped (dev) && + (TX_BUFFS_AVAIL (tp) >=MAX_SKB_FRAGS )) {netif_wake_queue (dev); + } } }
_
PATCH 2/4 r8169: hint for Tx flow control
return 1 in start_xmit() when the required descriptors are not available and wait for more room.
Signed-off-by Francois Romieu <[email protected]>
drivers/net/r8169.c renamed from drivers/net/r8169.c~r8169-140 +7 -5
@@ -1768,15 +1768,16 @@ static int rtl8169_start_xmit(struct sk_dma_addr_t mapping;u32 status, len;u32 opts1; +int ret =0 ;if (unlikely (TX_BUFFS_AVAIL (tp) <skb_shinfo (skb)->nr_frags)) { printk(KERN_ERR PFX "%s: BUG! Tx Ring full when queue awake!\n", dev->name); -return 1 ; + goto err_stop; }if (unlikely (le32_to_cpu (txd->opts1) & DescOwn)) - goto err_drop; + goto err_stop; opts1 = DescOwn |rtl8169_tx_csum (skb);
@@ -1826,10 +1827,11 @@ static int rtl8169_start_xmit(struct sk_ } out: -return 0 ; +return ret; -err_drop: -dev_kfree_skb (skb); +err_stop: +netif_stop_queue (dev); + ret =1 ; err_update_stats: tp->stats.tx_dropped++; goto out;
_
PATCH 3/4 r8169: TSO support.
TSO support. Suggestion of Jeff Garzik.
Signed-off-by Francois Romieu <[email protected]>
drivers/net/r8169.c renamed from drivers/net/r8169.c~r8169-160 +14 -3
@@ -323,6 +323,9 @@ enum _DescStatusBit { LastFrag = (1 <<28 ),/* Final segment of a packet */ /* Tx private */ + LargeSend = (1 <<27 ),/* TCP Large Send Offload (TSO) */ + MSSShift =16 ,/* MSS value position */ + MSSMask =0xfff ,/* MSS value + LargeSend bit: 12 bits */ IPCS = (1 <<18 ),/* Calculate IP checksum */ UDPCS = (1 <<17 ),/* Calculate UDP/IP checksum */ TCPCS = (1 << 16), /* Calculate TCP/IP checksum */
@@ -844,6 +847,8 @@ static struct ethtool_ops rtl8169_ethtoo .set_tx_csum = ethtool_op_set_tx_csum, .get_sg = ethtool_op_get_sg, .set_sg = ethtool_op_set_sg, + .get_tso = ethtool_op_get_tso, + .set_tso = ethtool_op_set_tso, .get_regs = rtl8169_get_regs, };
@@ -1745,8 +1750,14 @@ static int rtl8169_xmit_frags(struct rtlreturn cur_frag; } -static inline u32 rtl8169_tx_csum (struct sk_buff *skb) +static inline u32 rtl8169_tso_csum (struct sk_buff *skb,struct net_device *dev) { +if (dev->features &NETIF_F_TSO ) { +u32 mss =skb_shinfo (skb)->tso_size; + +if (mss) +return LargeSend | ((mss & MSSMask) << MSSShift); + }if (skb->ip_summed ==CHECKSUM_HW ) {const struct iphdr *ip = skb->nh.iph;
@@ -1754,7 +1765,7 @@ static inline u32 rtl8169_tx_csum(structreturn IPCS |TCPCS ; else if (ip->protocol == IPPROTO_UDP) return IPCS | UDPCS; -BUG (); +WARN_ON (1 );/* we need a WARN() */ }return 0 ; }
@@ -1779,7 +1790,7 @@ static int rtl8169_start_xmit(struct sk_if (unlikely (le32_to_cpu (txd->opts1) & DescOwn)) goto err_stop; - opts1 = DescOwn |rtl8169_tx_csum (skb); + opts1 = DescOwn |rtl8169_tso_csum (skb, dev); frags =rtl8169_xmit_frags (tp, skb, opts1);if (frags) {
_
PATCH 4/4 r8169: Mac identifier extracted from Realtek's driver v2.2
Mac identifier extracted from Realtek's driver v2.2.
Signed-off-by Francois Romieu <[email protected]>
drivers/net/r8169.c renamed from drivers/net/r8169.c~r8169-170 +3 -1
@@ -136,7 +136,8 @@ enum mac_version {RTL_GIGA_MAC_VER_B =0x00 ,/* RTL_GIGA_MAC_VER_C = 0x03, */ RTL_GIGA_MAC_VER_D =0x01 , -RTL_GIGA_MAC_VER_E =0x02 +RTL_GIGA_MAC_VER_E =0x02 , +RTL_GIGA_MAC_VER_X =0x04 /* Greater than RTL_GIGA_MAC_VER_E */ }; enum phy_version {
@@ -869,6 +870,7 @@ static void rtl8169_get_mac_version(struu32 mask;int mac_version; } mac_info[] = { + { 0x1 << 28, RTL_GIGA_MAC_VER_X }, { 0x1 << 26, RTL_GIGA_MAC_VER_E }, { 0x1 << 23, RTL_GIGA_MAC_VER_D }, { 0x00000000, RTL_GIGA_MAC_VER_B } /* Catch-all */
_