Lines Matching full:rpm
2 /* Marvell CN10K RPM driver
12 .name = "rpm",
47 .name = "rpm",
83 rpm_t *rpm = rpmd; in is_dev_rpm2() local
85 return (rpm->pdev->device == PCI_DEVID_CN10KB_RPM); in is_dev_rpm2()
88 struct mac_ops *rpm_get_mac_ops(rpm_t *rpm) in rpm_get_mac_ops() argument
90 if (is_dev_rpm2(rpm)) in rpm_get_mac_ops()
96 static void rpm_write(rpm_t *rpm, u64 lmac, u64 offset, u64 val) in rpm_write() argument
98 cgx_write(rpm, lmac, offset, val); in rpm_write()
101 static u64 rpm_read(rpm_t *rpm, u64 lmac, u64 offset) in rpm_read() argument
103 return cgx_read(rpm, lmac, offset); in rpm_read()
106 /* Read HW major version to determine RPM
111 rpm_t *rpm = rpmd; in is_mac_rpmusx() local
113 return rpm_read(rpm, 0, RPMX_CONST1) & 0x700ULL; in is_mac_rpmusx()
118 rpm_t *rpm = rpmd; in rpm_get_nr_lmacs() local
120 return hweight8(rpm_read(rpm, 0, CGXX_CMRX_RX_LMACS) & 0xFULL); in rpm_get_nr_lmacs()
125 rpm_t *rpm = rpmd; in rpm2_get_nr_lmacs() local
127 return hweight8(rpm_read(rpm, 0, RPM2_CMRX_RX_LMACS) & 0xFFULL); in rpm2_get_nr_lmacs()
132 rpm_t *rpm = rpmd; in rpm_lmac_tx_enable() local
135 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_tx_enable()
138 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_tx_enable()
146 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_tx_enable()
152 rpm_t *rpm = rpmd; in rpm_lmac_rx_tx_enable() local
155 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_rx_tx_enable()
158 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_rx_tx_enable()
163 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_rx_tx_enable()
169 rpm_t *rpm = rpmd; in rpm_lmac_enadis_rx_pause_fwding() local
173 if (!rpm) in rpm_lmac_enadis_rx_pause_fwding()
176 lmac = lmac_pdata(lmac_id, rpm); in rpm_lmac_enadis_rx_pause_fwding()
185 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_enadis_rx_pause_fwding()
187 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_enadis_rx_pause_fwding()
189 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_enadis_rx_pause_fwding()
191 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_enadis_rx_pause_fwding()
198 rpm_t *rpm = rpmd; in rpm_lmac_get_pause_frm_status() local
201 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_get_pause_frm_status()
204 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_get_pause_frm_status()
213 static void rpm_cfg_pfc_quanta_thresh(rpm_t *rpm, int lmac_id, in rpm_cfg_pfc_quanta_thresh() argument
269 cfg = rpm_read(rpm, lmac_id, quanta_offset); in rpm_cfg_pfc_quanta_thresh()
278 rpm_write(rpm, lmac_id, quanta_offset, cfg); in rpm_cfg_pfc_quanta_thresh()
280 cfg = rpm_read(rpm, lmac_id, quanta_thresh); in rpm_cfg_pfc_quanta_thresh()
289 rpm_write(rpm, lmac_id, quanta_thresh, cfg); in rpm_cfg_pfc_quanta_thresh()
293 static void rpm2_lmac_cfg_bp(rpm_t *rpm, int lmac_id, u8 tx_pause, u8 rx_pause) in rpm2_lmac_cfg_bp() argument
297 cfg = rpm_read(rpm, lmac_id, RPM2_CMR_RX_OVR_BP); in rpm2_lmac_cfg_bp()
302 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, 1, true); in rpm2_lmac_cfg_bp()
306 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, 0xffff, false); in rpm2_lmac_cfg_bp()
310 rpm_write(rpm, lmac_id, RPM2_CMR_RX_OVR_BP, cfg); in rpm2_lmac_cfg_bp()
313 static void rpm_lmac_cfg_bp(rpm_t *rpm, int lmac_id, u8 tx_pause, u8 rx_pause) in rpm_lmac_cfg_bp() argument
317 cfg = rpm_read(rpm, 0, RPMX_CMR_RX_OVR_BP); in rpm_lmac_cfg_bp()
322 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, 1, true); in rpm_lmac_cfg_bp()
326 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, 0xffff, false); in rpm_lmac_cfg_bp()
330 rpm_write(rpm, 0, RPMX_CMR_RX_OVR_BP, cfg); in rpm_lmac_cfg_bp()
336 rpm_t *rpm = rpmd; in rpm_lmac_enadis_pause_frm() local
339 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_enadis_pause_frm()
342 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_enadis_pause_frm()
347 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_enadis_pause_frm()
349 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_enadis_pause_frm()
352 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_enadis_pause_frm()
354 if (is_dev_rpm2(rpm)) in rpm_lmac_enadis_pause_frm()
355 rpm2_lmac_cfg_bp(rpm, lmac_id, tx_pause, rx_pause); in rpm_lmac_enadis_pause_frm()
357 rpm_lmac_cfg_bp(rpm, lmac_id, tx_pause, rx_pause); in rpm_lmac_enadis_pause_frm()
365 rpm_t *rpm = rpmd; in rpm_lmac_pause_frm_config() local
368 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_pause_frm_config()
370 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_pause_frm_config()
373 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_pause_frm_config()
375 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_pause_frm_config()
378 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_pause_frm_config()
380 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_pause_frm_config()
383 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_pause_frm_config()
385 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_pause_frm_config()
388 if (is_dev_rpm2(rpm)) in rpm_lmac_pause_frm_config()
389 rpm_write(rpm, lmac_id, RPM2_CMR_CHAN_MSK_OR, 0xffff); in rpm_lmac_pause_frm_config()
391 rpm_write(rpm, 0, RPMX_CMR_CHAN_MSK_OR, ~0ULL); in rpm_lmac_pause_frm_config()
394 pfc_class_mask_cfg = is_dev_rpm2(rpm) ? RPM2_CMRX_PRT_CBFC_CTL : in rpm_lmac_pause_frm_config()
396 cfg = rpm_read(rpm, lmac_id, pfc_class_mask_cfg); in rpm_lmac_pause_frm_config()
398 rpm_write(rpm, lmac_id, pfc_class_mask_cfg, cfg); in rpm_lmac_pause_frm_config()
403 rpm_t *rpm = rpmd; in rpm_get_rx_stats() local
406 if (!is_lmac_valid(rpm, lmac_id)) in rpm_get_rx_stats()
409 mutex_lock(&rpm->lock); in rpm_get_rx_stats()
412 idx += lmac_id * rpm->mac_ops->rx_stats_cnt; in rpm_get_rx_stats()
415 val_lo = rpm_read(rpm, 0, RPMX_MTI_STAT_RX_STAT_PAGES_COUNTERX + in rpm_get_rx_stats()
421 val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC); in rpm_get_rx_stats()
425 mutex_unlock(&rpm->lock); in rpm_get_rx_stats()
431 rpm_t *rpm = rpmd; in rpm_get_tx_stats() local
434 if (!is_lmac_valid(rpm, lmac_id)) in rpm_get_tx_stats()
437 mutex_lock(&rpm->lock); in rpm_get_tx_stats()
440 idx += lmac_id * rpm->mac_ops->tx_stats_cnt; in rpm_get_tx_stats()
442 val_lo = rpm_read(rpm, 0, RPMX_MTI_STAT_TX_STAT_PAGES_COUNTERX + in rpm_get_tx_stats()
444 val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC); in rpm_get_tx_stats()
448 mutex_unlock(&rpm->lock); in rpm_get_tx_stats()
454 rpm_t *rpm = rpmd; in rpm_stats_reset() local
457 if (!is_lmac_valid(rpm, lmac_id)) in rpm_stats_reset()
460 cfg = rpm_read(rpm, 0, RPMX_MTI_STAT_STATN_CONTROL); in rpm_stats_reset()
462 rpm_write(rpm, 0, RPMX_MTI_STAT_STATN_CONTROL, cfg); in rpm_stats_reset()
469 rpm_t *rpm = rpmd; in rpm_get_lmac_type() local
474 err = cgx_fwi_cmd_generic(req, &resp, rpm, lmac_id); in rpm_get_lmac_type()
482 rpm_t *rpm = rpmd; in rpm_get_lmac_fifo_len() local
487 fifo_len = rpm->fifo_len; in rpm_get_lmac_fifo_len()
488 num_lmacs = rpm->mac_ops->get_nr_lmacs(rpm); in rpm_get_lmac_fifo_len()
497 hi_perf_lmac = rpm_read(rpm, 0, CGXX_CMRX_RX_LMACS); in rpm_get_lmac_fifo_len()
509 static int rpmusx_lmac_internal_loopback(rpm_t *rpm, int lmac_id, bool enable) in rpmusx_lmac_internal_loopback() argument
513 cfg = rpm_read(rpm, lmac_id, RPM2_USX_PCSX_CONTROL1); in rpmusx_lmac_internal_loopback()
519 rpm_write(rpm, lmac_id, RPM2_USX_PCSX_CONTROL1, cfg); in rpmusx_lmac_internal_loopback()
527 rpm_t *rpm = rpmd; in rpm2_get_lmac_fifo_len() local
532 lmac_info = rpm_read(rpm, 0, RPM2_CMRX_RX_LMACS); in rpm2_get_lmac_fifo_len()
538 max_lmac = (rpm_read(rpm, 0, CGX_CONST) >> 24) & 0xFF; in rpm2_get_lmac_fifo_len()
540 fifo_len = rpm->fifo_len / 2; in rpm2_get_lmac_fifo_len()
542 fifo_len = rpm->fifo_len; in rpm2_get_lmac_fifo_len()
574 rpm_t *rpm = rpmd; in rpm_lmac_internal_loopback() local
578 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_internal_loopback()
581 lmac = lmac_pdata(lmac_id, rpm); in rpm_lmac_internal_loopback()
584 dev_err(&rpm->pdev->dev, "loopback not supported for LPC mode\n"); in rpm_lmac_internal_loopback()
588 if (is_dev_rpm2(rpm) && is_mac_rpmusx(rpm)) in rpm_lmac_internal_loopback()
589 return rpmusx_lmac_internal_loopback(rpm, lmac_id, enable); in rpm_lmac_internal_loopback()
591 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_PCS100X_CONTROL1); in rpm_lmac_internal_loopback()
597 rpm_write(rpm, lmac_id, RPMX_MTI_PCS100X_CONTROL1, cfg); in rpm_lmac_internal_loopback()
604 rpm_t *rpm = rpmd; in rpm_lmac_ptp_config() local
607 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_ptp_config()
610 cfg = rpm_read(rpm, lmac_id, RPMX_CMRX_CFG); in rpm_lmac_ptp_config()
619 rpm_write(rpm, lmac_id, RPMX_CMRX_CFG, cfg); in rpm_lmac_ptp_config()
621 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_XIF_MODE); in rpm_lmac_ptp_config()
630 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_XIF_MODE, cfg); in rpm_lmac_ptp_config()
636 rpm_t *rpm = rpmd; in rpm_lmac_pfc_config() local
638 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_pfc_config()
641 pfc_class_mask_cfg = is_dev_rpm2(rpm) ? RPM2_CMRX_PRT_CBFC_CTL : in rpm_lmac_pfc_config()
644 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_pfc_config()
645 class_en = rpm_read(rpm, lmac_id, pfc_class_mask_cfg); in rpm_lmac_pfc_config()
657 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, pfc_en, true); in rpm_lmac_pfc_config()
661 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, 0xfff, false); in rpm_lmac_pfc_config()
671 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_pfc_config()
672 rpm_write(rpm, lmac_id, pfc_class_mask_cfg, class_en); in rpm_lmac_pfc_config()
679 rpm_t *rpm = rpmd; in rpm_lmac_get_pfc_frm_cfg() local
682 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_get_pfc_frm_cfg()
685 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_get_pfc_frm_cfg()
697 rpm_t *rpm = rpmd; in rpm_get_fec_stats() local
700 if (!is_lmac_valid(rpm, lmac_id)) in rpm_get_fec_stats()
703 if (rpm->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_NONE) in rpm_get_fec_stats()
709 mutex_lock(&rpm->lock); in rpm_get_fec_stats()
710 if (rpm->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_BASER) { in rpm_get_fec_stats()
711 val_lo = rpm_read(rpm, 0, RPMX_MTI_FCFECX_VL0_CCW_LO(lmac_id)); in rpm_get_fec_stats()
712 val_hi = rpm_read(rpm, 0, RPMX_MTI_FCFECX_CW_HI(lmac_id)); in rpm_get_fec_stats()
715 val_lo = rpm_read(rpm, 0, RPMX_MTI_FCFECX_VL0_NCCW_LO(lmac_id)); in rpm_get_fec_stats()
716 val_hi = rpm_read(rpm, 0, RPMX_MTI_FCFECX_CW_HI(lmac_id)); in rpm_get_fec_stats()
720 if (rpm->lmac_idmap[lmac_id]->link_info.lmac_type_id == in rpm_get_fec_stats()
722 val_lo = rpm_read(rpm, 0, in rpm_get_fec_stats()
724 val_hi = rpm_read(rpm, 0, in rpm_get_fec_stats()
728 val_lo = rpm_read(rpm, 0, in rpm_get_fec_stats()
730 val_hi = rpm_read(rpm, 0, in rpm_get_fec_stats()
736 cfg = rpm_read(rpm, 0, RPMX_MTI_RSFEC_STAT_STATN_CONTROL); in rpm_get_fec_stats()
738 rpm_write(rpm, 0, RPMX_MTI_RSFEC_STAT_STATN_CONTROL, cfg); in rpm_get_fec_stats()
740 val_lo = rpm_read(rpm, 0, in rpm_get_fec_stats()
742 val_hi = rpm_read(rpm, 0, RPMX_MTI_RSFEC_STAT_FAST_DATA_HI_CDC); in rpm_get_fec_stats()
745 val_lo = rpm_read(rpm, 0, in rpm_get_fec_stats()
747 val_hi = rpm_read(rpm, 0, RPMX_MTI_RSFEC_STAT_FAST_DATA_HI_CDC); in rpm_get_fec_stats()
750 mutex_unlock(&rpm->lock); in rpm_get_fec_stats()
758 rpm_t *rpm = rpmd; in rpm_lmac_reset() local
760 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_reset()
764 rx_logl_xon = is_dev_rpm2(rpm) ? RPM2_CMRX_RX_LOGL_XON : in rpm_lmac_reset()
768 rpm_write(rpm, lmac_id, rx_logl_xon, cfg); in rpm_lmac_reset()
771 rpm_lmac_internal_loopback(rpm, lmac_id, false); in rpm_lmac_reset()
778 rpm_t *rpm = rpmd; in rpm_x2p_reset() local
783 for_each_set_bit(lmac_id, &rpm->lmac_bmap, rpm->max_lmac_per_mac) in rpm_x2p_reset()
784 rpm->mac_ops->mac_enadis_rx(rpm, lmac_id, false); in rpm_x2p_reset()
788 cfg = rpm_read(rpm, 0, RPMX_CMR_GLOBAL_CFG); in rpm_x2p_reset()
789 rpm_write(rpm, 0, RPMX_CMR_GLOBAL_CFG, cfg | RPM_NIX0_RESET); in rpm_x2p_reset()
791 cfg = rpm_read(rpm, 0, RPMX_CMR_GLOBAL_CFG); in rpm_x2p_reset()
793 rpm_write(rpm, 0, RPMX_CMR_GLOBAL_CFG, cfg); in rpm_x2p_reset()
799 rpm_t *rpm = rpmd; in rpm_enadis_rx() local
802 if (!is_lmac_valid(rpm, lmac_id)) in rpm_enadis_rx()
805 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_enadis_rx()
810 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_enadis_rx()