7575#define R8169_TX_RING_BYTES (NUM_TX_DESC * sizeof(struct TxDesc))
7676#define R8169_RX_RING_BYTES (NUM_RX_DESC * sizeof(struct RxDesc))
7777
78+ #define OCP_STD_PHY_BASE 0xa400
79+
7880#define RTL_CFG_NO_GBIT 1
7981
8082/* write/read MMIO register */
@@ -847,8 +849,6 @@ static void r8168_mac_ocp_modify(struct rtl8169_private *tp, u32 reg, u16 mask,
847849 r8168_mac_ocp_write (tp , reg , (data & ~mask ) | set );
848850}
849851
850- #define OCP_STD_PHY_BASE 0xa400
851-
852852static void r8168g_mdio_write (struct rtl8169_private * tp , int reg , int value )
853853{
854854 if (reg == 0x1f ) {
@@ -2397,6 +2397,8 @@ static void rtl_pll_power_up(struct rtl8169_private *tp)
23972397
23982398static void rtl_init_rxcfg (struct rtl8169_private * tp )
23992399{
2400+ u32 vlan ;
2401+
24002402 switch (tp -> mac_version ) {
24012403 case RTL_GIGA_MAC_VER_02 ... RTL_GIGA_MAC_VER_06 :
24022404 case RTL_GIGA_MAC_VER_10 ... RTL_GIGA_MAC_VER_17 :
@@ -2411,8 +2413,9 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp)
24112413 RTL_W32 (tp , RxConfig , RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF );
24122414 break ;
24132415 case RTL_GIGA_MAC_VER_60 ... RTL_GIGA_MAC_VER_61 :
2414- RTL_W32 (tp , RxConfig , RX_FETCH_DFLT_8125 | RX_VLAN_8125 |
2415- RX_DMA_BURST );
2416+ /* VLAN flags are controlled by NETIF_F_HW_VLAN_CTAG_RX */
2417+ vlan = RTL_R32 (tp , RxConfig ) & RX_VLAN_8125 ;
2418+ RTL_W32 (tp , RxConfig , vlan | RX_FETCH_DFLT_8125 | RX_DMA_BURST );
24162419 break ;
24172420 default :
24182421 RTL_W32 (tp , RxConfig , RX128_INT_EN | RX_DMA_BURST );
@@ -4124,25 +4127,20 @@ static bool rtl8169_tso_csum_v2(struct rtl8169_private *tp,
41244127 struct sk_buff * skb , u32 * opts )
41254128{
41264129 u32 transport_offset = (u32 )skb_transport_offset (skb );
4127- u32 mss = skb_shinfo (skb )-> gso_size ;
4130+ struct skb_shared_info * shinfo = skb_shinfo (skb );
4131+ u32 mss = shinfo -> gso_size ;
41284132
41294133 if (mss ) {
4130- switch (vlan_get_protocol (skb )) {
4131- case htons (ETH_P_IP ):
4134+ if (shinfo -> gso_type & SKB_GSO_TCPV4 ) {
41324135 opts [0 ] |= TD1_GTSENV4 ;
4133- break ;
4134-
4135- case htons (ETH_P_IPV6 ):
4136+ } else if (shinfo -> gso_type & SKB_GSO_TCPV6 ) {
41364137 if (skb_cow_head (skb , 0 ))
41374138 return false;
41384139
41394140 tcp_v6_gso_csum_prep (skb );
41404141 opts [0 ] |= TD1_GTSENV6 ;
4141- break ;
4142-
4143- default :
4142+ } else {
41444143 WARN_ON_ONCE (1 );
4145- break ;
41464144 }
41474145
41484146 opts [0 ] |= transport_offset << GTTCPHO_SHIFT ;
@@ -4308,6 +4306,37 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
43084306 return NETDEV_TX_BUSY ;
43094307}
43104308
4309+ static unsigned int rtl_last_frag_len (struct sk_buff * skb )
4310+ {
4311+ struct skb_shared_info * info = skb_shinfo (skb );
4312+ unsigned int nr_frags = info -> nr_frags ;
4313+
4314+ if (!nr_frags )
4315+ return UINT_MAX ;
4316+
4317+ return skb_frag_size (info -> frags + nr_frags - 1 );
4318+ }
4319+
4320+ /* Workaround for hw issues with TSO on RTL8168evl */
4321+ static netdev_features_t rtl8168evl_fix_tso (struct sk_buff * skb ,
4322+ netdev_features_t features )
4323+ {
4324+ /* IPv4 header has options field */
4325+ if (vlan_get_protocol (skb ) == htons (ETH_P_IP ) &&
4326+ ip_hdrlen (skb ) > sizeof (struct iphdr ))
4327+ features &= ~NETIF_F_ALL_TSO ;
4328+
4329+ /* IPv4 TCP header has options field */
4330+ else if (skb_shinfo (skb )-> gso_type & SKB_GSO_TCPV4 &&
4331+ tcp_hdrlen (skb ) > sizeof (struct tcphdr ))
4332+ features &= ~NETIF_F_ALL_TSO ;
4333+
4334+ else if (rtl_last_frag_len (skb ) <= 6 )
4335+ features &= ~NETIF_F_ALL_TSO ;
4336+
4337+ return features ;
4338+ }
4339+
43114340static netdev_features_t rtl8169_features_check (struct sk_buff * skb ,
43124341 struct net_device * dev ,
43134342 netdev_features_t features )
@@ -4316,6 +4345,9 @@ static netdev_features_t rtl8169_features_check(struct sk_buff *skb,
43164345 struct rtl8169_private * tp = netdev_priv (dev );
43174346
43184347 if (skb_is_gso (skb )) {
4348+ if (tp -> mac_version == RTL_GIGA_MAC_VER_34 )
4349+ features = rtl8168evl_fix_tso (skb , features );
4350+
43194351 if (transport_offset > GTTCPHO_MAX &&
43204352 rtl_chip_supports_csum_v2 (tp ))
43214353 features &= ~NETIF_F_ALL_TSO ;
@@ -5189,8 +5221,6 @@ static int r8169_mdio_register(struct rtl8169_private *tp)
51895221
51905222static void rtl_hw_init_8168g (struct rtl8169_private * tp )
51915223{
5192- tp -> ocp_base = OCP_STD_PHY_BASE ;
5193-
51945224 RTL_W32 (tp , MISC , RTL_R32 (tp , MISC ) | RXDV_GATED_EN );
51955225
51965226 if (!rtl_udelay_loop_wait_high (tp , & rtl_txcfg_empty_cond , 100 , 42 ))
@@ -5215,8 +5245,6 @@ static void rtl_hw_init_8168g(struct rtl8169_private *tp)
52155245
52165246static void rtl_hw_init_8125 (struct rtl8169_private * tp )
52175247{
5218- tp -> ocp_base = OCP_STD_PHY_BASE ;
5219-
52205248 RTL_W32 (tp , MISC , RTL_R32 (tp , MISC ) | RXDV_GATED_EN );
52215249
52225250 if (!rtl_udelay_loop_wait_high (tp , & rtl_rxtx_empty_cond , 100 , 42 ))
@@ -5353,6 +5381,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
53535381 tp -> msg_enable = netif_msg_init (debug .msg_enable , R8169_MSG_DEFAULT );
53545382 tp -> supports_gmii = ent -> driver_data == RTL_CFG_NO_GBIT ? 0 : 1 ;
53555383 tp -> eee_adv = -1 ;
5384+ tp -> ocp_base = OCP_STD_PHY_BASE ;
53565385
53575386 /* Get the *optional* external "ether_clk" used on some boards */
53585387 rc = rtl_get_ether_clk (tp );
@@ -5443,14 +5472,9 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
54435472
54445473 dev -> hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM |
54455474 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX ;
5446- dev -> vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO |
5447- NETIF_F_HIGHDMA ;
5475+ dev -> vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO ;
54485476 dev -> priv_flags |= IFF_LIVE_ADDR_CHANGE ;
54495477
5450- tp -> cp_cmd |= RxChkSum ;
5451- /* RTL8125 uses register RxConfig for VLAN offloading config */
5452- if (!rtl_is_8125 (tp ))
5453- tp -> cp_cmd |= RxVlan ;
54545478 /*
54555479 * Pretend we are using VLANs; This bypasses a nasty bug where
54565480 * Interrupts stop flowing on high load on 8110SCd controllers.
@@ -5482,6 +5506,9 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
54825506 dev -> hw_features |= NETIF_F_RXALL ;
54835507 dev -> hw_features |= NETIF_F_RXFCS ;
54845508
5509+ /* configure chip for default features */
5510+ rtl8169_set_features (dev , dev -> features );
5511+
54855512 jumbo_max = rtl_jumbo_max (tp );
54865513 if (jumbo_max )
54875514 dev -> max_mtu = jumbo_max ;
0 commit comments