@@ -599,6 +599,7 @@ enum rtl_register_content {
599
599
RxChkSum = (1 << 5 ),
600
600
PCIDAC = (1 << 4 ),
601
601
PCIMulRW = (1 << 3 ),
602
+ #define INTT_MASK GENMASK(1, 0)
602
603
INTT_0 = 0x0000 , // 8168
603
604
INTT_1 = 0x0001 , // 8168
604
605
INTT_2 = 0x0002 , // 8168
@@ -689,6 +690,7 @@ enum rtl_rx_desc_bit {
689
690
};
690
691
691
692
#define RsvdMask 0x3fffc000
693
+ #define CPCMD_QUIRK_MASK (Normal_mode | RxVlan | RxChkSum | INTT_MASK)
692
694
693
695
struct TxDesc {
694
696
__le32 opts1 ;
@@ -1935,12 +1937,14 @@ static netdev_features_t rtl8169_fix_features(struct net_device *dev,
1935
1937
return features ;
1936
1938
}
1937
1939
1938
- static void __rtl8169_set_features (struct net_device * dev ,
1939
- netdev_features_t features )
1940
+ static int rtl8169_set_features (struct net_device * dev ,
1941
+ netdev_features_t features )
1940
1942
{
1941
1943
struct rtl8169_private * tp = netdev_priv (dev );
1942
1944
u32 rx_config ;
1943
1945
1946
+ rtl_lock_work (tp );
1947
+
1944
1948
rx_config = RTL_R32 (tp , RxConfig );
1945
1949
if (features & NETIF_F_RXALL )
1946
1950
rx_config |= (AcceptErr | AcceptRunt );
@@ -1959,28 +1963,14 @@ static void __rtl8169_set_features(struct net_device *dev,
1959
1963
else
1960
1964
tp -> cp_cmd &= ~RxVlan ;
1961
1965
1962
- tp -> cp_cmd |= RTL_R16 (tp , CPlusCmd ) & ~(RxVlan | RxChkSum );
1963
-
1964
1966
RTL_W16 (tp , CPlusCmd , tp -> cp_cmd );
1965
1967
RTL_R16 (tp , CPlusCmd );
1966
- }
1967
1968
1968
- static int rtl8169_set_features (struct net_device * dev ,
1969
- netdev_features_t features )
1970
- {
1971
- struct rtl8169_private * tp = netdev_priv (dev );
1972
-
1973
- features &= NETIF_F_RXALL | NETIF_F_RXCSUM | NETIF_F_HW_VLAN_CTAG_RX ;
1974
-
1975
- rtl_lock_work (tp );
1976
- if (features ^ dev -> features )
1977
- __rtl8169_set_features (dev , features );
1978
1969
rtl_unlock_work (tp );
1979
1970
1980
1971
return 0 ;
1981
1972
}
1982
1973
1983
-
1984
1974
static inline u32 rtl8169_tx_vlan_tag (struct sk_buff * skb )
1985
1975
{
1986
1976
return (skb_vlan_tag_present (skb )) ?
@@ -2354,7 +2344,7 @@ static int rtl_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
2354
2344
if (IS_ERR (ci ))
2355
2345
return PTR_ERR (ci );
2356
2346
2357
- scale = & ci -> scalev [RTL_R16 ( tp , CPlusCmd ) & 3 ];
2347
+ scale = & ci -> scalev [tp -> cp_cmd & INTT_MASK ];
2358
2348
2359
2349
/* read IntrMitigate and adjust according to scale */
2360
2350
for (w = RTL_R16 (tp , IntrMitigate ); w ; w >>= RTL_COALESCE_SHIFT , p ++ ) {
@@ -2453,7 +2443,7 @@ static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec)
2453
2443
2454
2444
RTL_W16 (tp , IntrMitigate , swab16 (w ));
2455
2445
2456
- tp -> cp_cmd = (tp -> cp_cmd & ~3 ) | cp01 ;
2446
+ tp -> cp_cmd = (tp -> cp_cmd & ~INTT_MASK ) | cp01 ;
2457
2447
RTL_W16 (tp , CPlusCmd , tp -> cp_cmd );
2458
2448
RTL_R16 (tp , CPlusCmd );
2459
2449
@@ -4850,7 +4840,7 @@ static void r8168_pll_power_down(struct rtl8169_private *tp)
4850
4840
4851
4841
if ((tp -> mac_version == RTL_GIGA_MAC_VER_23 ||
4852
4842
tp -> mac_version == RTL_GIGA_MAC_VER_24 ) &&
4853
- (RTL_R16 ( tp , CPlusCmd ) & ASF )) {
4843
+ (tp -> cp_cmd & ASF )) {
4854
4844
return ;
4855
4845
}
4856
4846
@@ -5311,10 +5301,10 @@ static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp)
5311
5301
(InterFrameGap << TxInterFrameGapShift ));
5312
5302
}
5313
5303
5314
- static void rtl_hw_start (struct rtl8169_private * tp )
5304
+ static void rtl_set_rx_max_size (struct rtl8169_private * tp )
5315
5305
{
5316
- tp -> hw_start ( tp );
5317
- rtl_irq_enable_all (tp );
5306
+ /* Low hurts. Let's disable the filtering. */
5307
+ RTL_W16 (tp , RxMaxSize , R8169_RX_BUF_SIZE + 1 );
5318
5308
}
5319
5309
5320
5310
static void rtl_set_rx_tx_desc_registers (struct rtl8169_private * tp )
@@ -5330,19 +5320,23 @@ static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp)
5330
5320
RTL_W32 (tp , RxDescAddrLow , ((u64 ) tp -> RxPhyAddr ) & DMA_BIT_MASK (32 ));
5331
5321
}
5332
5322
5333
- static u16 rtl_rw_cpluscmd (struct rtl8169_private * tp )
5323
+ static void rtl_hw_start (struct rtl8169_private * tp )
5334
5324
{
5335
- u16 cmd ;
5325
+ RTL_W8 ( tp , Cfg9346 , Cfg9346_Unlock ) ;
5336
5326
5337
- cmd = RTL_R16 (tp , CPlusCmd );
5338
- RTL_W16 (tp , CPlusCmd , cmd );
5339
- return cmd ;
5340
- }
5327
+ tp -> hw_start (tp );
5341
5328
5342
- static void rtl_set_rx_max_size (struct rtl8169_private * tp )
5343
- {
5344
- /* Low hurts. Let's disable the filtering. */
5345
- RTL_W16 (tp , RxMaxSize , R8169_RX_BUF_SIZE + 1 );
5329
+ rtl_set_rx_max_size (tp );
5330
+ rtl_set_rx_tx_desc_registers (tp );
5331
+ rtl_set_rx_tx_config_registers (tp );
5332
+ RTL_W8 (tp , Cfg9346 , Cfg9346_Lock );
5333
+
5334
+ /* Initially a 10 us delay. Turned it into a PCI commit. - FR */
5335
+ RTL_R8 (tp , IntrMask );
5336
+ RTL_W8 (tp , ChipCmd , CmdTxEnb | CmdRxEnb );
5337
+ /* no early-rx interrupts */
5338
+ RTL_W16 (tp , MultiIntr , RTL_R16 (tp , MultiIntr ) & 0xf000 );
5339
+ rtl_irq_enable_all (tp );
5346
5340
}
5347
5341
5348
5342
static void rtl8169_set_magic_reg (struct rtl8169_private * tp , unsigned mac_version )
@@ -5424,31 +5418,12 @@ static void rtl_set_rx_mode(struct net_device *dev)
5424
5418
5425
5419
static void rtl_hw_start_8169 (struct rtl8169_private * tp )
5426
5420
{
5427
- if (tp -> mac_version == RTL_GIGA_MAC_VER_05 ) {
5428
- RTL_W16 (tp , CPlusCmd , RTL_R16 (tp , CPlusCmd ) | PCIMulRW );
5421
+ if (tp -> mac_version == RTL_GIGA_MAC_VER_05 )
5429
5422
pci_write_config_byte (tp -> pci_dev , PCI_CACHE_LINE_SIZE , 0x08 );
5430
- }
5431
-
5432
- RTL_W8 (tp , Cfg9346 , Cfg9346_Unlock );
5433
- if (tp -> mac_version == RTL_GIGA_MAC_VER_01 ||
5434
- tp -> mac_version == RTL_GIGA_MAC_VER_02 ||
5435
- tp -> mac_version == RTL_GIGA_MAC_VER_03 ||
5436
- tp -> mac_version == RTL_GIGA_MAC_VER_04 )
5437
- RTL_W8 (tp , ChipCmd , CmdTxEnb | CmdRxEnb );
5438
-
5439
- rtl_init_rxcfg (tp );
5440
5423
5441
5424
RTL_W8 (tp , EarlyTxThres , NoEarlyTx );
5442
5425
5443
- rtl_set_rx_max_size (tp );
5444
-
5445
- if (tp -> mac_version == RTL_GIGA_MAC_VER_01 ||
5446
- tp -> mac_version == RTL_GIGA_MAC_VER_02 ||
5447
- tp -> mac_version == RTL_GIGA_MAC_VER_03 ||
5448
- tp -> mac_version == RTL_GIGA_MAC_VER_04 )
5449
- rtl_set_rx_tx_config_registers (tp );
5450
-
5451
- tp -> cp_cmd |= rtl_rw_cpluscmd (tp ) | PCIMulRW ;
5426
+ tp -> cp_cmd |= PCIMulRW ;
5452
5427
5453
5428
if (tp -> mac_version == RTL_GIGA_MAC_VER_02 ||
5454
5429
tp -> mac_version == RTL_GIGA_MAC_VER_03 ) {
@@ -5467,27 +5442,7 @@ static void rtl_hw_start_8169(struct rtl8169_private *tp)
5467
5442
*/
5468
5443
RTL_W16 (tp , IntrMitigate , 0x0000 );
5469
5444
5470
- rtl_set_rx_tx_desc_registers (tp );
5471
-
5472
- if (tp -> mac_version != RTL_GIGA_MAC_VER_01 &&
5473
- tp -> mac_version != RTL_GIGA_MAC_VER_02 &&
5474
- tp -> mac_version != RTL_GIGA_MAC_VER_03 &&
5475
- tp -> mac_version != RTL_GIGA_MAC_VER_04 ) {
5476
- RTL_W8 (tp , ChipCmd , CmdTxEnb | CmdRxEnb );
5477
- rtl_set_rx_tx_config_registers (tp );
5478
- }
5479
-
5480
- RTL_W8 (tp , Cfg9346 , Cfg9346_Lock );
5481
-
5482
- /* Initially a 10 us delay. Turned it into a PCI commit. - FR */
5483
- RTL_R8 (tp , IntrMask );
5484
-
5485
5445
RTL_W32 (tp , RxMissed , 0 );
5486
-
5487
- rtl_set_rx_mode (tp -> dev );
5488
-
5489
- /* no early-rx interrupts */
5490
- RTL_W16 (tp , MultiIntr , RTL_R16 (tp , MultiIntr ) & 0xf000 );
5491
5446
}
5492
5447
5493
5448
static void rtl_csi_write (struct rtl8169_private * tp , int addr , int value )
@@ -5665,22 +5620,12 @@ static void rtl_pcie_state_l2l3_enable(struct rtl8169_private *tp, bool enable)
5665
5620
RTL_W8 (tp , Config3 , data );
5666
5621
}
5667
5622
5668
- #define R8168_CPCMD_QUIRK_MASK (\
5669
- EnableBist | \
5670
- Mac_dbgo_oe | \
5671
- Force_half_dup | \
5672
- Force_rxflow_en | \
5673
- Force_txflow_en | \
5674
- Cxpl_dbg_sel | \
5675
- ASF | \
5676
- PktCntrDisable | \
5677
- Mac_dbgo_sel)
5678
-
5679
5623
static void rtl_hw_start_8168bb (struct rtl8169_private * tp )
5680
5624
{
5681
5625
RTL_W8 (tp , Config3 , RTL_R8 (tp , Config3 ) & ~Beacon_en );
5682
5626
5683
- RTL_W16 (tp , CPlusCmd , RTL_R16 (tp , CPlusCmd ) & ~R8168_CPCMD_QUIRK_MASK );
5627
+ tp -> cp_cmd &= CPCMD_QUIRK_MASK ;
5628
+ RTL_W16 (tp , CPlusCmd , tp -> cp_cmd );
5684
5629
5685
5630
if (tp -> dev -> mtu <= ETH_DATA_LEN ) {
5686
5631
rtl_tx_performance_tweak (tp , PCI_EXP_DEVCTL_READRQ_4096B |
@@ -5708,7 +5653,8 @@ static void __rtl_hw_start_8168cp(struct rtl8169_private *tp)
5708
5653
5709
5654
rtl_disable_clock_request (tp );
5710
5655
5711
- RTL_W16 (tp , CPlusCmd , RTL_R16 (tp , CPlusCmd ) & ~R8168_CPCMD_QUIRK_MASK );
5656
+ tp -> cp_cmd &= CPCMD_QUIRK_MASK ;
5657
+ RTL_W16 (tp , CPlusCmd , tp -> cp_cmd );
5712
5658
}
5713
5659
5714
5660
static void rtl_hw_start_8168cp_1 (struct rtl8169_private * tp )
@@ -5737,7 +5683,8 @@ static void rtl_hw_start_8168cp_2(struct rtl8169_private *tp)
5737
5683
if (tp -> dev -> mtu <= ETH_DATA_LEN )
5738
5684
rtl_tx_performance_tweak (tp , PCI_EXP_DEVCTL_READRQ_4096B );
5739
5685
5740
- RTL_W16 (tp , CPlusCmd , RTL_R16 (tp , CPlusCmd ) & ~R8168_CPCMD_QUIRK_MASK );
5686
+ tp -> cp_cmd &= CPCMD_QUIRK_MASK ;
5687
+ RTL_W16 (tp , CPlusCmd , tp -> cp_cmd );
5741
5688
}
5742
5689
5743
5690
static void rtl_hw_start_8168cp_3 (struct rtl8169_private * tp )
@@ -5754,7 +5701,8 @@ static void rtl_hw_start_8168cp_3(struct rtl8169_private *tp)
5754
5701
if (tp -> dev -> mtu <= ETH_DATA_LEN )
5755
5702
rtl_tx_performance_tweak (tp , PCI_EXP_DEVCTL_READRQ_4096B );
5756
5703
5757
- RTL_W16 (tp , CPlusCmd , RTL_R16 (tp , CPlusCmd ) & ~R8168_CPCMD_QUIRK_MASK );
5704
+ tp -> cp_cmd &= CPCMD_QUIRK_MASK ;
5705
+ RTL_W16 (tp , CPlusCmd , tp -> cp_cmd );
5758
5706
}
5759
5707
5760
5708
static void rtl_hw_start_8168c_1 (struct rtl8169_private * tp )
@@ -5811,7 +5759,8 @@ static void rtl_hw_start_8168d(struct rtl8169_private *tp)
5811
5759
if (tp -> dev -> mtu <= ETH_DATA_LEN )
5812
5760
rtl_tx_performance_tweak (tp , PCI_EXP_DEVCTL_READRQ_4096B );
5813
5761
5814
- RTL_W16 (tp , CPlusCmd , RTL_R16 (tp , CPlusCmd ) & ~R8168_CPCMD_QUIRK_MASK );
5762
+ tp -> cp_cmd &= CPCMD_QUIRK_MASK ;
5763
+ RTL_W16 (tp , CPlusCmd , tp -> cp_cmd );
5815
5764
}
5816
5765
5817
5766
static void rtl_hw_start_8168dp (struct rtl8169_private * tp )
@@ -6274,14 +6223,10 @@ static void rtl_hw_start_8168ep_3(struct rtl8169_private *tp)
6274
6223
6275
6224
static void rtl_hw_start_8168 (struct rtl8169_private * tp )
6276
6225
{
6277
- RTL_W8 (tp , Cfg9346 , Cfg9346_Unlock );
6278
-
6279
6226
RTL_W8 (tp , MaxTxPacketSize , TxPacketMax );
6280
6227
6281
- rtl_set_rx_max_size (tp );
6282
-
6283
- tp -> cp_cmd |= RTL_R16 (tp , CPlusCmd ) | PktCntrDisable | INTT_1 ;
6284
-
6228
+ tp -> cp_cmd &= ~INTT_MASK ;
6229
+ tp -> cp_cmd |= PktCntrDisable | INTT_1 ;
6285
6230
RTL_W16 (tp , CPlusCmd , tp -> cp_cmd );
6286
6231
6287
6232
RTL_W16 (tp , IntrMitigate , 0x5151 );
@@ -6292,12 +6237,6 @@ static void rtl_hw_start_8168(struct rtl8169_private *tp)
6292
6237
tp -> event_slow &= ~RxOverflow ;
6293
6238
}
6294
6239
6295
- rtl_set_rx_tx_desc_registers (tp );
6296
-
6297
- rtl_set_rx_tx_config_registers (tp );
6298
-
6299
- RTL_R8 (tp , IntrMask );
6300
-
6301
6240
switch (tp -> mac_version ) {
6302
6241
case RTL_GIGA_MAC_VER_11 :
6303
6242
rtl_hw_start_8168bb (tp );
@@ -6401,27 +6340,8 @@ static void rtl_hw_start_8168(struct rtl8169_private *tp)
6401
6340
tp -> dev -> name , tp -> mac_version );
6402
6341
break ;
6403
6342
}
6404
-
6405
- RTL_W8 (tp , Cfg9346 , Cfg9346_Lock );
6406
-
6407
- RTL_W8 (tp , ChipCmd , CmdTxEnb | CmdRxEnb );
6408
-
6409
- rtl_set_rx_mode (tp -> dev );
6410
-
6411
- RTL_W16 (tp , MultiIntr , RTL_R16 (tp , MultiIntr ) & 0xf000 );
6412
6343
}
6413
6344
6414
- #define R810X_CPCMD_QUIRK_MASK (\
6415
- EnableBist | \
6416
- Mac_dbgo_oe | \
6417
- Force_half_dup | \
6418
- Force_rxflow_en | \
6419
- Force_txflow_en | \
6420
- Cxpl_dbg_sel | \
6421
- ASF | \
6422
- PktCntrDisable | \
6423
- Mac_dbgo_sel)
6424
-
6425
6345
static void rtl_hw_start_8102e_1 (struct rtl8169_private * tp )
6426
6346
{
6427
6347
static const struct ephy_info e_info_8102e_1 [] = {
@@ -6555,19 +6475,11 @@ static void rtl_hw_start_8101(struct rtl8169_private *tp)
6555
6475
pcie_capability_set_word (tp -> pci_dev , PCI_EXP_DEVCTL ,
6556
6476
PCI_EXP_DEVCTL_NOSNOOP_EN );
6557
6477
6558
- RTL_W8 (tp , Cfg9346 , Cfg9346_Unlock );
6559
-
6560
6478
RTL_W8 (tp , MaxTxPacketSize , TxPacketMax );
6561
6479
6562
- rtl_set_rx_max_size (tp );
6563
-
6564
- tp -> cp_cmd &= ~R810X_CPCMD_QUIRK_MASK ;
6480
+ tp -> cp_cmd &= CPCMD_QUIRK_MASK ;
6565
6481
RTL_W16 (tp , CPlusCmd , tp -> cp_cmd );
6566
6482
6567
- rtl_set_rx_tx_desc_registers (tp );
6568
-
6569
- rtl_set_rx_tx_config_registers (tp );
6570
-
6571
6483
switch (tp -> mac_version ) {
6572
6484
case RTL_GIGA_MAC_VER_07 :
6573
6485
rtl_hw_start_8102e_1 (tp );
@@ -6604,17 +6516,7 @@ static void rtl_hw_start_8101(struct rtl8169_private *tp)
6604
6516
break ;
6605
6517
}
6606
6518
6607
- RTL_W8 (tp , Cfg9346 , Cfg9346_Lock );
6608
-
6609
6519
RTL_W16 (tp , IntrMitigate , 0x0000 );
6610
-
6611
- RTL_W8 (tp , ChipCmd , CmdTxEnb | CmdRxEnb );
6612
-
6613
- rtl_set_rx_mode (tp -> dev );
6614
-
6615
- RTL_R8 (tp , IntrMask );
6616
-
6617
- RTL_W16 (tp , MultiIntr , RTL_R16 (tp , MultiIntr ) & 0xf000 );
6618
6520
}
6619
6521
6620
6522
static int rtl8169_change_mtu (struct net_device * dev , int new_mtu )
@@ -7637,8 +7539,6 @@ static int rtl_open(struct net_device *dev)
7637
7539
7638
7540
rtl8169_init_phy (dev , tp );
7639
7541
7640
- __rtl8169_set_features (dev , dev -> features );
7641
-
7642
7542
rtl_pll_power_up (tp );
7643
7543
7644
7544
rtl_hw_start (tp );
@@ -8141,7 +8041,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
8141
8041
/* Identify chip attached to board */
8142
8042
rtl8169_get_mac_version (tp , cfg -> default_ver );
8143
8043
8144
- tp -> cp_cmd = 0 ;
8044
+ tp -> cp_cmd = RTL_R16 ( tp , CPlusCmd ) ;
8145
8045
8146
8046
if ((sizeof (dma_addr_t ) > 4 ) &&
8147
8047
(use_dac == 1 || (use_dac == -1 && pci_is_pcie (pdev ) &&
0 commit comments