]> git.baikalelectronics.ru Git - kernel.git/commitdiff
octeontx2-af: Don't enable Pause frames by default
authorHariprasad Kelam <hkelam@marvell.com>
Wed, 9 Feb 2022 07:15:16 +0000 (12:45 +0530)
committerDavid S. Miller <davem@davemloft.net>
Wed, 9 Feb 2022 13:02:33 +0000 (13:02 +0000)
Current implementation is such that 802.3x pause frames are
enabled by default.  As CGX and RPM blocks support PFC
(priority flow control) also, instead of driver enabling one
between them enable them upon request from PF or its VFs.
Also add support to disable pause frames in driver unbind.

Signed-off-by: Hariprasad Kelam <hkelam@marvell.com>
Signed-off-by: Sunil Kovvuri Goutham <sgoutham@marvell.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/octeontx2/af/cgx.c
drivers/net/ethernet/marvell/octeontx2/af/rpm.c
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c

index 3631d612aaca1d36e5496d12d3f89700fa2b811a..fb7069c757f52e97394537b2b0f9f31758c23325 100644 (file)
@@ -782,21 +782,8 @@ static void cgx_lmac_pause_frm_config(void *cgxd, int lmac_id, bool enable)
 
        if (!is_lmac_valid(cgx, lmac_id))
                return;
-       if (enable) {
-               /* Enable receive pause frames */
-               cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
-               cfg |= CGX_SMUX_RX_FRM_CTL_CTL_BCK;
-               cgx_write(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL, cfg);
-
-               cfg = cgx_read(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL);
-               cfg |= CGX_GMP_GMI_RXX_FRM_CTL_CTL_BCK;
-               cgx_write(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL, cfg);
-
-               /* Enable pause frames transmission */
-               cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_TX_CTL);
-               cfg |= CGX_SMUX_TX_CTL_L2P_BP_CONV;
-               cgx_write(cgx, lmac_id, CGXX_SMUX_TX_CTL, cfg);
 
+       if (enable) {
                /* Set pause time and interval */
                cgx_write(cgx, lmac_id, CGXX_SMUX_TX_PAUSE_PKT_TIME,
                          DEFAULT_PAUSE_TIME);
@@ -813,21 +800,21 @@ static void cgx_lmac_pause_frm_config(void *cgxd, int lmac_id, bool enable)
                cfg &= ~0xFFFFULL;
                cgx_write(cgx, lmac_id, CGXX_GMP_GMI_TX_PAUSE_PKT_INTERVAL,
                          cfg | (DEFAULT_PAUSE_TIME / 2));
-       } else {
-               /* ALL pause frames received are completely ignored */
-               cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
-               cfg &= ~CGX_SMUX_RX_FRM_CTL_CTL_BCK;
-               cgx_write(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL, cfg);
+       }
 
-               cfg = cgx_read(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL);
-               cfg &= ~CGX_GMP_GMI_RXX_FRM_CTL_CTL_BCK;
-               cgx_write(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL, cfg);
+       /* ALL pause frames received are completely ignored */
+       cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL);
+       cfg &= ~CGX_SMUX_RX_FRM_CTL_CTL_BCK;
+       cgx_write(cgx, lmac_id, CGXX_SMUX_RX_FRM_CTL, cfg);
 
-               /* Disable pause frames transmission */
-               cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_TX_CTL);
-               cfg &= ~CGX_SMUX_TX_CTL_L2P_BP_CONV;
-               cgx_write(cgx, lmac_id, CGXX_SMUX_TX_CTL, cfg);
-       }
+       cfg = cgx_read(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL);
+       cfg &= ~CGX_GMP_GMI_RXX_FRM_CTL_CTL_BCK;
+       cgx_write(cgx, lmac_id, CGXX_GMP_GMI_RXX_FRM_CTL, cfg);
+
+       /* Disable pause frames transmission */
+       cfg = cgx_read(cgx, lmac_id, CGXX_SMUX_TX_CTL);
+       cfg &= ~CGX_SMUX_TX_CTL_L2P_BP_CONV;
+       cgx_write(cgx, lmac_id, CGXX_SMUX_TX_CTL, cfg);
 }
 
 void cgx_lmac_ptp_config(void *cgxd, int lmac_id, bool enable)
