Skip to content

Commit

Permalink
Merge branch 'add-mtu-change-with-stmmac-interface-running'
Browse files Browse the repository at this point in the history
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/20220723142933.16030-1-ansuelsmth@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Jul 26, 2022
2 parents aa24649 + 3470079 commit 8e4372e
Show file tree
Hide file tree
Showing 7 changed files with 459 additions and 313 deletions.
6 changes: 3 additions & 3 deletions drivers/net/ethernet/stmicro/stmmac/chain_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum)

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

if (len > bmax) {
Expand Down Expand Up @@ -137,7 +137,7 @@ static void refill_desc3(void *priv_ptr, struct dma_desc *p)
*/
p->des3 = cpu_to_le32((unsigned int)(rx_q->dma_rx_phy +
(((rx_q->dirty_rx) + 1) %
priv->dma_rx_size) *
priv->dma_conf.dma_rx_size) *
sizeof(struct dma_desc)));
}

Expand All @@ -155,7 +155,7 @@ static void clean_desc3(void *priv_ptr, struct dma_desc *p)
*/
p->des3 = cpu_to_le32((unsigned int)((tx_q->dma_tx_phy +
((tx_q->dirty_tx + 1) %
priv->dma_tx_size))
priv->dma_conf.dma_tx_size))
* sizeof(struct dma_desc)));
}

Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/ring_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static int jumbo_frm(void *p, struct sk_buff *skb, int csum)
stmmac_prepare_tx_desc(priv, desc, 1, bmax, csum,
STMMAC_RING_MODE, 0, false, skb->len);
tx_q->tx_skbuff[entry] = NULL;
entry = STMMAC_GET_ENTRY(entry, priv->dma_tx_size);
entry = STMMAC_GET_ENTRY(entry, priv->dma_conf.dma_tx_size);

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

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

Expand Down
21 changes: 13 additions & 8 deletions drivers/net/ethernet/stmicro/stmmac/stmmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ struct stmmac_rfs_entry {
int tc;
};

struct stmmac_dma_conf {
unsigned int dma_buf_sz;

/* RX Queue */
struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES];
unsigned int dma_rx_size;

/* TX Queue */
struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
unsigned int dma_tx_size;
};

struct stmmac_priv {
/* Frequently used values are kept adjacent for cache effect */
u32 tx_coal_frames[MTL_MAX_TX_QUEUES];
Expand All @@ -201,7 +213,6 @@ struct stmmac_priv {
int sph_cap;
u32 sarc_type;

unsigned int dma_buf_sz;
unsigned int rx_copybreak;
u32 rx_riwt[MTL_MAX_TX_QUEUES];
int hwts_rx_en;
Expand All @@ -213,13 +224,7 @@ struct stmmac_priv {
int (*hwif_quirks)(struct stmmac_priv *priv);
struct mutex lock;

/* RX Queue */
struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES];
unsigned int dma_rx_size;

/* TX Queue */
struct stmmac_tx_queue tx_queue[MTL_MAX_TX_QUEUES];
unsigned int dma_tx_size;
struct stmmac_dma_conf dma_conf;

/* Generic channel for NAPI */
struct stmmac_channel channel[STMMAC_CH_MAX];
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ static void stmmac_get_ringparam(struct net_device *netdev,

ring->rx_max_pending = DMA_MAX_RX_SIZE;
ring->tx_max_pending = DMA_MAX_TX_SIZE;
ring->rx_pending = priv->dma_rx_size;
ring->tx_pending = priv->dma_tx_size;
ring->rx_pending = priv->dma_conf.dma_rx_size;
ring->tx_pending = priv->dma_conf.dma_tx_size;
}

static int stmmac_set_ringparam(struct net_device *netdev,
Expand Down
Loading

0 comments on commit 8e4372e

Please sign in to comment.