Skip to content

Commit 5133bcc

Browse files
hayesorzdavem330
authored andcommitted
r8152: set inter fram gap time depending on speed
Set the maximum inter frame gap time (144ns) for speed 10M/half and 100M/half. It improves the performance for those speeds. And, there is no effect for the other speeds. For 10M/half and 100M/half, the fast inter frame gap time let the device couldn't use the feature of the aggregation effectively, because the transfer would be completed fastly. Therefore, use the maximum value to improve the effect of the aggregation. However, you may not feel the improvement for fast CPUs, because they compensate for the effect of the aggregation. Signed-off-by: Hayes Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c5d6658 commit 5133bcc

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

drivers/net/usb/r8152.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@
249249

250250
/* PLA_TCR1 */
251251
#define VERSION_MASK 0x7cf0
252+
#define IFG_MASK (BIT(3) | BIT(9) | BIT(8))
253+
#define IFG_144NS BIT(9)
254+
#define IFG_96NS (BIT(9) | BIT(8))
252255

253256
/* PLA_MTPS */
254257
#define MTPS_JUMBO (12 * 1024 / 64)
@@ -2747,6 +2750,29 @@ static int rtl_stop_rx(struct r8152 *tp)
27472750
return 0;
27482751
}
27492752

2753+
static void rtl_set_ifg(struct r8152 *tp, u16 speed)
2754+
{
2755+
u32 ocp_data;
2756+
2757+
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR1);
2758+
ocp_data &= ~IFG_MASK;
2759+
if ((speed & (_10bps | _100bps)) && !(speed & FULL_DUP)) {
2760+
ocp_data |= IFG_144NS;
2761+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_TCR1, ocp_data);
2762+
2763+
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4);
2764+
ocp_data &= ~TX10MIDLE_EN;
2765+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4, ocp_data);
2766+
} else {
2767+
ocp_data |= IFG_96NS;
2768+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_TCR1, ocp_data);
2769+
2770+
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4);
2771+
ocp_data |= TX10MIDLE_EN;
2772+
ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4, ocp_data);
2773+
}
2774+
}
2775+
27502776
static inline void r8153b_rx_agg_chg_indicate(struct r8152 *tp)
27512777
{
27522778
ocp_write_byte(tp, MCU_TYPE_USB, USB_UPT_RXDMA_OWN,
@@ -2850,6 +2876,8 @@ static int rtl8153_enable(struct r8152 *tp)
28502876
r8153_set_rx_early_timeout(tp);
28512877
r8153_set_rx_early_size(tp);
28522878

2879+
rtl_set_ifg(tp, rtl8152_get_speed(tp));
2880+
28532881
if (tp->version == RTL_VER_09) {
28542882
u32 ocp_data;
28552883

0 commit comments

Comments
 (0)