Skip to content

Commit 5bacd77

Browse files
montjoiedavem330
authored andcommitted
Revert "net: stmmac: enable multiple buffers"
The commit aff3d9e ("net: stmmac: enable multiple buffers") breaks numerous boards. while some patch exists for fixing some of it, dwmac-sunxi is still broken with it. Since this patch is very huge, it will be better to split it in smaller part. Signed-off-by: Corentin Labbe <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 397df70 commit 5bacd77

File tree

4 files changed

+473
-973
lines changed

4 files changed

+473
-973
lines changed

drivers/net/ethernet/stmicro/stmmac/chain_mode.c

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626

2727
static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
2828
{
29-
struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)p;
29+
struct stmmac_priv *priv = (struct stmmac_priv *)p;
30+
unsigned int entry = priv->cur_tx;
31+
struct dma_desc *desc = priv->dma_tx + entry;
3032
unsigned int nopaged_len = skb_headlen(skb);
31-
struct stmmac_priv *priv = tx_q->priv_data;
32-
unsigned int entry = tx_q->cur_tx;
3333
unsigned int bmax, des2;
3434
unsigned int i = 1, len;
35-
struct dma_desc *desc;
36-
37-
desc = tx_q->dma_tx + entry;
3835

3936
if (priv->plat->enh_desc)
4037
bmax = BUF_SIZE_8KiB;
@@ -48,16 +45,16 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
4845
desc->des2 = cpu_to_le32(des2);
4946
if (dma_mapping_error(priv->device, des2))
5047
return -1;
51-
tx_q->tx_skbuff_dma[entry].buf = des2;
52-
tx_q->tx_skbuff_dma[entry].len = bmax;
48+
priv->tx_skbuff_dma[entry].buf = des2;
49+
priv->tx_skbuff_dma[entry].len = bmax;
5350
/* do not close the descriptor and do not set own bit */
5451
priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE,
5552
0, false);
5653

5754
while (len != 0) {
58-
tx_q->tx_skbuff[entry] = NULL;
55+
priv->tx_skbuff[entry] = NULL;
5956
entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE);
60-
desc = tx_q->dma_tx + entry;
57+
desc = priv->dma_tx + entry;
6158

