Skip to content

Commit 8e4372e

Browse files
committed
Merge branch 'add-mtu-change-with-stmmac-interface-running'
Christian Marangi says: ==================== Add MTU change with stmmac interface running This series is to permit MTU change while the interface is running. Major rework are needed to permit to allocate a new dma conf based on the new MTU before applying it. This is to make sure there is enough space to allocate all the DMA queue before releasing the stmmac driver. This was tested with a simple way to stress the network while the interface is running. 2 ssh connection to the device: - One generating simple traffic with while true; do free; done - The other making the mtu change with a delay of 1 second The connection is correctly stopped and recovered after the MTU is changed. The first 2 patch of this series are minor fixup that fix problems presented while testing this. One fix a problem when we renable a queue while we are generating a new dma conf. The other is a corner case that was notice while stressing the driver and turning down the interface while there was some traffic. (this is a follow-up of a simpler patch that wanted to add the same feature. It was suggested to first try to check if it was possible to apply the new configuration. Posting as RFC as it does major rework for the new concept of DMA conf) ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents aa24649 + 3470079 commit 8e4372e

File tree

7 files changed

+459
-313
lines changed

7 files changed

+459
-313
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum)
4646

4747
while (len != 0) {
4848
tx_q->tx_skbuff[entry] = NULL;
49-
entry = STMMAC_GET_ENTRY(entry, priv->dma_tx_size);
49+
entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size);
5050
desc = tx_q->dma_tx + entry;
5151

5252
if (len > bmax) {
@@ -137,7 +137,7 @@ static void refill_desc3(void *priv_ptr, struct dma_desc *p)
137137
*/
138138
p->des3 = cpu_to_le32((unsigned int)(rx_q->dma_rx_phy +
139139
(((rx_q->dirty_rx) + 1) %
140-
priv->dma_rx_size) *
140+
priv->dma_conf.dma_rx_size) *
141141
sizeof(struct dma_desc)));
142142
}
143143

@@ -155,7 +155,7 @@ static void clean_desc3(void *priv_ptr, struct dma_desc *p)
155155
*/
156156
p->des3 = cpu_to_le32((unsigned int)((tx_q->dma_tx_phy +
157157
((tx_q->dirty_tx + 1) %
158-
priv->dma_tx_size))
158+
priv->dma_conf.dma_tx_size))
159159
* sizeof(struct dma_desc)));
160160
}
161161

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum)
5151
stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum,
5252
STMMAC_RING_MODE, 0, false, skb->len);
5353
tx_q->tx_skbuff[entry] = NULL;
54-
entry = STMMAC_GET_ENTRY(entry, priv->dma_tx_size);
54+
entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size);
5555

5656
if (priv->extend_desc)
5757
desc = (struct dma_desc *)(tx_q->dma_etx + entry);
@@ -107,7 +107,7 @@ static void refill_desc3(void *priv_ptr, struct dma_desc *p)
107107
struct stmmac_priv *priv = rx_q->priv_data;
108108

109109
/* Fill DES3 in case of RING mode */
110-
if (priv->dma_buf_sz == BUF_SIZE_16KiB)
110+
if (priv->dma_conf.dma_buf_sz == BUF_SIZE_16KiB)
111111
p->des3 = cpu_to_le32(le32_to_cpu(p->des2) + BUF_SIZE_8KiB);
112112
}
113113

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,18 @@ struct stmmac_rfs_entry {
188188
int tc;
189189
};
190190

191+
struct stmmac_dma_conf {
192+
unsigned int dma_buf_sz;
193+
194+
/* RX Queue */
195+
struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES];
196+
unsigned int dma_rx_size;
197+
198+
/* TX Queue */
199+
struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
200+
unsigned int dma_tx_size;
201+
};
202+
191203
struct stmmac_priv {
192204
/* Frequently used values are kept adjacent for cache effect */
193205
u32 tx_coal_frames[MTL_MAX_TX_QUEUES];
@@ -201,7 +213,6 @@ struct stmmac_priv {
201213
int sph_cap;
202214
u32 sarc_type;
203215

204-
unsigned int dma_buf_sz;
205216
unsigned int rx_copybreak;
206217
u32 rx_riwt[MTL_MAX_TX_QUEUES];
207218
int hwts_rx_en;
@@ -213,13 +224,7 @@ struct stmmac_priv {
213224
int (*hwif_quirks)(struct stmmac_priv *priv);
214225
struct mutex lock;
215226

216-
/* RX Queue */
217-
struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES];
218-
unsigned int dma_rx_size;
219-
220-
/* TX Queue */
221-
struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
222-
unsigned int dma_tx_size;
227+
struct stmmac_dma_conf dma_conf;
223228

224229
/* Generic channel for NAPI */
225230
struct stmmac_channel channel[STMMAC_CH_MAX];

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ static void stmmac_get_ringparam(struct net_device *netdev,
485485

486486
ring->rx_max_pending = DMA_MAX_RX_SIZE;
487487
ring->tx_max_pending = DMA_MAX_TX_SIZE;
488-
ring->rx_pending = priv->dma_rx_size;
489-
ring->tx_pending = priv->dma_tx_size;
488+
ring->rx_pending = priv->dma_conf.dma_rx_size;
489+
ring->tx_pending = priv->dma_conf.dma_tx_size;
490490
}
491491

492492
static int stmmac_set_ringparam(struct net_device *netdev,

0 commit comments

Comments
 (0)