Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'octeontx2-af-fixes'

Hariprasad Kelam says:

====================
octeontx2-af: MAC block fixes for CN10KB

This patch set contains fixes for the issues encountered in testing
CN10KB MAC block RPM_USX.

Patch1: firmware to kernel communication is not working due to wrong
interrupt configuration. CSR addresses are corrected.

Patch2: NIX to RVU PF mapping errors encountered due to wrong firmware
config. Corrects this mapping error.

Patch3: Driver is trying to access non exist cgx/lmac which is resulting
in kernel panic. Address this issue by adding proper checks.

Patch4: MAC features are not getting reset on FLR. Fix the issue by
resetting the stale config.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+99 -9
+30 -3
drivers/net/ethernet/marvell/octeontx2/af/cgx.c
··· 169 169 { 170 170 struct cgx *cgx_dev = cgx_get_pdata(cgx_id); 171 171 172 + /* Software must not access disabled LMAC registers */ 173 + if (!is_lmac_valid(cgx_dev, lmac_id)) 174 + return; 172 175 cgx_write(cgx_dev, lmac_id, offset, val); 173 176 } 174 177 175 178 u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset) 176 179 { 177 180 struct cgx *cgx_dev = cgx_get_pdata(cgx_id); 181 + 182 + /* Software must not access disabled LMAC registers */ 183 + if (!is_lmac_valid(cgx_dev, lmac_id)) 184 + return 0; 178 185 179 186 return cgx_read(cgx_dev, lmac_id, offset); 180 187 } ··· 537 530 int cgx_lmac_internal_loopback(void *cgxd, int lmac_id, bool enable) 538 531 { 539 532 struct cgx *cgx = cgxd; 540 - u8 lmac_type; 533 + struct lmac *lmac; 541 534 u64 cfg; 542 535 543 536 if (!is_lmac_valid(cgx, lmac_id)) 544 537 return -ENODEV; 545 538 546 - lmac_type = cgx->mac_ops->get_lmac_type(cgx, lmac_id); 547 - if (lmac_type == LMAC_MODE_SGMII || lmac_type == LMAC_MODE_QSGMII) { 539 + lmac = lmac_pdata(lmac_id, cgx); 540 + if (lmac->lmac_type == LMAC_MODE_SGMII || 541 + lmac->lmac_type == LMAC_MODE_QSGMII) { 548 542 cfg = cgx_read(cgx, lmac_id, CGXX_GMP_PCS_MRX_CTL); 549 543 if (enable) 550 544 cfg |= CGXX_GMP_PCS_MRX_CTL_LBK; ··· 1564 1556 return 0; 1565 1557 } 1566 1558 1559 + int cgx_lmac_reset(void *cgxd, int lmac_id, u8 pf_req_flr) 1560 + { 1561 + struct cgx *cgx = cgxd; 1562 + u64 cfg; 1563 + 1564 + if (!is_lmac_valid(cgx, lmac_id)) 1565 + return -ENODEV; 1566 + 1567 + /* Resetting PFC related CSRs */ 1568 + cfg = 0xff; 1569 + cgx_write(cgxd, lmac_id, CGXX_CMRX_RX_LOGL_XON, cfg); 1570 + 1571 + if (pf_req_flr) 1572 + cgx_lmac_internal_loopback(cgxd, lmac_id, false); 1573 + return 0; 1574 + } 1575 + 1567 1576 static int cgx_configure_interrupt(struct cgx *cgx, struct lmac *lmac, 1568 1577 int cnt, bool req_free) 1569 1578 { ··· 1700 1675 cgx->lmac_idmap[lmac->lmac_id] = lmac; 1701 1676 set_bit(lmac->lmac_id, &cgx->lmac_bmap); 1702 1677 cgx->mac_ops->mac_pause_frm_config(cgx, lmac->lmac_id, true); 1678 + lmac->lmac_type = cgx->mac_ops->get_lmac_type(cgx, lmac->lmac_id); 1703 1679 } 1704 1680 1705 1681 return cgx_lmac_verify_fwi_version(cgx); ··· 1797 1771 .mac_tx_enable = cgx_lmac_tx_enable, 1798 1772 .pfc_config = cgx_lmac_pfc_config, 1799 1773 .mac_get_pfc_frm_cfg = cgx_lmac_get_pfc_frm_cfg, 1774 + .mac_reset = cgx_lmac_reset, 1800 1775 }; 1801 1776 1802 1777 static int cgx_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+2
drivers/net/ethernet/marvell/octeontx2/af/cgx.h
··· 35 35 #define CGXX_CMRX_INT_ENA_W1S 0x058 36 36 #define CGXX_CMRX_RX_ID_MAP 0x060 37 37 #define CGXX_CMRX_RX_STAT0 0x070 38 + #define CGXX_CMRX_RX_LOGL_XON 0x100 38 39 #define CGXX_CMRX_RX_LMACS 0x128 39 40 #define CGXX_CMRX_RX_DMAC_CTL0 (0x1F8 + mac_ops->csr_offset) 40 41 #define CGX_DMAC_CTL0_CAM_ENABLE BIT_ULL(3) ··· 182 181 u8 *rx_pause); 183 182 int verify_lmac_fc_cfg(void *cgxd, int lmac_id, u8 tx_pause, u8 rx_pause, 184 183 int pfvf_idx); 184 + int cgx_lmac_reset(void *cgxd, int lmac_id, u8 pf_req_flr); 185 185 #endif /* CGX_H */
+3
drivers/net/ethernet/marvell/octeontx2/af/lmac_common.h
··· 24 24 * @cgx: parent cgx port 25 25 * @mcast_filters_count: Number of multicast filters installed 26 26 * @lmac_id: lmac port id 27 + * @lmac_type: lmac type like SGMII/XAUI 27 28 * @cmd_pend: flag set before new command is started 28 29 * flag cleared after command response is received 29 30 * @name: lmac port name ··· 44 43 struct cgx *cgx; 45 44 u8 mcast_filters_count; 46 45 u8 lmac_id; 46 + u8 lmac_type; 47 47 bool cmd_pend; 48 48 char *name; 49 49 }; ··· 127 125 128 126 int (*mac_get_pfc_frm_cfg)(void *cgxd, int lmac_id, 129 127 u8 *tx_pause, u8 *rx_pause); 128 + int (*mac_reset)(void *cgxd, int lmac_id, u8 pf_req_flr); 130 129 131 130 /* FEC stats */ 132 131 int (*get_fec_stats)(void *cgxd, int lmac_id,
+28 -4
drivers/net/ethernet/marvell/octeontx2/af/rpm.c
··· 37 37 .mac_tx_enable = rpm_lmac_tx_enable, 38 38 .pfc_config = rpm_lmac_pfc_config, 39 39 .mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg, 40 + .mac_reset = rpm_lmac_reset, 40 41 }; 41 42 42 43 static struct mac_ops rpm2_mac_ops = { ··· 48 47 .int_set_reg = RPM2_CMRX_SW_INT_ENA_W1S, 49 48 .irq_offset = 1, 50 49 .int_ena_bit = BIT_ULL(0), 51 - .lmac_fwi = RPM_LMAC_FWI, 50 + .lmac_fwi = RPM2_LMAC_FWI, 52 51 .non_contiguous_serdes_lane = true, 53 52 .rx_stats_cnt = 43, 54 53 .tx_stats_cnt = 34, ··· 69 68 .mac_tx_enable = rpm_lmac_tx_enable, 70 69 .pfc_config = rpm_lmac_pfc_config, 71 70 .mac_get_pfc_frm_cfg = rpm_lmac_get_pfc_frm_cfg, 71 + .mac_reset = rpm_lmac_reset, 72 72 }; 73 73 74 74 bool is_dev_rpm2(void *rpmd) ··· 539 537 int rpm_lmac_internal_loopback(void *rpmd, int lmac_id, bool enable) 540 538 { 541 539 rpm_t *rpm = rpmd; 542 - u8 lmac_type; 540 + struct lmac *lmac; 543 541 u64 cfg; 544 542 545 543 if (!is_lmac_valid(rpm, lmac_id)) 546 544 return -ENODEV; 547 - lmac_type = rpm->mac_ops->get_lmac_type(rpm, lmac_id); 548 545 549 - if (lmac_type == LMAC_MODE_QSGMII || lmac_type == LMAC_MODE_SGMII) { 546 + lmac = lmac_pdata(lmac_id, rpm); 547 + if (lmac->lmac_type == LMAC_MODE_QSGMII || 548 + lmac->lmac_type == LMAC_MODE_SGMII) { 550 549 dev_err(&rpm->pdev->dev, "loopback not supported for LPC mode\n"); 551 550 return 0; 552 551 } ··· 713 710 val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC); 714 711 rsp->fec_uncorr_blks = (val_hi << 32 | val_lo); 715 712 } 713 + 714 + return 0; 715 + } 716 + 717 + int rpm_lmac_reset(void *rpmd, int lmac_id, u8 pf_req_flr) 718 + { 719 + u64 rx_logl_xon, cfg; 720 + rpm_t *rpm = rpmd; 721 + 722 + if (!is_lmac_valid(rpm, lmac_id)) 723 + return -ENODEV; 724 + 725 + /* Resetting PFC related CSRs */ 726 + rx_logl_xon = is_dev_rpm2(rpm) ? RPM2_CMRX_RX_LOGL_XON : 727 + RPMX_CMRX_RX_LOGL_XON; 728 + cfg = 0xff; 729 + 730 + rpm_write(rpm, lmac_id, rx_logl_xon, cfg); 731 + 732 + if (pf_req_flr) 733 + rpm_lmac_internal_loopback(rpm, lmac_id, false); 716 734 717 735 return 0; 718 736 }
+4 -1
drivers/net/ethernet/marvell/octeontx2/af/rpm.h
··· 74 74 #define RPMX_MTI_MAC100X_CL01_PAUSE_QUANTA 0x80A8 75 75 #define RPMX_MTI_MAC100X_CL89_PAUSE_QUANTA 0x8108 76 76 #define RPM_DEFAULT_PAUSE_TIME 0x7FF 77 + #define RPMX_CMRX_RX_LOGL_XON 0x4100 77 78 78 79 #define RPMX_MTI_MAC100X_XIF_MODE 0x8100 79 80 #define RPMX_ONESTEP_ENABLE BIT_ULL(5) ··· 95 94 96 95 /* CN10KB CSR Declaration */ 97 96 #define RPM2_CMRX_SW_INT 0x1b0 98 - #define RPM2_CMRX_SW_INT_ENA_W1S 0x1b8 97 + #define RPM2_CMRX_SW_INT_ENA_W1S 0x1c8 98 + #define RPM2_LMAC_FWI 0x12 99 99 #define RPM2_CMR_CHAN_MSK_OR 0x3120 100 100 #define RPM2_CMR_RX_OVR_BP_EN BIT_ULL(2) 101 101 #define RPM2_CMR_RX_OVR_BP_BP BIT_ULL(1) ··· 133 131 int rpm2_get_nr_lmacs(void *rpmd); 134 132 bool is_dev_rpm2(void *rpmd); 135 133 int rpm_get_fec_stats(void *cgxd, int lmac_id, struct cgx_fec_stats_rsp *rsp); 134 + int rpm_lmac_reset(void *rpmd, int lmac_id, u8 pf_req_flr); 136 135 #endif /* RPM_H */
+1
drivers/net/ethernet/marvell/octeontx2/af/rvu.c
··· 2629 2629 * Since LF is detached use LF number as -1. 2630 2630 */ 2631 2631 rvu_npc_free_mcam_entries(rvu, pcifunc, -1); 2632 + rvu_mac_reset(rvu, pcifunc); 2632 2633 2633 2634 mutex_unlock(&rvu->flr_lock); 2634 2635 }
+12
drivers/net/ethernet/marvell/octeontx2/af/rvu.h
··· 23 23 #define PCI_DEVID_OCTEONTX2_LBK 0xA061 24 24 25 25 /* Subsystem Device ID */ 26 + #define PCI_SUBSYS_DEVID_98XX 0xB100 26 27 #define PCI_SUBSYS_DEVID_96XX 0xB200 27 28 #define PCI_SUBSYS_DEVID_CN10K_A 0xB900 28 29 #define PCI_SUBSYS_DEVID_CNF10K_B 0xBC00 ··· 687 686 return rvu->hw->cpt_chan_base + chan; 688 687 } 689 688 689 + static inline bool is_rvu_supports_nix1(struct rvu *rvu) 690 + { 691 + struct pci_dev *pdev = rvu->pdev; 692 + 693 + if (pdev->subsystem_device == PCI_SUBSYS_DEVID_98XX) 694 + return true; 695 + 696 + return false; 697 + } 698 + 690 699 /* Function Prototypes 691 700 * RVU 692 701 */ ··· 895 884 int rvu_cgx_prio_flow_ctrl_cfg(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_pause, 896 885 u16 pfc_en); 897 886 int rvu_cgx_cfg_pause_frm(struct rvu *rvu, u16 pcifunc, u8 tx_pause, u8 rx_pause); 887 + void rvu_mac_reset(struct rvu *rvu, u16 pcifunc); 898 888 u32 rvu_cgx_get_lmac_fifolen(struct rvu *rvu, int cgx, int lmac); 899 889 int npc_get_nixlf_mcam_index(struct npc_mcam *mcam, u16 pcifunc, int nixlf, 900 890 int type);
+19 -1
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
··· 114 114 p2x = cgx_lmac_get_p2x(cgx_id, lmac_id); 115 115 /* Firmware sets P2X_SELECT as either NIX0 or NIX1 */ 116 116 pfvf->nix_blkaddr = BLKADDR_NIX0; 117 - if (p2x == CMR_P2X_SEL_NIX1) 117 + if (is_rvu_supports_nix1(rvu) && p2x == CMR_P2X_SEL_NIX1) 118 118 pfvf->nix_blkaddr = BLKADDR_NIX1; 119 119 } 120 120 ··· 1249 1249 1250 1250 mac_ops->mac_get_pfc_frm_cfg(cgxd, lmac_id, &rsp->tx_pause, &rsp->rx_pause); 1251 1251 return err; 1252 + } 1253 + 1254 + void rvu_mac_reset(struct rvu *rvu, u16 pcifunc) 1255 + { 1256 + int pf = rvu_get_pf(pcifunc); 1257 + struct mac_ops *mac_ops; 1258 + struct cgx *cgxd; 1259 + u8 cgx, lmac; 1260 + 1261 + if (!is_pf_cgxmapped(rvu, pf)) 1262 + return; 1263 + 1264 + rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx, &lmac); 1265 + cgxd = rvu_cgx_pdata(cgx, rvu); 1266 + mac_ops = get_mac_ops(cgxd); 1267 + 1268 + if (mac_ops->mac_reset(cgxd, lmac, !is_vf(pcifunc))) 1269 + dev_err(rvu->dev, "Failed to reset MAC\n"); 1252 1270 }