6259
if (len > bmax) {
6360
des2 = dma_map_single(priv->device,
@@ -66,8 +63,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
6663
desc->des2 = cpu_to_le32(des2);
6764
if (dma_mapping_error(priv->device, des2))
6865
return -1;
69-
tx_q->tx_skbuff_dma[entry].buf = des2;
70-
tx_q->tx_skbuff_dma[entry].len = bmax;
66+
priv->tx_skbuff_dma[entry].buf = des2;
67+
priv->tx_skbuff_dma[entry].len = bmax;
7168
priv->hw->desc->prepare_tx_desc(desc, 0, bmax, csum,
7269
STMMAC_CHAIN_MODE, 1,
7370
false);
@@ -80,8 +77,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
8077
desc->des2 = cpu_to_le32(des2);
8178
if (dma_mapping_error(priv->device, des2))
8279
return -1;
83-
tx_q->tx_skbuff_dma[entry].buf = des2;
84-
tx_q->tx_skbuff_dma[entry].len = len;
80+
priv->tx_skbuff_dma[entry].buf = des2;
81+
priv->tx_skbuff_dma[entry].len = len;
8582
/* last descriptor can be set now */
8683
priv->hw->desc->prepare_tx_desc(desc, 0, len, csum,
8784
STMMAC_CHAIN_MODE, 1,
@@ -90,7 +87,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
9087
}
9188
}
9289

93-
tx_q->cur_tx = entry;
90+
priv->cur_tx = entry;
9491

9592
return entry;
9693
}
@@ -139,34 +136,32 @@ static void stmmac_init_dma_chain(void *des, dma_addr_t phy_addr,
139136

140137
static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p)
141138
{
142-
struct stmmac_rx_queue *rx_q = (struct stmmac_rx_queue *)priv_ptr;
143-
struct stmmac_priv *priv = rx_q->priv_data;
139+
struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr;
144140

145141
if (priv->hwts_rx_en && !priv->extend_desc)
146142
/* NOTE: Device will overwrite des3 with timestamp value if
147143
* 1588-2002 time stamping is enabled, hence reinitialize it
148144
* to keep explicit chaining in the descriptor.
149145
*/
150-
p->des3 = cpu_to_le32((unsigned int)(rx_q->dma_rx_phy +
151-
(((rx_q->dirty_rx) + 1) %
146+
p->des3 = cpu_to_le32((unsigned int)(priv->dma_rx_phy +
147+
(((priv->dirty_rx) + 1) %
152148
DMA_RX_SIZE) *
153149
sizeof(struct dma_desc)));
154150
}
155151

156152
static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p)
157153
{
158-
struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)priv_ptr;
159-
struct stmmac_priv *priv = tx_q->priv_data;
160-
unsigned int entry = tx_q->dirty_tx;
154+
struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr;
155+
unsigned int entry = priv->dirty_tx;
161156

162-
if (tx_q->tx_skbuff_dma[entry].last_segment && !priv->extend_desc &&
157+
if (priv->tx_skbuff_dma[entry].last_segment && !priv->extend_desc &&
163158
priv->hwts_tx_en)
164159
/* NOTE: Device will overwrite des3 with timestamp value if
165160
* 1588-2002 time stamping is enabled, hence reinitialize it
166161
* to keep explicit chaining in the descriptor.
167162
*/
168-
p->des3 = cpu_to_le32((unsigned int)((tx_q->dma_tx_phy +
169-
((tx_q->dirty_tx + 1) % DMA_TX_SIZE))
163+
p->des3 = cpu_to_le32((unsigned int)((priv->dma_tx_phy +
164+
((priv->dirty_tx + 1) % DMA_TX_SIZE))
170165
* sizeof(struct dma_desc)));
171166
}
172167

drivers/net/ethernet/stmicro/stmmac/ring_mode.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@
2626

2727
static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
2828
{
29-
struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)p;
29+
struct stmmac_priv *priv = (struct stmmac_priv *)p;
30+
unsigned int entry = priv->cur_tx;
31+
struct dma_desc *desc;
3032
unsigned int nopaged_len = skb_headlen(skb);
31-
struct stmmac_priv *priv = tx_q->priv_data;
32-
unsigned int entry = tx_q->cur_tx;
3333
unsigned int bmax, len, des2;
34-
struct dma_desc *desc;
3534

3635
if (priv->extend_desc)
37-
desc = (struct dma_desc *)(tx_q->dma_etx + entry);
36+
desc = (struct dma_desc *)(priv->dma_etx + entry);
3837
else
39-
desc = tx_q->dma_tx + entry;
38+
desc = priv->dma_tx + entry;
4039

4140
if (priv->plat->enh_desc)
4241
bmax = BUF_SIZE_8KiB;
@@ -53,29 +52,29 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
5352
if (dma_mapping_error(priv->device, des2))
5453
return -1;
5554

56-
tx_q->tx_skbuff_dma[entry].buf = des2;
57-
tx_q->tx_skbuff_dma[entry].len = bmax;
58-
tx_q->tx_skbuff_dma[entry].is_jumbo = true;
55+
priv->tx_skbuff_dma[entry].buf = des2;
56+
priv->tx_skbuff_dma[entry].len = bmax;
57+
priv->tx_skbuff_dma[entry].is_jumbo = true;
5958

6059
desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
6160
priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum,
6261
STMMAC_RING_MODE, 0, false);
63-
tx_q->tx_skbuff[entry] = NULL;
62+
priv->tx_skbuff[entry] = NULL;
6463
entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE);
6564

6665
if (priv->extend_desc)
67-
desc = (struct dma_desc *)(tx_q->dma_etx + entry);
66+
desc = (struct dma_desc *)(priv->dma_etx + entry);
6867
else
69-
desc = tx_q->dma_tx + entry;
68+
desc = priv->dma_tx + entry;
7069

7170
des2 = dma_map_single(priv->device, skb->data + bmax, len,
7271
DMA_TO_DEVICE);
7372
desc->des2 = cpu_to_le32(des2);
7473
if (dma_mapping_error(priv->device, des2))
7574
return -1;
76-
tx_q->tx_skbuff_dma[entry].buf = des2;
77-
tx_q->tx_skbuff_dma[entry].len = len;
78-
tx_q->tx_skbuff_dma[entry].is_jumbo = true;
75+
priv->tx_skbuff_dma[entry].buf = des2;
76+
priv->tx_skbuff_dma[entry].len = len;
77+
priv->tx_skbuff_dma[entry].is_jumbo = true;
7978

8079
desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
8180
priv->hw->desc->prepare_tx_desc(desc, 0, len, csum,
@@ -86,15 +85,15 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum)
8685
desc->des2 = cpu_to_le32(des2);
8786
if (dma_mapping_error(priv->device, des2))
8887
return -1;
89-
tx_q->tx_skbuff_dma[entry].buf = des2;
90-
tx_q->tx_skbuff_dma[entry].len = nopaged_len;
91-
tx_q->tx_skbuff_dma[entry].is_jumbo = true;
88+
priv->tx_skbuff_dma[entry].buf = des2;
89+
priv->tx_skbuff_dma[entry].len = nopaged_len;
90+
priv->tx_skbuff_dma[entry].is_jumbo = true;
9291
desc->des3 = cpu_to_le32(des2 + BUF_SIZE_4KiB);
9392
priv->hw->desc->prepare_tx_desc(desc, 1, nopaged_len, csum,
9493
STMMAC_RING_MODE, 0, true);
9594
}
9695

97-
tx_q->cur_tx = entry;
96+
priv->cur_tx = entry;
9897

9998
return entry;
10099
}
@@ -126,13 +125,12 @@ static void stmmac_init_desc3(struct dma_desc *p)
126125

