mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
Merge branch 'net-stmmac-restore-previous-state-if-tc_setup_dwmac510_mqprio-fails'
Lorenzo Bianconi says: ==================== net: stmmac: restore previous state if tc_setup_dwmac510_mqprio() fails Restore previous mqprio qdisc configuration if tc_setup_dwmac510_mqprio() fails running the following configuration: $tc qdisc add dev eth0 root handle 1: mqprio queues 2@0 2@2 $tc qdisc replace dev eth0 root handle 2: mqprio queues 2@0 2@2 fp E P Propagate FPE preemption-class mapping errors in tc_setup_dwmac510_mqprio() and tc_taprio_configure(). ==================== Link: https://patch.msgid.link/20260911-stmmac-tc_setup_dwmac510_mqprio-error-path-v3-0-a76b1e2547c1@oss.qualcomm.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
dd56c0bc48
|
|
@ -494,7 +494,7 @@ struct stmmac_ops {
|
|||
#define stmmac_set_arp_offload(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, set_arp_offload, __args)
|
||||
#define stmmac_fpe_map_preemption_class(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, mac, fpe_map_preemption_class, __args)
|
||||
stmmac_do_callback(__priv, mac, fpe_map_preemption_class, __args)
|
||||
|
||||
/* PTP and HW Timer helpers */
|
||||
struct stmmac_hwtimestamp {
|
||||
|
|
|
|||
|
|
@ -970,7 +970,7 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
|
|||
struct netlink_ext_ack *extack = qopt->mqprio.extack;
|
||||
struct timespec64 time, current_time, qopt_time;
|
||||
ktime_t current_time_ns;
|
||||
int i, ret = 0;
|
||||
int err, i, ret = 0;
|
||||
u64 ctr;
|
||||
|
||||
if (qopt->base_time < 0)
|
||||
|
|
@ -1120,9 +1120,9 @@ static int tc_taprio_configure(struct stmmac_priv *priv,
|
|||
mutex_unlock(&priv->est_lock);
|
||||
}
|
||||
|
||||
stmmac_fpe_map_preemption_class(priv, priv->dev, extack, 0);
|
||||
err = stmmac_fpe_map_preemption_class(priv, priv->dev, extack, 0);
|
||||
|
||||
return ret;
|
||||
return qopt->cmd == TAPRIO_CMD_DESTROY ? err : ret;
|
||||
}
|
||||
|
||||
static void tc_taprio_stats(struct stmmac_priv *priv,
|
||||
|
|
@ -1237,58 +1237,99 @@ static int tc_query_caps(struct stmmac_priv *priv,
|
|||
}
|
||||
}
|
||||
|
||||
static void stmmac_reset_tc_mqprio(struct net_device *ndev,
|
||||
struct netlink_ext_ack *extack)
|
||||
static int stmmac_set_ndev_tcs(struct net_device *ndev, u8 ntc,
|
||||
struct netdev_tc_txq *tc_to_txq)
|
||||
{
|
||||
int i, err;
|
||||
|
||||
netdev_reset_tc(ndev);
|
||||
if (!ntc)
|
||||
return 0;
|
||||
|
||||
err = netdev_set_num_tc(ndev, ntc);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
for (i = 0; i < ntc; i++) {
|
||||
u16 count, offset;
|
||||
|
||||
count = tc_to_txq[i].count;
|
||||
offset = tc_to_txq[i].offset;
|
||||
netdev_set_tc_queue(ndev, i, count, offset);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stmmac_reset_tc_mqprio(struct net_device *ndev,
|
||||
struct netlink_ext_ack *extack)
|
||||
{
|
||||
struct stmmac_priv *priv = netdev_priv(ndev);
|
||||
|
||||
netdev_reset_tc(ndev);
|
||||
netif_set_real_num_tx_queues(ndev, priv->plat->tx_queues_to_use);
|
||||
stmmac_fpe_map_preemption_class(priv, ndev, extack, 0);
|
||||
|
||||
return stmmac_fpe_map_preemption_class(priv, ndev, extack, 0);
|
||||
}
|
||||
|
||||
static int tc_setup_dwmac510_mqprio(struct stmmac_priv *priv,
|
||||
struct tc_mqprio_qopt_offload *mqprio)
|
||||
{
|
||||
unsigned int ndev_num_tx_queues, num_tx_queues = 0;
|
||||
struct netdev_tc_txq ndev_tc_to_txq[TC_MAX_QUEUE];
|
||||
struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE] = {};
|
||||
struct netlink_ext_ack *extack = mqprio->extack;
|
||||
struct tc_mqprio_qopt *qopt = &mqprio->qopt;
|
||||
u32 offset, count, num_stack_tx_queues = 0;
|
||||
struct net_device *ndev = priv->dev;
|
||||
u32 num_tc = qopt->num_tc;
|
||||
int err;
|
||||
u8 ndev_prio_tc_map[TC_BITMASK + 1];
|
||||
int i, err, ndev_ntc;
|
||||
|
||||
if (!num_tc) {
|
||||
stmmac_reset_tc_mqprio(ndev, extack);
|
||||
return 0;
|
||||
if (!qopt->num_tc)
|
||||
return stmmac_reset_tc_mqprio(ndev, extack);
|
||||
|
||||
if (qopt->num_tc > ARRAY_SIZE(tc_to_txq))
|
||||
return -EINVAL;
|
||||
|
||||
/* save current tc values for reset */
|
||||
ndev_ntc = netdev_get_num_tc(ndev);
|
||||
for (i = 0; i < ARRAY_SIZE(ndev->tc_to_txq); i++)
|
||||
ndev_tc_to_txq[i].combined =
|
||||
READ_ONCE(ndev->tc_to_txq[i].combined);
|
||||
for (i = 0; i < ARRAY_SIZE(ndev_prio_tc_map); i++)
|
||||
ndev_prio_tc_map[i] = READ_ONCE(ndev->prio_tc_map[i]);
|
||||
|
||||
for (i = 0; i < qopt->num_tc; i++) {
|
||||
tc_to_txq[i] = (struct netdev_tc_txq) {
|
||||
.count = qopt->count[i],
|
||||
.offset = qopt->offset[i],
|
||||
};
|
||||
num_tx_queues += qopt->count[i];
|
||||
}
|
||||
|
||||
err = netdev_set_num_tc(ndev, num_tc);
|
||||
err = stmmac_set_ndev_tcs(ndev, qopt->num_tc, tc_to_txq);
|
||||
if (err)
|
||||
return err;
|
||||
goto error_reset_tc;
|
||||
|
||||
for (u32 tc = 0; tc < num_tc; tc++) {
|
||||
offset = qopt->offset[tc];
|
||||
count = qopt->count[tc];
|
||||
num_stack_tx_queues += count;
|
||||
|
||||
err = netdev_set_tc_queue(ndev, tc, count, offset);
|
||||
if (err)
|
||||
goto err_reset_tc;
|
||||
}
|
||||
|
||||
err = netif_set_real_num_tx_queues(ndev, num_stack_tx_queues);
|
||||
ndev_num_tx_queues = ndev->real_num_tx_queues;
|
||||
err = netif_set_real_num_tx_queues(ndev, num_tx_queues);
|
||||
if (err)
|
||||
goto err_reset_tc;
|
||||
goto error_reset_tc;
|
||||
|
||||
err = stmmac_fpe_map_preemption_class(priv, ndev, extack,
|
||||
mqprio->preemptible_tcs);
|
||||
if (err)
|
||||
goto err_reset_tc;
|
||||
goto error_reset_num_tx_queues;
|
||||
|
||||
return 0;
|
||||
|
||||
err_reset_tc:
|
||||
stmmac_reset_tc_mqprio(ndev, extack);
|
||||
error_reset_num_tx_queues:
|
||||
if (netif_set_real_num_tx_queues(ndev, ndev_num_tx_queues))
|
||||
netdev_warn(ndev, "Failed to restore %u TX queues\n",
|
||||
ndev_num_tx_queues);
|
||||
error_reset_tc:
|
||||
stmmac_set_ndev_tcs(ndev, ndev_ntc, ndev_tc_to_txq);
|
||||
for (i = 0; i < ARRAY_SIZE(ndev_prio_tc_map); i++)
|
||||
netdev_set_prio_tc_map(ndev, i, ndev_prio_tc_map[i]);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user