index 9ea2f6ac38ec18fc1269bd59f0b787a05746b4c3..8c0b35a868cfe933bd31189c5707ce62a026017b 100644 (file)
@@ -167,26 +167,6 @@ void rpm_lmac_pause_frm_config(void *rpmd, int lmac_id, bool enable)
        u64 cfg;
 
        if (enable) {
-               /* Enable 802.3 pause frame mode */
-               cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
-               cfg &= ~RPMX_MTI_MAC100X_COMMAND_CONFIG_PFC_MODE;
-               rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
-
-               /* Enable receive pause frames */
-               cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
-               cfg &= ~RPMX_MTI_MAC100X_COMMAND_CONFIG_RX_P_DISABLE;
-               rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
-
-               /* Enable forward pause to TX block */
-               cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
-               cfg &= ~RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE;
-               rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
-
-               /* Enable pause frames transmission */
-               cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
-               cfg &= ~RPMX_MTI_MAC100X_COMMAND_CONFIG_TX_P_DISABLE;
-               rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
-
                /* Set pause time and interval */
                cfg = rpm_read(rpm, lmac_id,
                               RPMX_MTI_MAC100X_CL01_PAUSE_QUANTA);
@@ -199,23 +179,22 @@ void rpm_lmac_pause_frm_config(void *rpmd, int lmac_id, bool enable)
                cfg &= ~0xFFFFULL;
                rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_CL01_QUANTA_THRESH,
                          cfg | (RPM_DEFAULT_PAUSE_TIME / 2));
+       }
 
-       } else {
-               /* ALL pause frames received are completely ignored */
-               cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
-               cfg |= RPMX_MTI_MAC100X_COMMAND_CONFIG_RX_P_DISABLE;
-               rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
+       /* ALL pause frames received are completely ignored */
+       cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
+       cfg |= RPMX_MTI_MAC100X_COMMAND_CONFIG_RX_P_DISABLE;
+       rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
 
-               /* Disable forward pause to TX block */
-               cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
-               cfg |= RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE;
-               rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
+       /* Disable forward pause to TX block */
+       cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
+       cfg |= RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE;
+       rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
 
-               /* Disable pause frames transmission */
-               cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
-               cfg |= RPMX_MTI_MAC100X_COMMAND_CONFIG_TX_P_DISABLE;
-               rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
-       }
+       /* Disable pause frames transmission */
+       cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG);
+       cfg |= RPMX_MTI_MAC100X_COMMAND_CONFIG_TX_P_DISABLE;
+       rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg);
 }
 
 int rpm_get_rx_stats(void *rpmd, int lmac_id, int idx, u64 *rx_stat)
