• Home
  • Raw
  • Download

Lines Matching refs:dsaf_dev

41 static int hns_dsaf_get_cfg(struct dsaf_device *dsaf_dev)  in hns_dsaf_get_cfg()  argument
51 struct device_node *np = dsaf_dev->dev->of_node, *np_temp; in hns_dsaf_get_cfg()
52 struct platform_device *pdev = to_platform_device(dsaf_dev->dev); in hns_dsaf_get_cfg()
54 if (dev_of_node(dsaf_dev->dev)) { in hns_dsaf_get_cfg()
56 dsaf_dev->dsaf_ver = AE_VERSION_1; in hns_dsaf_get_cfg()
58 dsaf_dev->dsaf_ver = AE_VERSION_2; in hns_dsaf_get_cfg()
59 } else if (is_acpi_node(dsaf_dev->dev->fwnode)) { in hns_dsaf_get_cfg()
61 dsaf_dev->dsaf_ver = AE_VERSION_1; in hns_dsaf_get_cfg()
63 dsaf_dev->dsaf_ver = AE_VERSION_2; in hns_dsaf_get_cfg()
67 dev_err(dsaf_dev->dev, "cannot get cfg data from of or acpi\n"); in hns_dsaf_get_cfg()
71 ret = device_property_read_string(dsaf_dev->dev, "mode", &mode_str); in hns_dsaf_get_cfg()
73 dev_err(dsaf_dev->dev, "get dsaf mode fail, ret=%d!\n", ret); in hns_dsaf_get_cfg()
83 dev_err(dsaf_dev->dev, in hns_dsaf_get_cfg()
84 "%s prs mode str fail!\n", dsaf_dev->ae_dev.name); in hns_dsaf_get_cfg()
87 dsaf_dev->dsaf_mode = (enum dsaf_mode)i; in hns_dsaf_get_cfg()
89 if (dsaf_dev->dsaf_mode > DSAF_MODE_ENABLE) in hns_dsaf_get_cfg()
90 dsaf_dev->dsaf_en = HRD_DSAF_NO_DSAF_MODE; in hns_dsaf_get_cfg()
92 dsaf_dev->dsaf_en = HRD_DSAF_MODE; in hns_dsaf_get_cfg()
97 dsaf_dev->dsaf_tc_mode = HRD_DSAF_8TC_MODE; in hns_dsaf_get_cfg()
99 dsaf_dev->dsaf_tc_mode = HRD_DSAF_4TC_MODE; in hns_dsaf_get_cfg()
101 if (dev_of_node(dsaf_dev->dev)) { in hns_dsaf_get_cfg()
109 dev_err(dsaf_dev->dev, "subctrl info is needed!\n"); in hns_dsaf_get_cfg()
113 dsaf_dev->sc_base = devm_ioremap_resource(&pdev->dev, in hns_dsaf_get_cfg()
115 if (IS_ERR(dsaf_dev->sc_base)) in hns_dsaf_get_cfg()
116 return PTR_ERR(dsaf_dev->sc_base); in hns_dsaf_get_cfg()
121 dev_err(dsaf_dev->dev, "serdes-ctrl info is needed!\n"); in hns_dsaf_get_cfg()
125 dsaf_dev->sds_base = devm_ioremap_resource(&pdev->dev, in hns_dsaf_get_cfg()
127 if (IS_ERR(dsaf_dev->sds_base)) in hns_dsaf_get_cfg()
128 return PTR_ERR(dsaf_dev->sds_base); in hns_dsaf_get_cfg()
130 dsaf_dev->sub_ctrl = syscon; in hns_dsaf_get_cfg()
138 dev_err(dsaf_dev->dev, "ppe-base info is needed!\n"); in hns_dsaf_get_cfg()
142 dsaf_dev->ppe_base = devm_ioremap_resource(&pdev->dev, res); in hns_dsaf_get_cfg()
143 if (IS_ERR(dsaf_dev->ppe_base)) in hns_dsaf_get_cfg()
144 return PTR_ERR(dsaf_dev->ppe_base); in hns_dsaf_get_cfg()
145 dsaf_dev->ppe_paddr = res->start; in hns_dsaf_get_cfg()
147 if (!HNS_DSAF_IS_DEBUG(dsaf_dev)) { in hns_dsaf_get_cfg()
154 dev_err(dsaf_dev->dev, in hns_dsaf_get_cfg()
159 dsaf_dev->io_base = devm_ioremap_resource(&pdev->dev, res); in hns_dsaf_get_cfg()
160 if (IS_ERR(dsaf_dev->io_base)) in hns_dsaf_get_cfg()
161 return PTR_ERR(dsaf_dev->io_base); in hns_dsaf_get_cfg()
164 ret = device_property_read_u32(dsaf_dev->dev, "desc-num", &desc_num); in hns_dsaf_get_cfg()
167 dev_err(dsaf_dev->dev, "get desc-num(%d) fail, ret=%d!\n", in hns_dsaf_get_cfg()
171 dsaf_dev->desc_num = desc_num; in hns_dsaf_get_cfg()
173 ret = device_property_read_u32(dsaf_dev->dev, "reset-field-offset", in hns_dsaf_get_cfg()
176 dev_dbg(dsaf_dev->dev, in hns_dsaf_get_cfg()
179 dsaf_dev->reset_offset = reset_offset; in hns_dsaf_get_cfg()
181 ret = device_property_read_u32(dsaf_dev->dev, "buf-size", &buf_size); in hns_dsaf_get_cfg()
183 dev_err(dsaf_dev->dev, in hns_dsaf_get_cfg()
187 dsaf_dev->buf_size = buf_size; in hns_dsaf_get_cfg()
189 dsaf_dev->buf_size_type = hns_rcb_buf_size2type(buf_size); in hns_dsaf_get_cfg()
190 if (dsaf_dev->buf_size_type < 0) { in hns_dsaf_get_cfg()
191 dev_err(dsaf_dev->dev, in hns_dsaf_get_cfg()
196 dsaf_dev->misc_op = hns_misc_op_get(dsaf_dev); in hns_dsaf_get_cfg()
197 if (!dsaf_dev->misc_op) in hns_dsaf_get_cfg()
200 if (!dma_set_mask_and_coherent(dsaf_dev->dev, DMA_BIT_MASK(64ULL))) in hns_dsaf_get_cfg()
201 dev_dbg(dsaf_dev->dev, "set mask to 64bit\n"); in hns_dsaf_get_cfg()
203 dev_err(dsaf_dev->dev, "set mask to 64bit fail!\n"); in hns_dsaf_get_cfg()
212 static void hns_dsaf_sbm_link_sram_init_en(struct dsaf_device *dsaf_dev) in hns_dsaf_sbm_link_sram_init_en() argument
214 dsaf_set_dev_bit(dsaf_dev, DSAF_CFG_0_REG, DSAF_CFG_SBM_INIT_S, 1); in hns_dsaf_sbm_link_sram_init_en()
223 hns_dsaf_reg_cnt_clr_ce(struct dsaf_device *dsaf_dev, u32 reg_cnt_clr_ce) in hns_dsaf_reg_cnt_clr_ce() argument
225 dsaf_set_dev_bit(dsaf_dev, DSAF_DSA_REG_CNT_CLR_CE_REG, in hns_dsaf_reg_cnt_clr_ce()
235 hns_dsaf_ppe_qid_cfg(struct dsaf_device *dsaf_dev, u32 qid_cfg) in hns_dsaf_ppe_qid_cfg() argument
240 dsaf_set_dev_field(dsaf_dev, in hns_dsaf_ppe_qid_cfg()
247 static void hns_dsaf_mix_def_qid_cfg(struct dsaf_device *dsaf_dev) in hns_dsaf_mix_def_qid_cfg() argument
253 hns_rcb_get_queue_mode(dsaf_dev->dsaf_mode, &max_vfn, &max_q_per_vf); in hns_dsaf_mix_def_qid_cfg()
257 dsaf_set_dev_field(dsaf_dev, in hns_dsaf_mix_def_qid_cfg()
264 static void hns_dsaf_inner_qid_cfg(struct dsaf_device *dsaf_dev) in hns_dsaf_inner_qid_cfg() argument
270 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) in hns_dsaf_inner_qid_cfg()
273 hns_rcb_get_queue_mode(dsaf_dev->dsaf_mode, &max_vfn, &max_q_per_vf); in hns_dsaf_inner_qid_cfg()
277 dsaf_set_dev_field(dsaf_dev, in hns_dsaf_inner_qid_cfg()
291 static void hns_dsaf_sw_port_type_cfg(struct dsaf_device *dsaf_dev, in hns_dsaf_sw_port_type_cfg() argument
297 dsaf_set_dev_field(dsaf_dev, in hns_dsaf_sw_port_type_cfg()
309 static void hns_dsaf_stp_port_type_cfg(struct dsaf_device *dsaf_dev, in hns_dsaf_stp_port_type_cfg() argument
315 dsaf_set_dev_field(dsaf_dev, in hns_dsaf_stp_port_type_cfg()
328 static void hns_dsaf_sbm_cfg(struct dsaf_device *dsaf_dev) in hns_dsaf_sbm_cfg() argument
333 for (i = 0; i < HNS_DSAF_SBM_NUM(dsaf_dev); i++) { in hns_dsaf_sbm_cfg()
334 o_sbm_cfg = dsaf_read_dev(dsaf_dev, in hns_dsaf_sbm_cfg()
338 dsaf_write_dev(dsaf_dev, in hns_dsaf_sbm_cfg()
347 static int hns_dsaf_sbm_cfg_mib_en(struct dsaf_device *dsaf_dev) in hns_dsaf_sbm_cfg_mib_en() argument
355 for (i = 0; i < HNS_DSAF_SBM_NUM(dsaf_dev); i++) { in hns_dsaf_sbm_cfg_mib_en()
357 dsaf_set_dev_bit(dsaf_dev, reg, DSAF_SBM_CFG_MIB_EN_S, 0); in hns_dsaf_sbm_cfg_mib_en()
360 for (i = 0; i < HNS_DSAF_SBM_NUM(dsaf_dev); i++) { in hns_dsaf_sbm_cfg_mib_en()
362 dsaf_set_dev_bit(dsaf_dev, reg, DSAF_SBM_CFG_MIB_EN_S, 1); in hns_dsaf_sbm_cfg_mib_en()
366 for (i = 0; i < HNS_DSAF_SBM_NUM(dsaf_dev); i++) { in hns_dsaf_sbm_cfg_mib_en()
372 dsaf_dev, reg, DSAF_SBM_CFG_MIB_EN_S); in hns_dsaf_sbm_cfg_mib_en()
378 dev_err(dsaf_dev->dev, in hns_dsaf_sbm_cfg_mib_en()
380 dsaf_dev->ae_dev.name, i); in hns_dsaf_sbm_cfg_mib_en()
392 static void hns_dsaf_sbm_bp_wl_cfg(struct dsaf_device *dsaf_dev) in hns_dsaf_sbm_bp_wl_cfg() argument
401 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsaf_sbm_bp_wl_cfg()
408 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsaf_sbm_bp_wl_cfg()
411 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsaf_sbm_bp_wl_cfg()
416 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsaf_sbm_bp_wl_cfg()
419 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsaf_sbm_bp_wl_cfg()
424 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsaf_sbm_bp_wl_cfg()
427 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsaf_sbm_bp_wl_cfg()
434 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsaf_sbm_bp_wl_cfg()
438 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsaf_sbm_bp_wl_cfg()
445 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsaf_sbm_bp_wl_cfg()
451 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsaf_sbm_bp_wl_cfg()
456 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsaf_sbm_bp_wl_cfg()
462 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsaf_sbm_bp_wl_cfg()
467 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsaf_sbm_bp_wl_cfg()
471 static void hns_dsafv2_sbm_bp_wl_cfg(struct dsaf_device *dsaf_dev) in hns_dsafv2_sbm_bp_wl_cfg() argument
480 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsafv2_sbm_bp_wl_cfg()
487 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsafv2_sbm_bp_wl_cfg()
490 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsafv2_sbm_bp_wl_cfg()
495 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsafv2_sbm_bp_wl_cfg()
498 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsafv2_sbm_bp_wl_cfg()
503 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsafv2_sbm_bp_wl_cfg()
506 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsafv2_sbm_bp_wl_cfg()
513 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsafv2_sbm_bp_wl_cfg()
517 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsafv2_sbm_bp_wl_cfg()
524 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsafv2_sbm_bp_wl_cfg()
530 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsafv2_sbm_bp_wl_cfg()
540 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsafv2_sbm_bp_wl_cfg()
546 o_sbm_bp_cfg = dsaf_read_dev(dsaf_dev, reg); in hns_dsafv2_sbm_bp_wl_cfg()
553 dsaf_write_dev(dsaf_dev, reg, o_sbm_bp_cfg); in hns_dsafv2_sbm_bp_wl_cfg()
561 static void hns_dsaf_voq_bp_all_thrd_cfg(struct dsaf_device *dsaf_dev) in hns_dsaf_voq_bp_all_thrd_cfg() argument
568 dsaf_dev, DSAF_VOQ_BP_ALL_THRD_0_REG + 0x40 * i); in hns_dsaf_voq_bp_all_thrd_cfg()
585 dsaf_dev, DSAF_VOQ_BP_ALL_THRD_0_REG + 0x40 * i, in hns_dsaf_voq_bp_all_thrd_cfg()
591 struct dsaf_device *dsaf_dev, in hns_dsaf_tbl_tcam_match_cfg() argument
594 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MATCH_CFG_L_REG, in hns_dsaf_tbl_tcam_match_cfg()
596 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MATCH_CFG_H_REG, in hns_dsaf_tbl_tcam_match_cfg()
606 struct dsaf_device *dsaf_dev, in hns_dsaf_tbl_tcam_data_cfg() argument
609 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_LOW_0_REG, in hns_dsaf_tbl_tcam_data_cfg()
611 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_HIGH_0_REG, in hns_dsaf_tbl_tcam_data_cfg()
621 struct dsaf_device *dsaf_dev, in hns_dsaf_tbl_tcam_mcast_cfg() argument
626 mcast_cfg4 = dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_4_0_REG); in hns_dsaf_tbl_tcam_mcast_cfg()
634 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_4_0_REG, mcast_cfg4); in hns_dsaf_tbl_tcam_mcast_cfg()
636 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_3_0_REG, in hns_dsaf_tbl_tcam_mcast_cfg()
639 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_2_0_REG, in hns_dsaf_tbl_tcam_mcast_cfg()
642 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_1_0_REG, in hns_dsaf_tbl_tcam_mcast_cfg()
645 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_0_0_REG, in hns_dsaf_tbl_tcam_mcast_cfg()
655 struct dsaf_device *dsaf_dev, in hns_dsaf_tbl_tcam_ucast_cfg() argument
660 ucast_cfg1 = dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_UCAST_CFG_0_REG); in hns_dsaf_tbl_tcam_ucast_cfg()
672 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_UCAST_CFG_0_REG, ucast_cfg1); in hns_dsaf_tbl_tcam_ucast_cfg()
680 static void hns_dsaf_tbl_line_cfg(struct dsaf_device *dsaf_dev, in hns_dsaf_tbl_line_cfg() argument
685 tbl_line = dsaf_read_dev(dsaf_dev, DSAF_TBL_LIN_CFG_0_REG); in hns_dsaf_tbl_line_cfg()
693 dsaf_write_dev(dsaf_dev, DSAF_TBL_LIN_CFG_0_REG, tbl_line); in hns_dsaf_tbl_line_cfg()
700 static void hns_dsaf_tbl_tcam_mcast_pul(struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_tcam_mcast_pul() argument
704 o_tbl_pul = dsaf_read_dev(dsaf_dev, DSAF_TBL_PUL_0_REG); in hns_dsaf_tbl_tcam_mcast_pul()
706 dsaf_write_dev(dsaf_dev, DSAF_TBL_PUL_0_REG, o_tbl_pul); in hns_dsaf_tbl_tcam_mcast_pul()
708 dsaf_write_dev(dsaf_dev, DSAF_TBL_PUL_0_REG, o_tbl_pul); in hns_dsaf_tbl_tcam_mcast_pul()
715 static void hns_dsaf_tbl_line_pul(struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_line_pul() argument
719 tbl_pul = dsaf_read_dev(dsaf_dev, DSAF_TBL_PUL_0_REG); in hns_dsaf_tbl_line_pul()
721 dsaf_write_dev(dsaf_dev, DSAF_TBL_PUL_0_REG, tbl_pul); in hns_dsaf_tbl_line_pul()
723 dsaf_write_dev(dsaf_dev, DSAF_TBL_PUL_0_REG, tbl_pul); in hns_dsaf_tbl_line_pul()
731 struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_tcam_data_mcast_pul() argument
735 o_tbl_pul = dsaf_read_dev(dsaf_dev, DSAF_TBL_PUL_0_REG); in hns_dsaf_tbl_tcam_data_mcast_pul()
738 dsaf_write_dev(dsaf_dev, DSAF_TBL_PUL_0_REG, o_tbl_pul); in hns_dsaf_tbl_tcam_data_mcast_pul()
741 dsaf_write_dev(dsaf_dev, DSAF_TBL_PUL_0_REG, o_tbl_pul); in hns_dsaf_tbl_tcam_data_mcast_pul()
749 struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_tcam_data_ucast_pul() argument
753 o_tbl_pul = dsaf_read_dev(dsaf_dev, DSAF_TBL_PUL_0_REG); in hns_dsaf_tbl_tcam_data_ucast_pul()
756 dsaf_write_dev(dsaf_dev, DSAF_TBL_PUL_0_REG, o_tbl_pul); in hns_dsaf_tbl_tcam_data_ucast_pul()
759 dsaf_write_dev(dsaf_dev, DSAF_TBL_PUL_0_REG, o_tbl_pul); in hns_dsaf_tbl_tcam_data_ucast_pul()
762 void hns_dsaf_set_promisc_mode(struct dsaf_device *dsaf_dev, u32 en) in hns_dsaf_set_promisc_mode() argument
764 if (AE_IS_VER1(dsaf_dev->dsaf_ver) && !HNS_DSAF_IS_DEBUG(dsaf_dev)) in hns_dsaf_set_promisc_mode()
765 dsaf_set_dev_bit(dsaf_dev, DSAF_CFG_0_REG, in hns_dsaf_set_promisc_mode()
774 static void hns_dsaf_tbl_stat_en(struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_stat_en() argument
778 o_tbl_ctrl = dsaf_read_dev(dsaf_dev, DSAF_TBL_DFX_CTRL_0_REG); in hns_dsaf_tbl_stat_en()
783 dsaf_write_dev(dsaf_dev, DSAF_TBL_DFX_CTRL_0_REG, o_tbl_ctrl); in hns_dsaf_tbl_stat_en()
790 static void hns_dsaf_rocee_bp_en(struct dsaf_device *dsaf_dev) in hns_dsaf_rocee_bp_en() argument
792 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) in hns_dsaf_rocee_bp_en()
793 dsaf_set_dev_bit(dsaf_dev, DSAF_XGE_CTRL_SIG_CFG_0_REG, in hns_dsaf_rocee_bp_en()
798 static void hns_dsaf_int_xge_msk_set(struct dsaf_device *dsaf_dev, in hns_dsaf_int_xge_msk_set() argument
801 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_xge_msk_set()
805 static void hns_dsaf_int_ppe_msk_set(struct dsaf_device *dsaf_dev, in hns_dsaf_int_ppe_msk_set() argument
808 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_ppe_msk_set()
812 static void hns_dsaf_int_rocee_msk_set(struct dsaf_device *dsaf_dev, in hns_dsaf_int_rocee_msk_set() argument
815 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_rocee_msk_set()
820 hns_dsaf_int_tbl_msk_set(struct dsaf_device *dsaf_dev, u32 msk_set) in hns_dsaf_int_tbl_msk_set() argument
822 dsaf_write_dev(dsaf_dev, DSAF_TBL_INT_MSK_0_REG, msk_set); in hns_dsaf_int_tbl_msk_set()
826 static void hns_dsaf_int_xge_src_clr(struct dsaf_device *dsaf_dev, in hns_dsaf_int_xge_src_clr() argument
829 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_xge_src_clr()
833 static void hns_dsaf_int_ppe_src_clr(struct dsaf_device *dsaf_dev, in hns_dsaf_int_ppe_src_clr() argument
836 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_ppe_src_clr()
840 static void hns_dsaf_int_rocee_src_clr(struct dsaf_device *dsaf_dev, in hns_dsaf_int_rocee_src_clr() argument
843 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_rocee_src_clr()
847 static void hns_dsaf_int_tbl_src_clr(struct dsaf_device *dsaf_dev, in hns_dsaf_int_tbl_src_clr() argument
850 dsaf_write_dev(dsaf_dev, DSAF_TBL_INT_SRC_0_REG, int_src); in hns_dsaf_int_tbl_src_clr()
860 struct dsaf_device *dsaf_dev, in hns_dsaf_single_line_tbl_cfg() argument
863 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_single_line_tbl_cfg()
866 hns_dsaf_tbl_line_addr_cfg(dsaf_dev, address); in hns_dsaf_single_line_tbl_cfg()
869 hns_dsaf_tbl_line_cfg(dsaf_dev, ptbl_line); in hns_dsaf_single_line_tbl_cfg()
872 hns_dsaf_tbl_line_pul(dsaf_dev); in hns_dsaf_single_line_tbl_cfg()
874 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_single_line_tbl_cfg()
884 struct dsaf_device *dsaf_dev, u32 address, in hns_dsaf_tcam_uc_cfg() argument
888 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_uc_cfg()
891 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_uc_cfg()
893 hns_dsaf_tbl_tcam_data_cfg(dsaf_dev, ptbl_tcam_data); in hns_dsaf_tcam_uc_cfg()
895 hns_dsaf_tbl_tcam_ucast_cfg(dsaf_dev, ptbl_tcam_ucast); in hns_dsaf_tcam_uc_cfg()
897 hns_dsaf_tbl_tcam_data_ucast_pul(dsaf_dev); in hns_dsaf_tcam_uc_cfg()
899 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_uc_cfg()
910 struct dsaf_device *dsaf_dev, u32 address, in hns_dsaf_tcam_mc_cfg() argument
915 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_cfg()
918 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_mc_cfg()
920 hns_dsaf_tbl_tcam_data_cfg(dsaf_dev, ptbl_tcam_data); in hns_dsaf_tcam_mc_cfg()
922 hns_dsaf_tbl_tcam_mcast_cfg(dsaf_dev, ptbl_tcam_mcast); in hns_dsaf_tcam_mc_cfg()
925 hns_dsaf_tbl_tcam_match_cfg(dsaf_dev, ptbl_tcam_mask); in hns_dsaf_tcam_mc_cfg()
928 hns_dsaf_tbl_tcam_data_mcast_pul(dsaf_dev); in hns_dsaf_tcam_mc_cfg()
930 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_cfg()
939 static void hns_dsaf_tcam_uc_cfg_vague(struct dsaf_device *dsaf_dev, in hns_dsaf_tcam_uc_cfg_vague() argument
945 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_uc_cfg_vague()
946 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_uc_cfg_vague()
947 hns_dsaf_tbl_tcam_data_cfg(dsaf_dev, tcam_data); in hns_dsaf_tcam_uc_cfg_vague()
948 hns_dsaf_tbl_tcam_ucast_cfg(dsaf_dev, tcam_uc); in hns_dsaf_tcam_uc_cfg_vague()
949 hns_dsaf_tbl_tcam_match_cfg(dsaf_dev, tcam_mask); in hns_dsaf_tcam_uc_cfg_vague()
950 hns_dsaf_tbl_tcam_data_ucast_pul(dsaf_dev); in hns_dsaf_tcam_uc_cfg_vague()
955 hns_dsaf_tbl_tcam_match_cfg(dsaf_dev, tcam_mask); in hns_dsaf_tcam_uc_cfg_vague()
957 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_uc_cfg_vague()
968 static void hns_dsaf_tcam_mc_cfg_vague(struct dsaf_device *dsaf_dev, in hns_dsaf_tcam_mc_cfg_vague() argument
974 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_cfg_vague()
975 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_mc_cfg_vague()
976 hns_dsaf_tbl_tcam_data_cfg(dsaf_dev, tcam_data); in hns_dsaf_tcam_mc_cfg_vague()
977 hns_dsaf_tbl_tcam_mcast_cfg(dsaf_dev, tcam_mc); in hns_dsaf_tcam_mc_cfg_vague()
978 hns_dsaf_tbl_tcam_match_cfg(dsaf_dev, tcam_mask); in hns_dsaf_tcam_mc_cfg_vague()
979 hns_dsaf_tbl_tcam_data_mcast_pul(dsaf_dev); in hns_dsaf_tcam_mc_cfg_vague()
984 hns_dsaf_tbl_tcam_match_cfg(dsaf_dev, tcam_mask); in hns_dsaf_tcam_mc_cfg_vague()
986 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_cfg_vague()
994 static void hns_dsaf_tcam_mc_invld(struct dsaf_device *dsaf_dev, u32 address) in hns_dsaf_tcam_mc_invld() argument
996 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_invld()
999 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_mc_invld()
1002 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_0_0_REG, 0); in hns_dsaf_tcam_mc_invld()
1003 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_1_0_REG, 0); in hns_dsaf_tcam_mc_invld()
1004 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_2_0_REG, 0); in hns_dsaf_tcam_mc_invld()
1005 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_3_0_REG, 0); in hns_dsaf_tcam_mc_invld()
1006 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_4_0_REG, 0); in hns_dsaf_tcam_mc_invld()
1009 hns_dsaf_tbl_tcam_mcast_pul(dsaf_dev); in hns_dsaf_tcam_mc_invld()
1011 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_invld()
1033 struct dsaf_device *dsaf_dev, u32 address, in hns_dsaf_tcam_uc_get() argument
1040 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_uc_get()
1043 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_uc_get()
1046 hns_dsaf_tbl_tcam_load_pul(dsaf_dev); in hns_dsaf_tcam_uc_get()
1050 = dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_HIGH_0_REG); in hns_dsaf_tcam_uc_get()
1052 = dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_LOW_0_REG); in hns_dsaf_tcam_uc_get()
1055 tcam_read_data0 = dsaf_read_dev(dsaf_dev, in hns_dsaf_tcam_uc_get()
1057 tcam_read_data4 = dsaf_read_dev(dsaf_dev, in hns_dsaf_tcam_uc_get()
1075 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_uc_get()
1086 struct dsaf_device *dsaf_dev, u32 address, in hns_dsaf_tcam_mc_get() argument
1092 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_get()
1095 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_mc_get()
1098 hns_dsaf_tbl_tcam_load_pul(dsaf_dev); in hns_dsaf_tcam_mc_get()
1102 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_HIGH_0_REG); in hns_dsaf_tcam_mc_get()
1104 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_LOW_0_REG); in hns_dsaf_tcam_mc_get()
1108 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RAM_RDATA0_0_REG); in hns_dsaf_tcam_mc_get()
1110 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RAM_RDATA1_0_REG); in hns_dsaf_tcam_mc_get()
1112 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RAM_RDATA2_0_REG); in hns_dsaf_tcam_mc_get()
1114 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RAM_RDATA3_0_REG); in hns_dsaf_tcam_mc_get()
1116 data_tmp = dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RAM_RDATA4_0_REG); in hns_dsaf_tcam_mc_get()
1125 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_get()
1132 static void hns_dsaf_tbl_line_init(struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_line_init() argument
1139 hns_dsaf_single_line_tbl_cfg(dsaf_dev, i, tbl_line); in hns_dsaf_tbl_line_init()
1146 static void hns_dsaf_tbl_tcam_init(struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_tcam_init() argument
1154 hns_dsaf_tcam_uc_cfg(dsaf_dev, i, tcam_data, tcam_ucast); in hns_dsaf_tbl_tcam_init()
1161 static void hns_dsaf_pfc_en_cfg(struct dsaf_device *dsaf_dev, in hns_dsaf_pfc_en_cfg() argument
1164 dsaf_write_dev(dsaf_dev, DSAF_PFC_EN_0_REG + mac_id * 4, tc_en); in hns_dsaf_pfc_en_cfg()
1167 static void hns_dsaf_set_pfc_pause(struct dsaf_device *dsaf_dev, in hns_dsaf_set_pfc_pause() argument
1170 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_set_pfc_pause()
1172 dev_err(dsaf_dev->dev, "dsaf v1 can not close pfc!\n"); in hns_dsaf_set_pfc_pause()
1177 dsaf_set_dev_bit(dsaf_dev, DSAF_PAUSE_CFG_REG + mac_id * 4, in hns_dsaf_set_pfc_pause()
1179 dsaf_set_dev_bit(dsaf_dev, DSAF_PAUSE_CFG_REG + mac_id * 4, in hns_dsaf_set_pfc_pause()
1183 int hns_dsaf_set_rx_mac_pause_en(struct dsaf_device *dsaf_dev, int mac_id, in hns_dsaf_set_rx_mac_pause_en() argument
1186 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_set_rx_mac_pause_en()
1188 dev_err(dsaf_dev->dev, "dsafv1 can't close rx_pause!\n"); in hns_dsaf_set_rx_mac_pause_en()
1193 dsaf_set_dev_bit(dsaf_dev, DSAF_PAUSE_CFG_REG + mac_id * 4, in hns_dsaf_set_rx_mac_pause_en()
1199 void hns_dsaf_get_rx_mac_pause_en(struct dsaf_device *dsaf_dev, int mac_id, in hns_dsaf_get_rx_mac_pause_en() argument
1202 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) in hns_dsaf_get_rx_mac_pause_en()
1205 *en = dsaf_get_dev_bit(dsaf_dev, in hns_dsaf_get_rx_mac_pause_en()
1215 static void hns_dsaf_comm_init(struct dsaf_device *dsaf_dev) in hns_dsaf_comm_init() argument
1219 bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver); in hns_dsaf_comm_init()
1221 o_dsaf_cfg = dsaf_read_dev(dsaf_dev, DSAF_CFG_0_REG); in hns_dsaf_comm_init()
1222 dsaf_set_bit(o_dsaf_cfg, DSAF_CFG_EN_S, dsaf_dev->dsaf_en); in hns_dsaf_comm_init()
1223 dsaf_set_bit(o_dsaf_cfg, DSAF_CFG_TC_MODE_S, dsaf_dev->dsaf_tc_mode); in hns_dsaf_comm_init()
1227 dsaf_write_dev(dsaf_dev, DSAF_CFG_0_REG, o_dsaf_cfg); in hns_dsaf_comm_init()
1229 hns_dsaf_reg_cnt_clr_ce(dsaf_dev, 1); in hns_dsaf_comm_init()
1230 hns_dsaf_stp_port_type_cfg(dsaf_dev, DSAF_STP_PORT_TYPE_FORWARD); in hns_dsaf_comm_init()
1233 hns_dsaf_ppe_qid_cfg(dsaf_dev, DSAF_DEFAUTL_QUEUE_NUM_PER_PPE); in hns_dsaf_comm_init()
1236 hns_dsaf_mix_def_qid_cfg(dsaf_dev); in hns_dsaf_comm_init()
1239 hns_dsaf_inner_qid_cfg(dsaf_dev); in hns_dsaf_comm_init()
1242 hns_dsaf_sw_port_type_cfg(dsaf_dev, DSAF_SW_PORT_TYPE_NON_VLAN); in hns_dsaf_comm_init()
1246 hns_dsaf_pfc_en_cfg(dsaf_dev, i, 0); in hns_dsaf_comm_init()
1247 hns_dsaf_set_pfc_pause(dsaf_dev, i, is_ver1, is_ver1); in hns_dsaf_comm_init()
1252 hns_dsaf_int_xge_src_clr(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1253 hns_dsaf_int_ppe_src_clr(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1254 hns_dsaf_int_rocee_src_clr(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1256 hns_dsaf_int_xge_msk_set(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1257 hns_dsaf_int_ppe_msk_set(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1258 hns_dsaf_int_rocee_msk_set(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1260 hns_dsaf_int_tbl_src_clr(dsaf_dev, 0xfffffffful); in hns_dsaf_comm_init()
1261 hns_dsaf_int_tbl_msk_set(dsaf_dev, 0xfffffffful); in hns_dsaf_comm_init()
1268 static void hns_dsaf_inode_init(struct dsaf_device *dsaf_dev) in hns_dsaf_inode_init() argument
1274 if (dsaf_dev->dsaf_tc_mode == HRD_DSAF_4TC_MODE) in hns_dsaf_inode_init()
1279 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_inode_init()
1282 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1290 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1293 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1296 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1299 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1302 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1305 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1312 dsaf_write_dev(dsaf_dev, reg, tc_cfg); in hns_dsaf_inode_init()
1320 static int hns_dsaf_sbm_init(struct dsaf_device *dsaf_dev) in hns_dsaf_sbm_init() argument
1327 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_sbm_init()
1328 hns_dsaf_sbm_bp_wl_cfg(dsaf_dev); in hns_dsaf_sbm_init()
1331 hns_dsafv2_sbm_bp_wl_cfg(dsaf_dev); in hns_dsaf_sbm_init()
1336 hns_dsaf_sbm_cfg(dsaf_dev); in hns_dsaf_sbm_init()
1339 ret = hns_dsaf_sbm_cfg_mib_en(dsaf_dev); in hns_dsaf_sbm_init()
1341 dev_err(dsaf_dev->dev, in hns_dsaf_sbm_init()
1343 dsaf_dev->ae_dev.name, ret); in hns_dsaf_sbm_init()
1348 hns_dsaf_sbm_link_sram_init_en(dsaf_dev); in hns_dsaf_sbm_init()
1352 flag = dsaf_get_dev_field(dsaf_dev, DSAF_SRAM_INIT_OVER_0_REG, in hns_dsaf_sbm_init()
1359 dev_err(dsaf_dev->dev, in hns_dsaf_sbm_init()
1361 dsaf_dev->ae_dev.name, flag, cnt); in hns_dsaf_sbm_init()
1365 hns_dsaf_rocee_bp_en(dsaf_dev); in hns_dsaf_sbm_init()
1374 static void hns_dsaf_tbl_init(struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_init() argument
1376 hns_dsaf_tbl_stat_en(dsaf_dev); in hns_dsaf_tbl_init()
1378 hns_dsaf_tbl_tcam_init(dsaf_dev); in hns_dsaf_tbl_init()
1379 hns_dsaf_tbl_line_init(dsaf_dev); in hns_dsaf_tbl_init()
1386 static void hns_dsaf_voq_init(struct dsaf_device *dsaf_dev) in hns_dsaf_voq_init() argument
1388 hns_dsaf_voq_bp_all_thrd_cfg(dsaf_dev); in hns_dsaf_voq_init()
1395 static int hns_dsaf_init_hw(struct dsaf_device *dsaf_dev) in hns_dsaf_init_hw() argument
1399 dev_dbg(dsaf_dev->dev, in hns_dsaf_init_hw()
1400 "hns_dsaf_init_hw begin %s !\n", dsaf_dev->ae_dev.name); in hns_dsaf_init_hw()
1402 dsaf_dev->misc_op->dsaf_reset(dsaf_dev, 0); in hns_dsaf_init_hw()
1404 dsaf_dev->misc_op->dsaf_reset(dsaf_dev, 1); in hns_dsaf_init_hw()
1406 hns_dsaf_comm_init(dsaf_dev); in hns_dsaf_init_hw()
1409 hns_dsaf_inode_init(dsaf_dev); in hns_dsaf_init_hw()
1412 ret = hns_dsaf_sbm_init(dsaf_dev); in hns_dsaf_init_hw()
1417 hns_dsaf_tbl_init(dsaf_dev); in hns_dsaf_init_hw()
1420 hns_dsaf_voq_init(dsaf_dev); in hns_dsaf_init_hw()
1429 static void hns_dsaf_remove_hw(struct dsaf_device *dsaf_dev) in hns_dsaf_remove_hw() argument
1432 dsaf_dev->misc_op->dsaf_reset(dsaf_dev, 0); in hns_dsaf_remove_hw()
1440 static int hns_dsaf_init(struct dsaf_device *dsaf_dev) in hns_dsaf_init() argument
1443 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_init()
1447 if (HNS_DSAF_IS_DEBUG(dsaf_dev)) in hns_dsaf_init()
1450 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) in hns_dsaf_init()
1451 dsaf_dev->tcam_max_num = DSAF_TCAM_SUM; in hns_dsaf_init()
1453 dsaf_dev->tcam_max_num = in hns_dsaf_init()
1456 spin_lock_init(&dsaf_dev->tcam_lock); in hns_dsaf_init()
1457 ret = hns_dsaf_init_hw(dsaf_dev); in hns_dsaf_init()
1476 hns_dsaf_remove_hw(dsaf_dev); in hns_dsaf_init()
1484 static void hns_dsaf_free(struct dsaf_device *dsaf_dev) in hns_dsaf_free() argument
1487 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_free()
1489 hns_dsaf_remove_hw(dsaf_dev); in hns_dsaf_free()
1502 struct dsaf_device *dsaf_dev, in hns_dsaf_find_soft_mac_entry() argument
1506 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_find_soft_mac_entry()
1511 for (i = 0; i < dsaf_dev->tcam_max_num; i++) { in hns_dsaf_find_soft_mac_entry()
1528 static u16 hns_dsaf_find_empty_mac_entry(struct dsaf_device *dsaf_dev) in hns_dsaf_find_empty_mac_entry() argument
1531 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_find_empty_mac_entry()
1536 for (i = 0; i < dsaf_dev->tcam_max_num; i++) { in hns_dsaf_find_empty_mac_entry()
1552 static u16 hns_dsaf_find_empty_mac_entry_reverse(struct dsaf_device *dsaf_dev) in hns_dsaf_find_empty_mac_entry_reverse() argument
1554 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_find_empty_mac_entry_reverse()
1577 struct dsaf_device *dsaf_dev, in hns_dsaf_set_mac_key() argument
1583 if (dsaf_dev->dsaf_mode <= DSAF_MODE_ENABLE) in hns_dsaf_set_mac_key()
1609 struct dsaf_device *dsaf_dev, in hns_dsaf_set_mac_uc_entry() argument
1616 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_set_mac_uc_entry()
1624 dev_err(dsaf_dev->dev, "set_uc %s Mac %pM err!\n", in hns_dsaf_set_mac_uc_entry()
1625 dsaf_dev->ae_dev.name, mac_entry->addr); in hns_dsaf_set_mac_uc_entry()
1630 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, mac_entry->in_vlan_id, in hns_dsaf_set_mac_uc_entry()
1634 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in hns_dsaf_set_mac_uc_entry()
1637 entry_index = hns_dsaf_find_empty_mac_entry(dsaf_dev); in hns_dsaf_set_mac_uc_entry()
1640 dev_err(dsaf_dev->dev, in hns_dsaf_set_mac_uc_entry()
1642 dsaf_dev->ae_dev.name, in hns_dsaf_set_mac_uc_entry()
1648 dev_dbg(dsaf_dev->dev, in hns_dsaf_set_mac_uc_entry()
1650 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_set_mac_uc_entry()
1663 hns_dsaf_tcam_uc_cfg(dsaf_dev, entry_index, &tcam_data, &mac_data); in hns_dsaf_set_mac_uc_entry()
1675 struct dsaf_device *dsaf_dev, in hns_dsaf_rm_mac_addr() argument
1684 dev_err(dsaf_dev->dev, "rm_uc_addr %s Mac %pM err!\n", in hns_dsaf_rm_mac_addr()
1685 dsaf_dev->ae_dev.name, mac_entry->addr); in hns_dsaf_rm_mac_addr()
1690 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, mac_entry->in_vlan_id, in hns_dsaf_rm_mac_addr()
1693 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in hns_dsaf_rm_mac_addr()
1696 dev_info(dsaf_dev->dev, in hns_dsaf_rm_mac_addr()
1698 dsaf_dev->ae_dev.name, in hns_dsaf_rm_mac_addr()
1703 dev_dbg(dsaf_dev->dev, in hns_dsaf_rm_mac_addr()
1705 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_rm_mac_addr()
1709 dsaf_dev, entry_index, in hns_dsaf_rm_mac_addr()
1717 return hns_dsaf_del_mac_entry(dsaf_dev, in hns_dsaf_rm_mac_addr()
1723 static void hns_dsaf_setup_mc_mask(struct dsaf_device *dsaf_dev, in hns_dsaf_setup_mc_mask() argument
1729 memcpy(mask, dsaf_dev->mac_cb[port_num]->mc_mask, ETH_ALEN); in hns_dsaf_setup_mc_mask()
1747 int hns_dsaf_add_mac_mc_port(struct dsaf_device *dsaf_dev, in hns_dsaf_add_mac_mc_port() argument
1755 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_add_mac_mc_port()
1763 dev_err(dsaf_dev->dev, "set_entry failed,addr %pM!\n", in hns_dsaf_add_mac_mc_port()
1769 if (!AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_add_mac_mc_port()
1773 hns_dsaf_setup_mc_mask(dsaf_dev, mac_entry->in_port_num, in hns_dsaf_add_mac_mc_port()
1778 hns_dsaf_set_mac_key(dsaf_dev, &mask_key, in hns_dsaf_add_mac_mc_port()
1788 dsaf_dev, &mac_key, mac_entry->in_vlan_id, in hns_dsaf_add_mac_mc_port()
1794 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in hns_dsaf_add_mac_mc_port()
1797 entry_index = hns_dsaf_find_empty_mac_entry(dsaf_dev); in hns_dsaf_add_mac_mc_port()
1800 dev_err(dsaf_dev->dev, in hns_dsaf_add_mac_mc_port()
1802 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_add_mac_mc_port()
1808 hns_dsaf_tcam_mc_get(dsaf_dev, entry_index, &tcam_data, in hns_dsaf_add_mac_mc_port()
1819 dev_err(dsaf_dev->dev, in hns_dsaf_add_mac_mc_port()
1821 dsaf_dev->ae_dev.name, mac_entry->port_num, in hns_dsaf_add_mac_mc_port()
1829 dev_dbg(dsaf_dev->dev, in hns_dsaf_add_mac_mc_port()
1831 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_add_mac_mc_port()
1838 hns_dsaf_tcam_mc_cfg(dsaf_dev, entry_index, &tcam_data, in hns_dsaf_add_mac_mc_port()
1857 int hns_dsaf_del_mac_entry(struct dsaf_device *dsaf_dev, u16 vlan_id, in hns_dsaf_del_mac_entry() argument
1863 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_del_mac_entry()
1868 dev_err(dsaf_dev->dev, "del_entry failed,addr %pM!\n", in hns_dsaf_del_mac_entry()
1874 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, vlan_id, in_port_num, addr); in hns_dsaf_del_mac_entry()
1877 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in hns_dsaf_del_mac_entry()
1880 dev_err(dsaf_dev->dev, in hns_dsaf_del_mac_entry()
1882 dsaf_dev->ae_dev.name, in hns_dsaf_del_mac_entry()
1886 dev_dbg(dsaf_dev->dev, in hns_dsaf_del_mac_entry()
1888 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_del_mac_entry()
1892 hns_dsaf_tcam_mc_invld(dsaf_dev, entry_index); in hns_dsaf_del_mac_entry()
1906 int hns_dsaf_del_mac_mc_port(struct dsaf_device *dsaf_dev, in hns_dsaf_del_mac_mc_port() argument
1911 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_del_mac_mc_port()
1924 dev_err(dsaf_dev->dev, in hns_dsaf_del_mac_mc_port()
1931 dev_err(dsaf_dev->dev, "del_port failed, addr %pM!\n", in hns_dsaf_del_mac_mc_port()
1939 if (!AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_del_mac_mc_port()
1943 hns_dsaf_setup_mc_mask(dsaf_dev, mac_entry->in_port_num, in hns_dsaf_del_mac_mc_port()
1948 hns_dsaf_set_mac_key(dsaf_dev, &mask_key, 0x00, 0xff, mc_mask); in hns_dsaf_del_mac_mc_port()
1958 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, vlan_id, in_port_num, mc_addr); in hns_dsaf_del_mac_mc_port()
1961 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in hns_dsaf_del_mac_mc_port()
1964 dev_err(dsaf_dev->dev, in hns_dsaf_del_mac_mc_port()
1966 dsaf_dev->ae_dev.name, in hns_dsaf_del_mac_mc_port()
1971 dev_dbg(dsaf_dev->dev, in hns_dsaf_del_mac_mc_port()
1973 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_del_mac_mc_port()
1977 hns_dsaf_tcam_mc_get(dsaf_dev, entry_index, &tcam_data, &mac_data); in hns_dsaf_del_mac_mc_port()
1986 dev_err(dsaf_dev->dev, in hns_dsaf_del_mac_mc_port()
1988 dsaf_dev->ae_dev.name, mac_entry->port_num, in hns_dsaf_del_mac_mc_port()
1997 hns_dsaf_tcam_mc_invld(dsaf_dev, entry_index); in hns_dsaf_del_mac_mc_port()
2006 hns_dsaf_tcam_mc_cfg(dsaf_dev, entry_index, in hns_dsaf_del_mac_mc_port()
2014 int hns_dsaf_clr_mac_mc_port(struct dsaf_device *dsaf_dev, u8 mac_id, in hns_dsaf_clr_mac_mc_port() argument
2017 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_clr_mac_mc_port()
2022 if (HNS_DSAF_IS_DEBUG(dsaf_dev)) in hns_dsaf_clr_mac_mc_port()
2054 if (hns_dsaf_del_mac_mc_port(dsaf_dev, &mac_entry)) { in hns_dsaf_clr_mac_mc_port()
2062 hns_dsaf_tcam_mc_get(dsaf_dev, i, in hns_dsaf_clr_mac_mc_port()
2071 if (hns_dsaf_del_mac_mc_port(dsaf_dev, in hns_dsaf_clr_mac_mc_port()
2086 struct dsaf_device *dsaf_dev; in hns_dsaf_alloc_dev() local
2088 dsaf_dev = devm_kzalloc(dev, in hns_dsaf_alloc_dev()
2089 sizeof(*dsaf_dev) + sizeof_priv, GFP_KERNEL); in hns_dsaf_alloc_dev()
2090 if (unlikely(!dsaf_dev)) { in hns_dsaf_alloc_dev()
2091 dsaf_dev = ERR_PTR(-ENOMEM); in hns_dsaf_alloc_dev()
2093 dsaf_dev->dev = dev; in hns_dsaf_alloc_dev()
2094 dev_set_drvdata(dev, dsaf_dev); in hns_dsaf_alloc_dev()
2097 return dsaf_dev; in hns_dsaf_alloc_dev()
2104 static void hns_dsaf_free_dev(struct dsaf_device *dsaf_dev) in hns_dsaf_free_dev() argument
2106 (void)dev_set_drvdata(dsaf_dev->dev, NULL); in hns_dsaf_free_dev()
2115 static void hns_dsaf_pfc_unit_cnt(struct dsaf_device *dsaf_dev, int mac_id, in hns_dsaf_pfc_unit_cnt() argument
2134 dsaf_set_dev_field(dsaf_dev, in hns_dsaf_pfc_unit_cnt()
2146 hns_dsaf_port_work_rate_cfg(struct dsaf_device *dsaf_dev, int mac_id, in hns_dsaf_port_work_rate_cfg() argument
2152 dsaf_dev, DSAF_XGE_GE_WORK_MODE_0_REG + 0x4 * (u64)mac_id); in hns_dsaf_port_work_rate_cfg()
2159 dsaf_write_dev(dsaf_dev, in hns_dsaf_port_work_rate_cfg()
2163 hns_dsaf_pfc_unit_cnt(dsaf_dev, mac_id, rate_mode); in hns_dsaf_port_work_rate_cfg()
2173 struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev; in hns_dsaf_fix_mac_mode() local
2183 hns_dsaf_port_work_rate_cfg(dsaf_dev, mac_id, mode); in hns_dsaf_fix_mac_mode()
2198 void hns_dsaf_update_stats(struct dsaf_device *dsaf_dev, u32 node_num) in hns_dsaf_update_stats() argument
2201 = &dsaf_dev->hw_stats[node_num]; in hns_dsaf_update_stats()
2202 bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver); in hns_dsaf_update_stats()
2206 hw_stats->pad_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2208 hw_stats->man_pkts += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2210 hw_stats->rx_pkts += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2212 hw_stats->rx_pkt_id += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2218 dsaf_read_dev(dsaf_dev, reg_tmp + 0x80 * (u64)node_num); in hns_dsaf_update_stats()
2220 hw_stats->release_buf_num += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2222 hw_stats->sbm_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2224 hw_stats->crc_false += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2226 hw_stats->bp_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2228 hw_stats->rslt_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2230 hw_stats->local_addr_false += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2233 hw_stats->vlan_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2235 hw_stats->stp_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2242 hw_stats->rx_pfc[i] += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2244 hw_stats->tx_pfc[i] += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2250 hw_stats->tx_pkts += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2588 struct dsaf_device *dsaf_dev) in hns_dsaf_get_node_stats_strings() argument
2592 bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver); in hns_dsaf_get_node_stats_strings()
2696 int hns_dsaf_get_sset_count(struct dsaf_device *dsaf_dev, int stringset) in hns_dsaf_get_sset_count() argument
2698 bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver); in hns_dsaf_get_sset_count()
2716 struct dsaf_device *dsaf_dev) in hns_dsaf_get_strings() argument
2725 buff = hns_dsaf_get_node_stats_strings(buff, node, dsaf_dev); in hns_dsaf_get_strings()
2729 (void)hns_dsaf_get_node_stats_strings(buff, node, dsaf_dev); in hns_dsaf_get_strings()
2752 static void set_promisc_tcam_enable(struct dsaf_device *dsaf_dev, u32 port) in set_promisc_tcam_enable() argument
2758 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in set_promisc_tcam_enable()
2771 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, 0x00, port, addr); in set_promisc_tcam_enable()
2772 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in set_promisc_tcam_enable()
2778 entry_index = hns_dsaf_find_empty_mac_entry_reverse(dsaf_dev); in set_promisc_tcam_enable()
2780 dev_err(dsaf_dev->dev, in set_promisc_tcam_enable()
2786 mac_cb = dsaf_dev->mac_cb[port]; in set_promisc_tcam_enable()
2791 hns_dsaf_tcam_uc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_uc, in set_promisc_tcam_enable()
2804 entry_index = hns_dsaf_find_empty_mac_entry_reverse(dsaf_dev); in set_promisc_tcam_enable()
2806 dev_err(dsaf_dev->dev, in set_promisc_tcam_enable()
2816 hns_dsaf_set_mac_key(dsaf_dev, &mask_key, mask_entry.in_vlan_id, in set_promisc_tcam_enable()
2824 dev_err(dsaf_dev->dev, "%s,pnum(%d)error,key(%#x:%#x)\n", in set_promisc_tcam_enable()
2825 dsaf_dev->ae_dev.name, port, in set_promisc_tcam_enable()
2835 dev_err(dsaf_dev->dev, in set_promisc_tcam_enable()
2837 dsaf_dev->ae_dev.name, port_num, in set_promisc_tcam_enable()
2845 hns_dsaf_tcam_mc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_mc, in set_promisc_tcam_enable()
2856 static void set_promisc_tcam_disable(struct dsaf_device *dsaf_dev, u32 port) in set_promisc_tcam_disable() argument
2861 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in set_promisc_tcam_disable()
2871 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, 0x00, port, addr); in set_promisc_tcam_disable()
2872 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in set_promisc_tcam_disable()
2878 hns_dsaf_tcam_uc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_uc, in set_promisc_tcam_disable()
2890 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, 0x00, port, addr); in set_promisc_tcam_disable()
2891 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in set_promisc_tcam_disable()
2897 hns_dsaf_tcam_mc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_mc, in set_promisc_tcam_disable()
2905 void hns_dsaf_set_promisc_tcam(struct dsaf_device *dsaf_dev, in hns_dsaf_set_promisc_tcam() argument
2909 set_promisc_tcam_enable(dsaf_dev, port); in hns_dsaf_set_promisc_tcam()
2911 set_promisc_tcam_disable(dsaf_dev, port); in hns_dsaf_set_promisc_tcam()
2914 int hns_dsaf_wait_pkt_clean(struct dsaf_device *dsaf_dev, int port) in hns_dsaf_wait_pkt_clean() argument
2924 val = dsaf_read_dev(dsaf_dev, DSAF_VOQ_IN_PKT_NUM_0_REG + in hns_dsaf_wait_pkt_clean()
2926 val_tmp = dsaf_read_dev(dsaf_dev, DSAF_VOQ_OUT_PKT_NUM_0_REG + in hns_dsaf_wait_pkt_clean()
2935 dev_err(dsaf_dev->dev, "hns dsaf clean wait timeout(%u - %u).\n", in hns_dsaf_wait_pkt_clean()
2950 struct dsaf_device *dsaf_dev; in hns_dsaf_probe() local
2953 dsaf_dev = hns_dsaf_alloc_dev(&pdev->dev, sizeof(struct dsaf_drv_priv)); in hns_dsaf_probe()
2954 if (IS_ERR(dsaf_dev)) { in hns_dsaf_probe()
2955 ret = PTR_ERR(dsaf_dev); in hns_dsaf_probe()
2961 ret = hns_dsaf_get_cfg(dsaf_dev); in hns_dsaf_probe()
2965 ret = hns_dsaf_init(dsaf_dev); in hns_dsaf_probe()
2969 ret = hns_mac_init(dsaf_dev); in hns_dsaf_probe()
2973 ret = hns_ppe_init(dsaf_dev); in hns_dsaf_probe()
2977 ret = hns_dsaf_ae_init(dsaf_dev); in hns_dsaf_probe()
2984 hns_ppe_uninit(dsaf_dev); in hns_dsaf_probe()
2987 hns_mac_uninit(dsaf_dev); in hns_dsaf_probe()
2990 hns_dsaf_free(dsaf_dev); in hns_dsaf_probe()
2993 hns_dsaf_free_dev(dsaf_dev); in hns_dsaf_probe()
3004 struct dsaf_device *dsaf_dev = dev_get_drvdata(&pdev->dev); in hns_dsaf_remove() local
3006 hns_dsaf_ae_uninit(dsaf_dev); in hns_dsaf_remove()
3008 hns_ppe_uninit(dsaf_dev); in hns_dsaf_remove()
3010 hns_mac_uninit(dsaf_dev); in hns_dsaf_remove()
3012 hns_dsaf_free(dsaf_dev); in hns_dsaf_remove()
3014 hns_dsaf_free_dev(dsaf_dev); in hns_dsaf_remove()
3046 struct dsaf_device *dsaf_dev; in hns_dsaf_roce_reset() local
3090 dsaf_dev = dev_get_drvdata(&pdev->dev); in hns_dsaf_roce_reset()
3091 if (!dsaf_dev) { in hns_dsaf_roce_reset()
3098 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_roce_reset()
3099 dev_err(dsaf_dev->dev, "%s v1 chip doesn't support RoCE!\n", in hns_dsaf_roce_reset()
3100 dsaf_dev->ae_dev.name); in hns_dsaf_roce_reset()
3108 dsaf_dev->misc_op->hns_dsaf_srst_chns(dsaf_dev, DSAF_CHNS_MASK, in hns_dsaf_roce_reset()
3110 dsaf_dev->misc_op->hns_dsaf_roce_srst(dsaf_dev, false); in hns_dsaf_roce_reset()
3113 mp = dsaf_read_dev(dsaf_dev, DSAF_ROCE_PORT_MAP_REG); in hns_dsaf_roce_reset()
3118 dsaf_write_dev(dsaf_dev, DSAF_ROCE_PORT_MAP_REG, mp); in hns_dsaf_roce_reset()
3120 sl = dsaf_read_dev(dsaf_dev, DSAF_ROCE_SL_MAP_REG); in hns_dsaf_roce_reset()
3124 dsaf_write_dev(dsaf_dev, DSAF_ROCE_SL_MAP_REG, sl); in hns_dsaf_roce_reset()
3127 dsaf_dev->misc_op->hns_dsaf_srst_chns(dsaf_dev, DSAF_CHNS_MASK, in hns_dsaf_roce_reset()
3130 dsaf_dev->misc_op->hns_dsaf_roce_srst(dsaf_dev, true); in hns_dsaf_roce_reset()
3133 credit = dsaf_read_dev(dsaf_dev, DSAF_SBM_ROCEE_CFG_REG_REG); in hns_dsaf_roce_reset()
3135 dsaf_write_dev(dsaf_dev, DSAF_SBM_ROCEE_CFG_REG_REG, credit); in hns_dsaf_roce_reset()
3138 dsaf_write_dev(dsaf_dev, DSAF_SBM_ROCEE_CFG_REG_REG, credit); in hns_dsaf_roce_reset()