Commit 4646651e authored by David S. Miller's avatar David S. Miller

Merge branch 'mediatek-hw-lro'

Nelson Chang says:

====================
net: ethernet: mediatek: add HW LRO functions

The series add the large receive offload (LRO) functions by hardware and
the ethtool functions to configure RX flows of HW LRO.

changes since v3:
- Respin the patch by the newer driver
- Move the dts description of hwlro to optional properties

changes since v2:
- Add ndo_fix_features to prevent NETIF_F_LRO off while RX flow is programmed
- Rephrase the dts property is a capability if the hardware supports LRO

changes since v1:
- Add HW LRO support
- Add ethtool hooks to set LRO RX flows
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 0fbc81b3 004e6cc6
...@@ -24,7 +24,7 @@ Required properties: ...@@ -24,7 +24,7 @@ Required properties:
Optional properties: Optional properties:
- interrupt-parent: Should be the phandle for the interrupt controller - interrupt-parent: Should be the phandle for the interrupt controller
that services interrupts for this device that services interrupts for this device
- mediatek,hwlro: the capability if the hardware supports LRO functions
* Ethernet MAC node * Ethernet MAC node
...@@ -51,6 +51,7 @@ eth: ethernet@1b100000 { ...@@ -51,6 +51,7 @@ eth: ethernet@1b100000 {
reset-names = "eth"; reset-names = "eth";
mediatek,ethsys = <&ethsys>; mediatek,ethsys = <&ethsys>;
mediatek,pctl = <&syscfg_pctl_a>; mediatek,pctl = <&syscfg_pctl_a>;
mediatek,hwlro;
#address-cells = <1>; #address-cells = <1>;
#size-cells = <0>; #size-cells = <0>;
......
This diff is collapsed.
...@@ -39,7 +39,21 @@ ...@@ -39,7 +39,21 @@
NETIF_F_SG | NETIF_F_TSO | \ NETIF_F_SG | NETIF_F_TSO | \
NETIF_F_TSO6 | \ NETIF_F_TSO6 | \
NETIF_F_IPV6_CSUM) NETIF_F_IPV6_CSUM)
#define NEXT_RX_DESP_IDX(X) (((X) + 1) & (MTK_DMA_SIZE - 1)) #define NEXT_RX_DESP_IDX(X, Y) (((X) + 1) & ((Y) - 1))
#define MTK_MAX_RX_RING_NUM 4
#define MTK_HW_LRO_DMA_SIZE 8
#define MTK_MAX_LRO_RX_LENGTH (4096 * 3)
#define MTK_MAX_LRO_IP_CNT 2
#define MTK_HW_LRO_TIMER_UNIT 1 /* 20 us */
#define MTK_HW_LRO_REFRESH_TIME 50000 /* 1 sec. */
#define MTK_HW_LRO_AGG_TIME 10 /* 200us */
#define MTK_HW_LRO_AGE_TIME 50 /* 1ms */
#define MTK_HW_LRO_MAX_AGG_CNT 64
#define MTK_HW_LRO_BW_THRE 3000
#define MTK_HW_LRO_REPLACE_DELTA 1000
#define MTK_HW_LRO_SDL_REMAIN_ROOM 1522
/* Frame Engine Global Reset Register */ /* Frame Engine Global Reset Register */
#define MTK_RST_GL 0x04 #define MTK_RST_GL 0x04
...@@ -50,6 +64,9 @@ ...@@ -50,6 +64,9 @@
#define MTK_GDM1_AF BIT(28) #define MTK_GDM1_AF BIT(28)
#define MTK_GDM2_AF BIT(29) #define MTK_GDM2_AF BIT(29)
/* PDMA HW LRO Alter Flow Timer Register */
#define MTK_PDMA_LRO_ALT_REFRESH_TIMER 0x1c
/* Frame Engine Interrupt Grouping Register */ /* Frame Engine Interrupt Grouping Register */
#define MTK_FE_INT_GRP 0x20 #define MTK_FE_INT_GRP 0x20
...@@ -70,12 +87,29 @@ ...@@ -70,12 +87,29 @@
/* PDMA RX Base Pointer Register */ /* PDMA RX Base Pointer Register */
#define MTK_PRX_BASE_PTR0 0x900 #define MTK_PRX_BASE_PTR0 0x900
#define MTK_PRX_BASE_PTR_CFG(x) (MTK_PRX_BASE_PTR0 + (x * 0x10))
/* PDMA RX Maximum Count Register */ /* PDMA RX Maximum Count Register */
#define MTK_PRX_MAX_CNT0 0x904 #define MTK_PRX_MAX_CNT0 0x904
#define MTK_PRX_MAX_CNT_CFG(x) (MTK_PRX_MAX_CNT0 + (x * 0x10))
/* PDMA RX CPU Pointer Register */ /* PDMA RX CPU Pointer Register */
#define MTK_PRX_CRX_IDX0 0x908 #define MTK_PRX_CRX_IDX0 0x908
#define MTK_PRX_CRX_IDX_CFG(x) (MTK_PRX_CRX_IDX0 + (x * 0x10))
/* PDMA HW LRO Control Registers */
#define MTK_PDMA_LRO_CTRL_DW0 0x980
#define MTK_LRO_EN BIT(0)
#define MTK_L3_CKS_UPD_EN BIT(7)
#define MTK_LRO_ALT_PKT_CNT_MODE BIT(21)
#define MTK_LRO_RING_RELINQUISH_REQ (0x3 << 26)
#define MTK_LRO_RING_RELINQUISH_DONE (0x3 << 29)
#define MTK_PDMA_LRO_CTRL_DW1 0x984
#define MTK_PDMA_LRO_CTRL_DW2 0x988
#define MTK_PDMA_LRO_CTRL_DW3 0x98c
#define MTK_ADMA_MODE BIT(15)
#define MTK_LRO_MIN_RXD_SDL (MTK_HW_LRO_SDL_REMAIN_ROOM << 16)
/* PDMA Global Configuration Register */ /* PDMA Global Configuration Register */
#define MTK_PDMA_GLO_CFG 0xa04 #define MTK_PDMA_GLO_CFG 0xa04
...@@ -84,6 +118,7 @@ ...@@ -84,6 +118,7 @@
/* PDMA Reset Index Register */ /* PDMA Reset Index Register */
#define MTK_PDMA_RST_IDX 0xa08 #define MTK_PDMA_RST_IDX 0xa08
#define MTK_PST_DRX_IDX0 BIT(16) #define MTK_PST_DRX_IDX0 BIT(16)
#define MTK_PST_DRX_IDX_CFG(x) (MTK_PST_DRX_IDX0 << (x))
/* PDMA Delay Interrupt Register */ /* PDMA Delay Interrupt Register */
#define MTK_PDMA_DELAY_INT 0xa0c #define MTK_PDMA_DELAY_INT 0xa0c
...@@ -94,10 +129,33 @@ ...@@ -94,10 +129,33 @@
/* PDMA Interrupt Mask Register */ /* PDMA Interrupt Mask Register */
#define MTK_PDMA_INT_MASK 0xa28 #define MTK_PDMA_INT_MASK 0xa28
/* PDMA HW LRO Alter Flow Delta Register */
#define MTK_PDMA_LRO_ALT_SCORE_DELTA 0xa4c
/* PDMA Interrupt grouping registers */ /* PDMA Interrupt grouping registers */
#define MTK_PDMA_INT_GRP1 0xa50 #define MTK_PDMA_INT_GRP1 0xa50
#define MTK_PDMA_INT_GRP2 0xa54 #define MTK_PDMA_INT_GRP2 0xa54
/* PDMA HW LRO IP Setting Registers */
#define MTK_LRO_RX_RING0_DIP_DW0 0xb04
#define MTK_LRO_DIP_DW0_CFG(x) (MTK_LRO_RX_RING0_DIP_DW0 + (x * 0x40))
#define MTK_RING_MYIP_VLD BIT(9)
/* PDMA HW LRO Ring Control Registers */
#define MTK_LRO_RX_RING0_CTRL_DW1 0xb28
#define MTK_LRO_RX_RING0_CTRL_DW2 0xb2c
#define MTK_LRO_RX_RING0_CTRL_DW3 0xb30
#define MTK_LRO_CTRL_DW1_CFG(x) (MTK_LRO_RX_RING0_CTRL_DW1 + (x * 0x40))
#define MTK_LRO_CTRL_DW2_CFG(x) (MTK_LRO_RX_RING0_CTRL_DW2 + (x * 0x40))
#define MTK_LRO_CTRL_DW3_CFG(x) (MTK_LRO_RX_RING0_CTRL_DW3 + (x * 0x40))
#define MTK_RING_AGE_TIME_L ((MTK_HW_LRO_AGE_TIME & 0x3ff) << 22)
#define MTK_RING_AGE_TIME_H ((MTK_HW_LRO_AGE_TIME >> 10) & 0x3f)
#define MTK_RING_AUTO_LERAN_MODE (3 << 6)
#define MTK_RING_VLD BIT(8)
#define MTK_RING_MAX_AGG_TIME ((MTK_HW_LRO_AGG_TIME & 0xffff) << 10)
#define MTK_RING_MAX_AGG_CNT_L ((MTK_HW_LRO_MAX_AGG_CNT & 0x3f) << 26)
#define MTK_RING_MAX_AGG_CNT_H ((MTK_HW_LRO_MAX_AGG_CNT >> 6) & 0x3)
/* QDMA TX Queue Configuration Registers */ /* QDMA TX Queue Configuration Registers */
#define MTK_QTX_CFG(x) (0x1800 + (x * 0x10)) #define MTK_QTX_CFG(x) (0x1800 + (x * 0x10))
#define QDMA_RES_THRES 4 #define QDMA_RES_THRES 4
...@@ -132,7 +190,6 @@ ...@@ -132,7 +190,6 @@
/* QDMA Reset Index Register */ /* QDMA Reset Index Register */
#define MTK_QDMA_RST_IDX 0x1A08 #define MTK_QDMA_RST_IDX 0x1A08
#define MTK_PST_DRX_IDX0 BIT(16)
/* QDMA Delay Interrupt Register */ /* QDMA Delay Interrupt Register */
#define MTK_QDMA_DELAY_INT 0x1A0C #define MTK_QDMA_DELAY_INT 0x1A0C
...@@ -377,6 +434,12 @@ struct mtk_tx_ring { ...@@ -377,6 +434,12 @@ struct mtk_tx_ring {
atomic_t free_count; atomic_t free_count;
}; };
/* PDMA rx ring mode */
enum mtk_rx_flags {
MTK_RX_FLAGS_NORMAL = 0,
MTK_RX_FLAGS_HWLRO,
};
/* struct mtk_rx_ring - This struct holds info describing a RX ring /* struct mtk_rx_ring - This struct holds info describing a RX ring
* @dma: The descriptor ring * @dma: The descriptor ring
* @data: The memory pointed at by the ring * @data: The memory pointed at by the ring
...@@ -391,7 +454,10 @@ struct mtk_rx_ring { ...@@ -391,7 +454,10 @@ struct mtk_rx_ring {
dma_addr_t phys; dma_addr_t phys;
u16 frag_size; u16 frag_size;
u16 buf_size; u16 buf_size;
u16 dma_size;
bool calc_idx_update;
u16 calc_idx; u16 calc_idx;
u32 crx_idx_reg;
}; };
/* currently no SoC has more than 2 macs */ /* currently no SoC has more than 2 macs */
...@@ -439,9 +505,10 @@ struct mtk_eth { ...@@ -439,9 +505,10 @@ struct mtk_eth {
unsigned long sysclk; unsigned long sysclk;
struct regmap *ethsys; struct regmap *ethsys;
struct regmap *pctl; struct regmap *pctl;
bool hwlro;
atomic_t dma_refcnt; atomic_t dma_refcnt;
struct mtk_tx_ring tx_ring; struct mtk_tx_ring tx_ring;
struct mtk_rx_ring rx_ring; struct mtk_rx_ring rx_ring[MTK_MAX_RX_RING_NUM];
struct napi_struct tx_napi; struct napi_struct tx_napi;
struct napi_struct rx_napi; struct napi_struct rx_napi;
struct mtk_tx_dma *scratch_ring; struct mtk_tx_dma *scratch_ring;
...@@ -470,6 +537,8 @@ struct mtk_mac { ...@@ -470,6 +537,8 @@ struct mtk_mac {
struct mtk_eth *hw; struct mtk_eth *hw;
struct mtk_hw_stats *hw_stats; struct mtk_hw_stats *hw_stats;
struct phy_device *phy_dev; struct phy_device *phy_dev;
__be32 hwlro_ip[MTK_MAX_LRO_IP_CNT];
int hwlro_ip_cnt;
}; };
/* the struct describing the SoC. these are declared in the soc_xyz.c files */ /* the struct describing the SoC. these are declared in the soc_xyz.c files */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment