Lines Matching full:rpm
2 /* Marvell CN10K RPM driver
12 .name = "rpm",
44 .name = "rpm",
77 rpm_t *rpm = rpmd; in is_dev_rpm2() local
79 return (rpm->pdev->device == PCI_DEVID_CN10KB_RPM); in is_dev_rpm2()
82 struct mac_ops *rpm_get_mac_ops(rpm_t *rpm) in rpm_get_mac_ops() argument
84 if (is_dev_rpm2(rpm)) in rpm_get_mac_ops()
90 static void rpm_write(rpm_t *rpm, u64 lmac, u64 offset, u64 val) in rpm_write() argument
92 cgx_write(rpm, lmac, offset, val); in rpm_write()
95 static u64 rpm_read(rpm_t *rpm, u64 lmac, u64 offset) in rpm_read() argument
97 return cgx_read(rpm, lmac, offset); in rpm_read()
100 /* Read HW major version to determine RPM
105 rpm_t *rpm = rpmd; in is_mac_rpmusx() local
107 return rpm_read(rpm, 0, RPMX_CONST1) & 0x700ULL; in is_mac_rpmusx()
112 rpm_t *rpm = rpmd; in rpm_get_nr_lmacs() local
114 return hweight8(rpm_read(rpm, 0, CGXX_CMRX_RX_LMACS) & 0xFULL); in rpm_get_nr_lmacs()
119 rpm_t *rpm = rpmd; in rpm2_get_nr_lmacs() local
121 return hweight8(rpm_read(rpm, 0, RPM2_CMRX_RX_LMACS) & 0xFFULL); in rpm2_get_nr_lmacs()
126 rpm_t *rpm = rpmd; in rpm_lmac_tx_enable() local
129 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_tx_enable()
132 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_tx_enable()
140 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_tx_enable()
146 rpm_t *rpm = rpmd; in rpm_lmac_rx_tx_enable() local
149 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_rx_tx_enable()
152 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_rx_tx_enable()
157 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_rx_tx_enable()
163 rpm_t *rpm = rpmd; in rpm_lmac_enadis_rx_pause_fwding() local
167 if (!rpm) in rpm_lmac_enadis_rx_pause_fwding()
170 lmac = lmac_pdata(lmac_id, rpm); in rpm_lmac_enadis_rx_pause_fwding()
179 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_enadis_rx_pause_fwding()
181 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_enadis_rx_pause_fwding()
183 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_enadis_rx_pause_fwding()
185 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_enadis_rx_pause_fwding()
192 rpm_t *rpm = rpmd; in rpm_lmac_get_pause_frm_status() local
195 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_get_pause_frm_status()
198 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_get_pause_frm_status()
207 static void rpm_cfg_pfc_quanta_thresh(rpm_t *rpm, int lmac_id, in rpm_cfg_pfc_quanta_thresh() argument
263 cfg = rpm_read(rpm, lmac_id, quanta_offset); in rpm_cfg_pfc_quanta_thresh()
272 rpm_write(rpm, lmac_id, quanta_offset, cfg); in rpm_cfg_pfc_quanta_thresh()
274 cfg = rpm_read(rpm, lmac_id, quanta_thresh); in rpm_cfg_pfc_quanta_thresh()
283 rpm_write(rpm, lmac_id, quanta_thresh, cfg); in rpm_cfg_pfc_quanta_thresh()
287 static void rpm2_lmac_cfg_bp(rpm_t *rpm, int lmac_id, u8 tx_pause, u8 rx_pause) in rpm2_lmac_cfg_bp() argument
291 cfg = rpm_read(rpm, lmac_id, RPM2_CMR_RX_OVR_BP); in rpm2_lmac_cfg_bp()
296 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, 1, true); in rpm2_lmac_cfg_bp()
300 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, 0xffff, false); in rpm2_lmac_cfg_bp()
304 rpm_write(rpm, lmac_id, RPM2_CMR_RX_OVR_BP, cfg); in rpm2_lmac_cfg_bp()
307 static void rpm_lmac_cfg_bp(rpm_t *rpm, int lmac_id, u8 tx_pause, u8 rx_pause) in rpm_lmac_cfg_bp() argument
311 cfg = rpm_read(rpm, 0, RPMX_CMR_RX_OVR_BP); in rpm_lmac_cfg_bp()
316 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, 1, true); in rpm_lmac_cfg_bp()
320 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, 0xffff, false); in rpm_lmac_cfg_bp()
324 rpm_write(rpm, 0, RPMX_CMR_RX_OVR_BP, cfg); in rpm_lmac_cfg_bp()
330 rpm_t *rpm = rpmd; in rpm_lmac_enadis_pause_frm() local
333 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_enadis_pause_frm()
336 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_enadis_pause_frm()
341 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_enadis_pause_frm()
343 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_enadis_pause_frm()
346 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_enadis_pause_frm()
348 if (is_dev_rpm2(rpm)) in rpm_lmac_enadis_pause_frm()
349 rpm2_lmac_cfg_bp(rpm, lmac_id, tx_pause, rx_pause); in rpm_lmac_enadis_pause_frm()
351 rpm_lmac_cfg_bp(rpm, lmac_id, tx_pause, rx_pause); in rpm_lmac_enadis_pause_frm()
359 rpm_t *rpm = rpmd; in rpm_lmac_pause_frm_config() local
362 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_pause_frm_config()
364 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_pause_frm_config()
367 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_pause_frm_config()
369 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_pause_frm_config()
372 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_pause_frm_config()
374 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_pause_frm_config()
377 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_pause_frm_config()
379 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_pause_frm_config()
382 if (is_dev_rpm2(rpm)) in rpm_lmac_pause_frm_config()
383 rpm_write(rpm, lmac_id, RPM2_CMR_CHAN_MSK_OR, 0xffff); in rpm_lmac_pause_frm_config()
385 rpm_write(rpm, 0, RPMX_CMR_CHAN_MSK_OR, ~0ULL); in rpm_lmac_pause_frm_config()
388 pfc_class_mask_cfg = is_dev_rpm2(rpm) ? RPM2_CMRX_PRT_CBFC_CTL : in rpm_lmac_pause_frm_config()
390 cfg = rpm_read(rpm, lmac_id, pfc_class_mask_cfg); in rpm_lmac_pause_frm_config()
392 rpm_write(rpm, lmac_id, pfc_class_mask_cfg, cfg); in rpm_lmac_pause_frm_config()
397 rpm_t *rpm = rpmd; in rpm_get_rx_stats() local
400 if (!is_lmac_valid(rpm, lmac_id)) in rpm_get_rx_stats()
403 mutex_lock(&rpm->lock); in rpm_get_rx_stats()
406 idx += lmac_id * rpm->mac_ops->rx_stats_cnt; in rpm_get_rx_stats()
409 val_lo = rpm_read(rpm, 0, RPMX_MTI_STAT_RX_STAT_PAGES_COUNTERX + in rpm_get_rx_stats()
415 val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC); in rpm_get_rx_stats()
419 mutex_unlock(&rpm->lock); in rpm_get_rx_stats()
425 rpm_t *rpm = rpmd; in rpm_get_tx_stats() local
428 if (!is_lmac_valid(rpm, lmac_id)) in rpm_get_tx_stats()
431 mutex_lock(&rpm->lock); in rpm_get_tx_stats()
434 idx += lmac_id * rpm->mac_ops->tx_stats_cnt; in rpm_get_tx_stats()
436 val_lo = rpm_read(rpm, 0, RPMX_MTI_STAT_TX_STAT_PAGES_COUNTERX + in rpm_get_tx_stats()
438 val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC); in rpm_get_tx_stats()
442 mutex_unlock(&rpm->lock); in rpm_get_tx_stats()
448 rpm_t *rpm = rpmd; in rpm_get_lmac_type() local
453 err = cgx_fwi_cmd_generic(req, &resp, rpm, 0); in rpm_get_lmac_type()
461 rpm_t *rpm = rpmd; in rpm_get_lmac_fifo_len() local
466 fifo_len = rpm->mac_ops->fifo_len; in rpm_get_lmac_fifo_len()
467 num_lmacs = rpm->mac_ops->get_nr_lmacs(rpm); in rpm_get_lmac_fifo_len()
476 hi_perf_lmac = rpm_read(rpm, 0, CGXX_CMRX_RX_LMACS); in rpm_get_lmac_fifo_len()
488 static int rpmusx_lmac_internal_loopback(rpm_t *rpm, int lmac_id, bool enable) in rpmusx_lmac_internal_loopback() argument
492 cfg = rpm_read(rpm, lmac_id, RPM2_USX_PCSX_CONTROL1); in rpmusx_lmac_internal_loopback()
498 rpm_write(rpm, lmac_id, RPM2_USX_PCSX_CONTROL1, cfg); in rpmusx_lmac_internal_loopback()
506 rpm_t *rpm = rpmd; in rpm2_get_lmac_fifo_len() local
511 lmac_info = rpm_read(rpm, 0, RPM2_CMRX_RX_LMACS); in rpm2_get_lmac_fifo_len()
517 max_lmac = (rpm_read(rpm, 0, CGX_CONST) >> 24) & 0xFF; in rpm2_get_lmac_fifo_len()
519 fifo_len = rpm->mac_ops->fifo_len / 2; in rpm2_get_lmac_fifo_len()
521 fifo_len = rpm->mac_ops->fifo_len; in rpm2_get_lmac_fifo_len()
553 rpm_t *rpm = rpmd; in rpm_lmac_internal_loopback() local
557 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_internal_loopback()
560 lmac = lmac_pdata(lmac_id, rpm); in rpm_lmac_internal_loopback()
563 dev_err(&rpm->pdev->dev, "loopback not supported for LPC mode\n"); in rpm_lmac_internal_loopback()
567 if (is_dev_rpm2(rpm) && is_mac_rpmusx(rpm)) in rpm_lmac_internal_loopback()
568 return rpmusx_lmac_internal_loopback(rpm, lmac_id, enable); in rpm_lmac_internal_loopback()
570 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_PCS100X_CONTROL1); in rpm_lmac_internal_loopback()
576 rpm_write(rpm, lmac_id, RPMX_MTI_PCS100X_CONTROL1, cfg); in rpm_lmac_internal_loopback()
583 rpm_t *rpm = rpmd; in rpm_lmac_ptp_config() local
586 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_ptp_config()
589 cfg = rpm_read(rpm, lmac_id, RPMX_CMRX_CFG); in rpm_lmac_ptp_config()
598 rpm_write(rpm, lmac_id, RPMX_CMRX_CFG, cfg); in rpm_lmac_ptp_config()
600 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_XIF_MODE); in rpm_lmac_ptp_config()
609 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_XIF_MODE, cfg); in rpm_lmac_ptp_config()
615 rpm_t *rpm = rpmd; in rpm_lmac_pfc_config() local
617 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_pfc_config()
620 pfc_class_mask_cfg = is_dev_rpm2(rpm) ? RPM2_CMRX_PRT_CBFC_CTL : in rpm_lmac_pfc_config()
623 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_pfc_config()
624 class_en = rpm_read(rpm, lmac_id, pfc_class_mask_cfg); in rpm_lmac_pfc_config()
636 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, pfc_en, true); in rpm_lmac_pfc_config()
640 rpm_cfg_pfc_quanta_thresh(rpm, lmac_id, 0xfff, false); in rpm_lmac_pfc_config()
650 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); in rpm_lmac_pfc_config()
651 rpm_write(rpm, lmac_id, pfc_class_mask_cfg, class_en); in rpm_lmac_pfc_config()
658 rpm_t *rpm = rpmd; in rpm_lmac_get_pfc_frm_cfg() local
661 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_get_pfc_frm_cfg()
664 cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); in rpm_lmac_get_pfc_frm_cfg()
676 rpm_t *rpm = rpmd; in rpm_get_fec_stats() local
679 if (!is_lmac_valid(rpm, lmac_id)) in rpm_get_fec_stats()
682 if (rpm->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_NONE) in rpm_get_fec_stats()
685 if (rpm->lmac_idmap[lmac_id]->link_info.fec == OTX2_FEC_BASER) { in rpm_get_fec_stats()
686 val_lo = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_VL0_CCW_LO); in rpm_get_fec_stats()
687 val_hi = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_CW_HI); in rpm_get_fec_stats()
690 val_lo = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_VL0_NCCW_LO); in rpm_get_fec_stats()
691 val_hi = rpm_read(rpm, lmac_id, RPMX_MTI_FCFECX_CW_HI); in rpm_get_fec_stats()
695 if (rpm->lmac_idmap[lmac_id]->link_info.lmac_type_id == in rpm_get_fec_stats()
697 val_lo = rpm_read(rpm, lmac_id, in rpm_get_fec_stats()
699 val_hi = rpm_read(rpm, lmac_id, in rpm_get_fec_stats()
703 val_lo = rpm_read(rpm, lmac_id, in rpm_get_fec_stats()
705 val_hi = rpm_read(rpm, lmac_id, in rpm_get_fec_stats()
711 cfg = rpm_read(rpm, 0, RPMX_MTI_STAT_STATN_CONTROL); in rpm_get_fec_stats()
713 rpm_write(rpm, 0, RPMX_MTI_STAT_STATN_CONTROL, cfg); in rpm_get_fec_stats()
715 val_lo = rpm_read(rpm, 0, in rpm_get_fec_stats()
717 val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC); in rpm_get_fec_stats()
720 val_lo = rpm_read(rpm, 0, in rpm_get_fec_stats()
722 val_hi = rpm_read(rpm, 0, RPMX_MTI_STAT_DATA_HI_CDC); in rpm_get_fec_stats()
732 rpm_t *rpm = rpmd; in rpm_lmac_reset() local
734 if (!is_lmac_valid(rpm, lmac_id)) in rpm_lmac_reset()
738 rx_logl_xon = is_dev_rpm2(rpm) ? RPM2_CMRX_RX_LOGL_XON : in rpm_lmac_reset()
742 rpm_write(rpm, lmac_id, rx_logl_xon, cfg); in rpm_lmac_reset()
745 rpm_lmac_internal_loopback(rpm, lmac_id, false); in rpm_lmac_reset()