index 97fb61915379a1b3befdb6a0a57bbcf7ba10a947..811d775a97524bccdad4f9a018d5b88f1f57ad2b 100644 (file)
@@ -296,7 +296,6 @@ static int nix_interface_init(struct rvu *rvu, u16 pcifunc, int type, int nixlf,
        struct rvu_hwinfo *hw = rvu->hw;
        struct sdp_node_info *sdp_info;
        int pkind, pf, vf, lbkid, vfid;
-       struct mac_ops *mac_ops;
        u8 cgx_id, lmac_id;
        bool from_vf;
        int err;
@@ -326,13 +325,6 @@ static int nix_interface_init(struct rvu *rvu, u16 pcifunc, int type, int nixlf,
                cgx_set_pkind(rvu_cgx_pdata(cgx_id, rvu), lmac_id, pkind);
                rvu_npc_set_pkind(rvu, pkind, pfvf);
 
-               mac_ops = get_mac_ops(rvu_cgx_pdata(cgx_id, rvu));
-
-               /* By default we enable pause frames */
-               if ((pcifunc & RVU_PFVF_FUNC_MASK) == 0)
-                       mac_ops->mac_enadis_pause_frm(rvu_cgx_pdata(cgx_id,
-                                                                   rvu),
-                                                     lmac_id, true, true);
                break;
        case NIX_INTF_TYPE_LBK:
                vf = (pcifunc & RVU_PFVF_FUNC_MASK) - 1;
index 92c0ddb602ca89a59a24a5b9f417f581df7b110e..52615bd9b9bfd203c368d89c0d79cabd5a63c24e 100644 (file)
@@ -269,6 +269,7 @@ unlock:
        mutex_unlock(&pfvf->mbox.lock);
        return err;
 }
+EXPORT_SYMBOL(otx2_config_pause_frm);
 
 int otx2_set_flowkey_cfg(struct otx2_nic *pfvf)
 {
index 86c1c2f77bd762411b018a424453c72936c0bdc5..67fbe6ec00301ec663f089ceda9243f1db07e709 100644 (file)
@@ -1697,9 +1697,6 @@ int otx2_open(struct net_device *netdev)
        if (pf->linfo.link_up && !(pf->pcifunc & RVU_PFVF_FUNC_MASK))
                otx2_handle_link_event(pf);
 
-       /* Restore pause frame settings */
-       otx2_config_pause_frm(pf);
-
        /* Install DMAC Filters */
        if (pf->flags & OTX2_FLAG_DMACFLTR_SUPPORT)
                otx2_dmacflt_reinstall_flows(pf);
@@ -2782,10 +2779,6 @@ static int otx2_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        /* Enable link notifications */
        otx2_cgx_config_linkevents(pf, true);
 
-       /* Enable pause frames by default */
-       pf->flags |= OTX2_FLAG_RX_PAUSE_ENABLED;
-       pf->flags |= OTX2_FLAG_TX_PAUSE_ENABLED;
-
        return 0;
 
 err_pf_sriov_init:
@@ -2929,6 +2922,14 @@ static void otx2_remove(struct pci_dev *pdev)
        if (pf->flags & OTX2_FLAG_RX_TSTAMP_ENABLED)
                otx2_config_hw_rx_tstamp(pf, false);
 
+       /* Disable 802.3x pause frames */
+       if (pf->flags & OTX2_FLAG_RX_PAUSE_ENABLED ||
+           (pf->flags & OTX2_FLAG_TX_PAUSE_ENABLED)) {
+               pf->flags &= ~OTX2_FLAG_RX_PAUSE_ENABLED;
+               pf->flags &= ~OTX2_FLAG_TX_PAUSE_ENABLED;
+               otx2_config_pause_frm(pf);
+       }
+
        cancel_work_sync(&pf->reset_task);
        /* Disable link notifications */
        otx2_cgx_config_linkevents(pf, false);
index d96c8903c67eeb20e1a5261ff46740122cc5811c..c154b09ec12f0ff395e5eb3037a16bd9e5e61e0b 100644 (file)
@@ -702,10 +702,6 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        if (err)
                goto err_unreg_netdev;
 
-       /* Enable pause frames by default */
-       vf->flags |= OTX2_FLAG_RX_PAUSE_ENABLED;
-       vf->flags |= OTX2_FLAG_TX_PAUSE_ENABLED;
-
        return 0;
 
 err_unreg_netdev:
@@ -740,6 +736,14 @@ static void otx2vf_remove(struct pci_dev *pdev)
 
        vf = netdev_priv(netdev);
 
+       /* Disable 802.3x pause frames */
+       if (vf->flags & OTX2_FLAG_RX_PAUSE_ENABLED ||
+           (vf->flags & OTX2_FLAG_TX_PAUSE_ENABLED)) {
+               vf->flags &= ~OTX2_FLAG_RX_PAUSE_ENABLED;
+               vf->flags &= ~OTX2_FLAG_TX_PAUSE_ENABLED;
+               otx2_config_pause_frm(vf);
+       }
+
        cancel_work_sync(&vf->reset_task);
        otx2_unregister_dl(vf);
        unregister_netdev(netdev);