Skip to content

Commit 4fd48c4

Browse files
hkallweitdavem330
authored andcommitted
r8169: move common initializations to tp->hw_start
The chip-specific init code includes quite some calls which are identical for all chips. So move these calls to tp->hw_start(). In addition move rtl_set_rx_max_size() a little to make sure it's defined before it's used. Unfortunately the diff generated by git is a little bit hard to read. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 82d3ff6 commit 4fd48c4

File tree

1 file changed

+19
-55
lines changed
  • drivers/net/ethernet/realtek

1 file changed

+19
-55
lines changed

drivers/net/ethernet/realtek/r8169.c

Lines changed: 19 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -5301,10 +5301,10 @@ static void rtl_set_rx_tx_config_registers(struct rtl8169_private *tp)
53015301
(InterFrameGap << TxInterFrameGapShift));
53025302
}
53035303

5304-
static void rtl_hw_start(struct rtl8169_private *tp)
5304+
static void rtl_set_rx_max_size(struct rtl8169_private *tp)
53055305
{
5306-
tp->hw_start(tp);
5307-
rtl_irq_enable_all(tp);
5306+
/* Low hurts. Let's disable the filtering. */
5307+
RTL_W16(tp, RxMaxSize, R8169_RX_BUF_SIZE + 1);
53085308
}
53095309

53105310
static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp)
@@ -5320,10 +5320,23 @@ static void rtl_set_rx_tx_desc_registers(struct rtl8169_private *tp)
53205320
RTL_W32(tp, RxDescAddrLow, ((u64) tp->RxPhyAddr) & DMA_BIT_MASK(32));
53215321
}
53225322

5323-
static void rtl_set_rx_max_size(struct rtl8169_private *tp)
5323+
static void rtl_hw_start(struct rtl8169_private *tp)
53245324
{
5325-
/* Low hurts. Let's disable the filtering. */
5326-
RTL_W16(tp, RxMaxSize, R8169_RX_BUF_SIZE + 1);
5325+
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
5326+
5327+
tp->hw_start(tp);
5328+
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);
53275340
}
53285341

53295342
static void rtl8169_set_magic_reg(struct rtl8169_private *tp, unsigned mac_version)
@@ -5408,12 +5421,8 @@ static void rtl_hw_start_8169(struct rtl8169_private *tp)
54085421
if (tp->mac_version == RTL_GIGA_MAC_VER_05)
54095422
pci_write_config_byte(tp->pci_dev, PCI_CACHE_LINE_SIZE, 0x08);
54105423

5411-
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
5412-
54135424
RTL_W8(tp, EarlyTxThres, NoEarlyTx);
54145425

5415-
rtl_set_rx_max_size(tp);
5416-
54175426
tp->cp_cmd |= PCIMulRW;
54185427

54195428
if (tp->mac_version == RTL_GIGA_MAC_VER_02 ||
@@ -5433,20 +5442,7 @@ static void rtl_hw_start_8169(struct rtl8169_private *tp)
54335442
*/
54345443
RTL_W16(tp, IntrMitigate, 0x0000);
54355444

5436-
rtl_set_rx_tx_desc_registers(tp);
5437-
rtl_set_rx_tx_config_registers(tp);
5438-
5439-
RTL_W8(tp, ChipCmd, CmdTxEnb | CmdRxEnb);
5440-
5441-
RTL_W8(tp, Cfg9346, Cfg9346_Lock);
5442-
5443-
/* Initially a 10 us delay. Turned it into a PCI commit. - FR */
5444-
RTL_R8(tp, IntrMask);
5445-
54465445
RTL_W32(tp, RxMissed, 0);
5447-
5448-
/* no early-rx interrupts */
5449-
RTL_W16(tp, MultiIntr, RTL_R16(tp, MultiIntr) & 0xf000);
54505446
}
54515447

54525448
static void rtl_csi_write(struct rtl8169_private *tp, int addr, int value)
@@ -6227,12 +6223,8 @@ static void rtl_hw_start_8168ep_3(struct rtl8169_private *tp)
62276223

62286224
static void rtl_hw_start_8168(struct rtl8169_private *tp)
62296225
{
6230-
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
6231-
62326226
RTL_W8(tp, MaxTxPacketSize, TxPacketMax);
62336227

6234-
rtl_set_rx_max_size(tp);
6235-
62366228
tp->cp_cmd &= ~INTT_MASK;
62376229
tp->cp_cmd |= PktCntrDisable | INTT_1;
62386230
RTL_W16(tp, CPlusCmd, tp->cp_cmd);
@@ -6245,12 +6237,6 @@ static void rtl_hw_start_8168(struct rtl8169_private *tp)
62456237
tp->event_slow &= ~RxOverflow;
62466238
}
62476239

6248-
rtl_set_rx_tx_desc_registers(tp);
6249-
6250-
rtl_set_rx_tx_config_registers(tp);
6251-
6252-
RTL_R8(tp, IntrMask);
6253-
62546240
switch (tp->mac_version) {
62556241
case RTL_GIGA_MAC_VER_11:
62566242
rtl_hw_start_8168bb(tp);
@@ -6354,12 +6340,6 @@ static void rtl_hw_start_8168(struct rtl8169_private *tp)
63546340
tp->dev->name, tp->mac_version);
63556341
break;
63566342
}
6357-
6358-
RTL_W8(tp, Cfg9346, Cfg9346_Lock);
6359-
6360-
RTL_W8(tp, ChipCmd, CmdTxEnb | CmdRxEnb);
6361-
6362-
RTL_W16(tp, MultiIntr, RTL_R16(tp, MultiIntr) & 0xf000);
63636343
}
63646344

63656345
static void rtl_hw_start_8102e_1(struct rtl8169_private *tp)
@@ -6495,19 +6475,11 @@ static void rtl_hw_start_8101(struct rtl8169_private *tp)
64956475
pcie_capability_set_word(tp->pci_dev, PCI_EXP_DEVCTL,
64966476
PCI_EXP_DEVCTL_NOSNOOP_EN);
64976477

6498-
RTL_W8(tp, Cfg9346, Cfg9346_Unlock);
6499-
65006478
RTL_W8(tp, MaxTxPacketSize, TxPacketMax);
65016479

6502-
rtl_set_rx_max_size(tp);
6503-
65046480
tp->cp_cmd &= CPCMD_QUIRK_MASK;
65056481
RTL_W16(tp, CPlusCmd, tp->cp_cmd);
65066482

6507-
rtl_set_rx_tx_desc_registers(tp);
6508-
6509-
rtl_set_rx_tx_config_registers(tp);
6510-
65116483
switch (tp->mac_version) {
65126484
case RTL_GIGA_MAC_VER_07:
65136485
rtl_hw_start_8102e_1(tp);
@@ -6544,15 +6516,7 @@ static void rtl_hw_start_8101(struct rtl8169_private *tp)
65446516
break;
65456517
}
65466518

6547-
RTL_W8(tp, Cfg9346, Cfg9346_Lock);
6548-
65496519
RTL_W16(tp, IntrMitigate, 0x0000);
6550-
6551-
RTL_W8(tp, ChipCmd, CmdTxEnb | CmdRxEnb);
6552-
6553-
RTL_R8(tp, IntrMask);
6554-
6555-
RTL_W16(tp, MultiIntr, RTL_R16(tp, MultiIntr) & 0xf000);
65566520
}
65576521

65586522
static int rtl8169_change_mtu(struct net_device *dev, int new_mtu)

0 commit comments

Comments
 (0)