127126
static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p)
128127
{
129-
struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)priv_ptr;
130-
struct stmmac_priv *priv = tx_q->priv_data;
131-
unsigned int entry = tx_q->dirty_tx;
128+
struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr;
129+
unsigned int entry = priv->dirty_tx;
132130

133131
/* des3 is only used for jumbo frames tx or time stamping */
134-
if (unlikely(tx_q->tx_skbuff_dma[entry].is_jumbo ||
135-
(tx_q->tx_skbuff_dma[entry].last_segment &&
132+
if (unlikely(priv->tx_skbuff_dma[entry].is_jumbo ||
133+
(priv->tx_skbuff_dma[entry].last_segment &&
136134
!priv->extend_desc && priv->hwts_tx_en)))
137135
p->des3 = 0;
138136
}

drivers/net/ethernet/stmicro/stmmac/stmmac.h

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,6 @@ struct stmmac_tx_info {
4646
bool is_jumbo;
4747
};
4848

49-
/* Frequently used values are kept adjacent for cache effect */
50-
struct stmmac_tx_queue {
51-
u32 queue_index;
52-
struct stmmac_priv *priv_data;
53-
struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
54-
struct dma_desc *dma_tx;
55-
struct sk_buff **tx_skbuff;
56-
struct stmmac_tx_info *tx_skbuff_dma;
57-
unsigned int cur_tx;
58-
unsigned int dirty_tx;
59-
dma_addr_t dma_tx_phy;
60-
u32 tx_tail_addr;
61-
};
62-
63-
struct stmmac_rx_queue {
64-
u32 queue_index;
65-
struct stmmac_priv *priv_data;
66-
struct dma_extended_desc *dma_erx;
67-
struct dma_desc *dma_rx ____cacheline_aligned_in_smp;
68-
struct sk_buff **rx_skbuff;
69-
dma_addr_t *rx_skbuff_dma;
70-
struct napi_struct napi ____cacheline_aligned_in_smp;
71-
unsigned int cur_rx;
72-
unsigned int dirty_rx;
73-
u32 rx_zeroc_thresh;
74-
dma_addr_t dma_rx_phy;
75-
u32 rx_tail_addr;
76-
};
77-
7849
struct stmmac_priv {
7950
/* Frequently used values are kept adjacent for cache effect */
8051
struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp;
@@ -85,22 +56,28 @@ struct stmmac_priv {
8556
u32 tx_count_frames;
8657
u32 tx_coal_frames;
8758
u32 tx_coal_timer;
59+
struct stmmac_tx_info *tx_skbuff_dma;
60+
dma_addr_t dma_tx_phy;
8861
int tx_coalesce;
8962
int hwts_tx_en;
9063
bool tx_path_in_lpi_mode;
9164
struct timer_list txtimer;
9265
bool tso;
9366

94-
/* TX Queue */
95-
struct stmmac_tx_queue *tx_queue;
96-
97-
/* RX Queue */
98-
struct stmmac_rx_queue *rx_queue;
99-
67+
struct dma_desc *dma_rx ____cacheline_aligned_in_smp;
68+
struct dma_extended_desc *dma_erx;
69+
struct sk_buff **rx_skbuff;
70+
unsigned int cur_rx;
71+
unsigned int dirty_rx;
10072
unsigned int dma_buf_sz;
10173
unsigned int rx_copybreak;
74+
unsigned int rx_zeroc_thresh;
10275
u32 rx_riwt;
10376
int hwts_rx_en;
77+
dma_addr_t *rx_skbuff_dma;
78+
dma_addr_t dma_rx_phy;
79+
80+
struct napi_struct napi ____cacheline_aligned_in_smp;
10481

10582
void __iomem *ioaddr;
10683
struct net_device *dev;
@@ -142,6 +119,8 @@ struct stmmac_priv {
142119
spinlock_t ptp_lock;
143120
void __iomem *mmcaddr;
144121
void __iomem *ptpaddr;
122+
u32 rx_tail_addr;
123+
u32 tx_tail_addr;
145124
u32 mss;
146125

147126
#ifdef CONFIG_DEBUG_FS

0 commit comments

Comments
 (0)