octeontx2-pf: Fix graceful exit during PFC configuration failure
authorSuman Ghosh <sumang@marvell.com>
Wed, 13 Dec 2023 18:10:44 +0000 (23:40 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Jan 2024 12:42:30 +0000 (12:42 +0000)
[ Upstream commit 8c97ab5448f2096daba11edf8d18a44e1eb6f31d ]

During PFC configuration failure the code was not handling a graceful
exit. This patch fixes the same and add proper code for a graceful exit.

Fixes: 99c969a83d82 ("octeontx2-pf: Add egress PFC support")
Signed-off-by: Suman Ghosh <sumang@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/marvell/octeontx2/nic/otx2_dcbnl.c

index bfddbff..28fb643 100644 (file)
@@ -399,9 +399,10 @@ static int otx2_dcbnl_ieee_getpfc(struct net_device *dev, struct ieee_pfc *pfc)
 static int otx2_dcbnl_ieee_setpfc(struct net_device *dev, struct ieee_pfc *pfc)
 {
        struct otx2_nic *pfvf = netdev_priv(dev);
+       u8 old_pfc_en;
        int err;
 
-       /* Save PFC configuration to interface */
+       old_pfc_en = pfvf->pfc_en;
        pfvf->pfc_en = pfc->pfc_en;
 
        if (pfvf->hw.tx_queues >= NIX_PF_PFC_PRIO_MAX)
@@ -411,13 +412,17 @@ static int otx2_dcbnl_ieee_setpfc(struct net_device *dev, struct ieee_pfc *pfc)
         * supported by the tx queue configuration
         */
        err = otx2_check_pfc_config(pfvf);
-       if (err)
+       if (err) {
+               pfvf->pfc_en = old_pfc_en;
                return err;
+       }
 
 process_pfc:
        err = otx2_config_priority_flow_ctrl(pfvf);
-       if (err)
+       if (err) {
+               pfvf->pfc_en = old_pfc_en;
                return err;
+       }
 
        /* Request Per channel Bpids */
        if (pfc->pfc_en)
@@ -425,6 +430,12 @@ process_pfc:
 
        err = otx2_pfc_txschq_update(pfvf);
        if (err) {
+               if (pfc->pfc_en)
+                       otx2_nix_config_bp(pfvf, false);
+
+               otx2_pfc_txschq_stop(pfvf);
+               pfvf->pfc_en = old_pfc_en;
+               otx2_config_priority_flow_ctrl(pfvf);
                dev_err(pfvf->dev, "%s failed to update TX schedulers\n", __func__);
                return err;
        }