Skip to content

Commit

Permalink
net/cnxk: flush SQ before configuring MTU
Browse files Browse the repository at this point in the history
[ upstream commit b33bef500a50b750577e3028e7ae8aff08bf3ae9 ]

When try to configure MTU for lower value causes run time failure
due to old bigger packets enqueued. To avoid error interrupts better
to flush the all SQs of this port before configuring new MTU.

Fixes: 8589ec2 ("net/cnxk: support MTU set")

Signed-off-by: Satha Rao <skoteshwar@marvell.com>
  • Loading branch information
ksatha authored and kevintraynor committed Jul 12, 2023
1 parent 36b2f49 commit dd0782d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/net/cnxk/cnxk_ethdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ int cnxk_nix_probe(struct rte_pci_driver *pci_drv,
struct rte_pci_device *pci_dev);
int cnxk_nix_remove(struct rte_pci_device *pci_dev);
int cnxk_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu);
int cnxk_nix_sq_flush(struct rte_eth_dev *eth_dev);
int cnxk_nix_mc_addr_list_configure(struct rte_eth_dev *eth_dev,
struct rte_ether_addr *mc_addr_set,
uint32_t nb_mc_addr);
Expand Down
47 changes: 47 additions & 0 deletions drivers/net/cnxk/cnxk_ethdev_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,44 @@ cnxk_nix_mac_addr_del(struct rte_eth_dev *eth_dev, uint32_t index)
dev->dmac_filter_count--;
}

int
cnxk_nix_sq_flush(struct rte_eth_dev *eth_dev)
{
struct cnxk_eth_dev *dev = cnxk_eth_pmd_priv(eth_dev);
struct rte_eth_dev_data *data = eth_dev->data;
int i, rc = 0;

/* Flush all tx queues */
for (i = 0; i < eth_dev->data->nb_tx_queues; i++) {
struct roc_nix_sq *sq = &dev->sqs[i];

if (eth_dev->data->tx_queues[i] == NULL)
continue;

rc = roc_nix_tm_sq_aura_fc(sq, false);
if (rc) {
plt_err("Failed to disable sqb aura fc, rc=%d", rc);
goto exit;
}

/* Wait for sq entries to be flushed */
rc = roc_nix_tm_sq_flush_spin(sq);
if (rc) {
plt_err("Failed to drain sq, rc=%d\n", rc);
goto exit;
}
if (data->tx_queue_state[i] == RTE_ETH_QUEUE_STATE_STARTED) {
rc = roc_nix_tm_sq_aura_fc(sq, true);
if (rc) {
plt_err("Failed to enable sq aura fc, txq=%u, rc=%d", i, rc);
goto exit;
}
}
}
exit:
return rc;
}

int
cnxk_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
{
Expand Down Expand Up @@ -433,6 +471,15 @@ cnxk_nix_mtu_set(struct rte_eth_dev *eth_dev, uint16_t mtu)
goto exit;
}

/* if new MTU was smaller than old one, then flush all SQs before MTU change */
if (old_frame_size > frame_size) {
if (data->dev_started) {
plt_err("Reducing MTU is not supported when device started");
goto exit;
}
cnxk_nix_sq_flush(eth_dev);
}

frame_size -= RTE_ETHER_CRC_LEN;

/* Update mtu on Tx */
Expand Down

0 comments on commit dd0782d

Please sign in to comment.