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()
773 static void hns_dsaf_tbl_stat_en(struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_stat_en() argument
777 o_tbl_ctrl = dsaf_read_dev(dsaf_dev, DSAF_TBL_DFX_CTRL_0_REG); in hns_dsaf_tbl_stat_en()
782 dsaf_write_dev(dsaf_dev, DSAF_TBL_DFX_CTRL_0_REG, o_tbl_ctrl); in hns_dsaf_tbl_stat_en()
789 static void hns_dsaf_rocee_bp_en(struct dsaf_device *dsaf_dev) in hns_dsaf_rocee_bp_en() argument
791 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) in hns_dsaf_rocee_bp_en()
792 dsaf_set_dev_bit(dsaf_dev, DSAF_XGE_CTRL_SIG_CFG_0_REG, in hns_dsaf_rocee_bp_en()
797 static void hns_dsaf_int_xge_msk_set(struct dsaf_device *dsaf_dev, in hns_dsaf_int_xge_msk_set() argument
800 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_xge_msk_set()
804 static void hns_dsaf_int_ppe_msk_set(struct dsaf_device *dsaf_dev, in hns_dsaf_int_ppe_msk_set() argument
807 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_ppe_msk_set()
811 static void hns_dsaf_int_rocee_msk_set(struct dsaf_device *dsaf_dev, in hns_dsaf_int_rocee_msk_set() argument
814 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_rocee_msk_set()
819 hns_dsaf_int_tbl_msk_set(struct dsaf_device *dsaf_dev, u32 msk_set) in hns_dsaf_int_tbl_msk_set() argument
821 dsaf_write_dev(dsaf_dev, DSAF_TBL_INT_MSK_0_REG, msk_set); in hns_dsaf_int_tbl_msk_set()
825 static void hns_dsaf_int_xge_src_clr(struct dsaf_device *dsaf_dev, in hns_dsaf_int_xge_src_clr() argument
828 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_xge_src_clr()
832 static void hns_dsaf_int_ppe_src_clr(struct dsaf_device *dsaf_dev, in hns_dsaf_int_ppe_src_clr() argument
835 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_ppe_src_clr()
839 static void hns_dsaf_int_rocee_src_clr(struct dsaf_device *dsaf_dev, in hns_dsaf_int_rocee_src_clr() argument
842 dsaf_write_dev(dsaf_dev, in hns_dsaf_int_rocee_src_clr()
846 static void hns_dsaf_int_tbl_src_clr(struct dsaf_device *dsaf_dev, in hns_dsaf_int_tbl_src_clr() argument
849 dsaf_write_dev(dsaf_dev, DSAF_TBL_INT_SRC_0_REG, int_src); in hns_dsaf_int_tbl_src_clr()
859 struct dsaf_device *dsaf_dev, in hns_dsaf_single_line_tbl_cfg() argument
862 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_single_line_tbl_cfg()
865 hns_dsaf_tbl_line_addr_cfg(dsaf_dev, address); in hns_dsaf_single_line_tbl_cfg()
868 hns_dsaf_tbl_line_cfg(dsaf_dev, ptbl_line); in hns_dsaf_single_line_tbl_cfg()
871 hns_dsaf_tbl_line_pul(dsaf_dev); in hns_dsaf_single_line_tbl_cfg()
873 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()
911 struct dsaf_device *dsaf_dev, u32 address, in hns_dsaf_tcam_mc_cfg() argument
916 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_cfg()
919 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_mc_cfg()
921 hns_dsaf_tbl_tcam_data_cfg(dsaf_dev, ptbl_tcam_data); in hns_dsaf_tcam_mc_cfg()
923 hns_dsaf_tbl_tcam_mcast_cfg(dsaf_dev, ptbl_tcam_mcast); in hns_dsaf_tcam_mc_cfg()
926 hns_dsaf_tbl_tcam_match_cfg(dsaf_dev, ptbl_tcam_mask); in hns_dsaf_tcam_mc_cfg()
929 hns_dsaf_tbl_tcam_data_mcast_pul(dsaf_dev); in hns_dsaf_tcam_mc_cfg()
931 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_cfg()
942 static void hns_dsaf_tcam_uc_cfg_vague(struct dsaf_device *dsaf_dev, in hns_dsaf_tcam_uc_cfg_vague() argument
948 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_uc_cfg_vague()
949 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_uc_cfg_vague()
950 hns_dsaf_tbl_tcam_data_cfg(dsaf_dev, tcam_data); in hns_dsaf_tcam_uc_cfg_vague()
951 hns_dsaf_tbl_tcam_ucast_cfg(dsaf_dev, tcam_uc); in hns_dsaf_tcam_uc_cfg_vague()
952 hns_dsaf_tbl_tcam_match_cfg(dsaf_dev, tcam_mask); in hns_dsaf_tcam_uc_cfg_vague()
953 hns_dsaf_tbl_tcam_data_ucast_pul(dsaf_dev); in hns_dsaf_tcam_uc_cfg_vague()
958 hns_dsaf_tbl_tcam_match_cfg(dsaf_dev, tcam_mask); in hns_dsaf_tcam_uc_cfg_vague()
960 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_uc_cfg_vague()
971 static void hns_dsaf_tcam_mc_cfg_vague(struct dsaf_device *dsaf_dev, in hns_dsaf_tcam_mc_cfg_vague() argument
977 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_cfg_vague()
978 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_mc_cfg_vague()
979 hns_dsaf_tbl_tcam_data_cfg(dsaf_dev, tcam_data); in hns_dsaf_tcam_mc_cfg_vague()
980 hns_dsaf_tbl_tcam_mcast_cfg(dsaf_dev, tcam_mc); in hns_dsaf_tcam_mc_cfg_vague()
981 hns_dsaf_tbl_tcam_match_cfg(dsaf_dev, tcam_mask); in hns_dsaf_tcam_mc_cfg_vague()
982 hns_dsaf_tbl_tcam_data_mcast_pul(dsaf_dev); in hns_dsaf_tcam_mc_cfg_vague()
987 hns_dsaf_tbl_tcam_match_cfg(dsaf_dev, tcam_mask); in hns_dsaf_tcam_mc_cfg_vague()
989 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_cfg_vague()
997 static void hns_dsaf_tcam_mc_invld(struct dsaf_device *dsaf_dev, u32 address) in hns_dsaf_tcam_mc_invld() argument
999 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_invld()
1002 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_mc_invld()
1005 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_0_0_REG, 0); in hns_dsaf_tcam_mc_invld()
1006 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_1_0_REG, 0); in hns_dsaf_tcam_mc_invld()
1007 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_2_0_REG, 0); in hns_dsaf_tcam_mc_invld()
1008 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_3_0_REG, 0); in hns_dsaf_tcam_mc_invld()
1009 dsaf_write_dev(dsaf_dev, DSAF_TBL_TCAM_MCAST_CFG_4_0_REG, 0); in hns_dsaf_tcam_mc_invld()
1012 hns_dsaf_tbl_tcam_mcast_pul(dsaf_dev); in hns_dsaf_tcam_mc_invld()
1014 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_invld()
1036 struct dsaf_device *dsaf_dev, u32 address, in hns_dsaf_tcam_uc_get() argument
1043 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_uc_get()
1046 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_uc_get()
1049 hns_dsaf_tbl_tcam_load_pul(dsaf_dev); in hns_dsaf_tcam_uc_get()
1053 = dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_HIGH_0_REG); in hns_dsaf_tcam_uc_get()
1055 = dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_LOW_0_REG); in hns_dsaf_tcam_uc_get()
1058 tcam_read_data0 = dsaf_read_dev(dsaf_dev, in hns_dsaf_tcam_uc_get()
1060 tcam_read_data4 = dsaf_read_dev(dsaf_dev, in hns_dsaf_tcam_uc_get()
1078 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_uc_get()
1089 struct dsaf_device *dsaf_dev, u32 address, in hns_dsaf_tcam_mc_get() argument
1095 spin_lock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_get()
1098 hns_dsaf_tbl_tcam_addr_cfg(dsaf_dev, address); in hns_dsaf_tcam_mc_get()
1101 hns_dsaf_tbl_tcam_load_pul(dsaf_dev); in hns_dsaf_tcam_mc_get()
1105 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_HIGH_0_REG); in hns_dsaf_tcam_mc_get()
1107 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RDATA_LOW_0_REG); in hns_dsaf_tcam_mc_get()
1111 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RAM_RDATA0_0_REG); in hns_dsaf_tcam_mc_get()
1113 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RAM_RDATA1_0_REG); in hns_dsaf_tcam_mc_get()
1115 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RAM_RDATA2_0_REG); in hns_dsaf_tcam_mc_get()
1117 dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RAM_RDATA3_0_REG); in hns_dsaf_tcam_mc_get()
1119 data_tmp = dsaf_read_dev(dsaf_dev, DSAF_TBL_TCAM_RAM_RDATA4_0_REG); in hns_dsaf_tcam_mc_get()
1128 spin_unlock_bh(&dsaf_dev->tcam_lock); in hns_dsaf_tcam_mc_get()
1135 static void hns_dsaf_tbl_line_init(struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_line_init() argument
1142 hns_dsaf_single_line_tbl_cfg(dsaf_dev, i, tbl_line); in hns_dsaf_tbl_line_init()
1149 static void hns_dsaf_tbl_tcam_init(struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_tcam_init() argument
1157 hns_dsaf_tcam_uc_cfg(dsaf_dev, i, tcam_data, tcam_ucast); in hns_dsaf_tbl_tcam_init()
1166 static void hns_dsaf_pfc_en_cfg(struct dsaf_device *dsaf_dev, in hns_dsaf_pfc_en_cfg() argument
1169 dsaf_write_dev(dsaf_dev, DSAF_PFC_EN_0_REG + mac_id * 4, tc_en); in hns_dsaf_pfc_en_cfg()
1172 static void hns_dsaf_set_pfc_pause(struct dsaf_device *dsaf_dev, in hns_dsaf_set_pfc_pause() argument
1175 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_set_pfc_pause()
1177 dev_err(dsaf_dev->dev, "dsaf v1 can not close pfc!\n"); in hns_dsaf_set_pfc_pause()
1182 dsaf_set_dev_bit(dsaf_dev, DSAF_PAUSE_CFG_REG + mac_id * 4, in hns_dsaf_set_pfc_pause()
1184 dsaf_set_dev_bit(dsaf_dev, DSAF_PAUSE_CFG_REG + mac_id * 4, in hns_dsaf_set_pfc_pause()
1188 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
1191 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_set_rx_mac_pause_en()
1193 dev_err(dsaf_dev->dev, "dsafv1 can't close rx_pause!\n"); in hns_dsaf_set_rx_mac_pause_en()
1198 dsaf_set_dev_bit(dsaf_dev, DSAF_PAUSE_CFG_REG + mac_id * 4, in hns_dsaf_set_rx_mac_pause_en()
1204 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
1207 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) in hns_dsaf_get_rx_mac_pause_en()
1210 *en = dsaf_get_dev_bit(dsaf_dev, in hns_dsaf_get_rx_mac_pause_en()
1219 static void hns_dsaf_comm_init(struct dsaf_device *dsaf_dev) in hns_dsaf_comm_init() argument
1223 bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver); in hns_dsaf_comm_init()
1225 o_dsaf_cfg = dsaf_read_dev(dsaf_dev, DSAF_CFG_0_REG); in hns_dsaf_comm_init()
1226 dsaf_set_bit(o_dsaf_cfg, DSAF_CFG_EN_S, dsaf_dev->dsaf_en); in hns_dsaf_comm_init()
1227 dsaf_set_bit(o_dsaf_cfg, DSAF_CFG_TC_MODE_S, dsaf_dev->dsaf_tc_mode); in hns_dsaf_comm_init()
1231 dsaf_write_dev(dsaf_dev, DSAF_CFG_0_REG, o_dsaf_cfg); in hns_dsaf_comm_init()
1233 hns_dsaf_reg_cnt_clr_ce(dsaf_dev, 1); in hns_dsaf_comm_init()
1234 hns_dsaf_stp_port_type_cfg(dsaf_dev, DSAF_STP_PORT_TYPE_FORWARD); in hns_dsaf_comm_init()
1237 hns_dsaf_ppe_qid_cfg(dsaf_dev, DSAF_DEFAUTL_QUEUE_NUM_PER_PPE); in hns_dsaf_comm_init()
1240 hns_dsaf_mix_def_qid_cfg(dsaf_dev); in hns_dsaf_comm_init()
1243 hns_dsaf_inner_qid_cfg(dsaf_dev); in hns_dsaf_comm_init()
1246 hns_dsaf_sw_port_type_cfg(dsaf_dev, DSAF_SW_PORT_TYPE_NON_VLAN); in hns_dsaf_comm_init()
1250 hns_dsaf_pfc_en_cfg(dsaf_dev, i, 0); in hns_dsaf_comm_init()
1251 hns_dsaf_set_pfc_pause(dsaf_dev, i, is_ver1, is_ver1); in hns_dsaf_comm_init()
1256 hns_dsaf_int_xge_src_clr(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1257 hns_dsaf_int_ppe_src_clr(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1258 hns_dsaf_int_rocee_src_clr(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1260 hns_dsaf_int_xge_msk_set(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1261 hns_dsaf_int_ppe_msk_set(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1262 hns_dsaf_int_rocee_msk_set(dsaf_dev, i, 0xfffffffful); in hns_dsaf_comm_init()
1264 hns_dsaf_int_tbl_src_clr(dsaf_dev, 0xfffffffful); in hns_dsaf_comm_init()
1265 hns_dsaf_int_tbl_msk_set(dsaf_dev, 0xfffffffful); in hns_dsaf_comm_init()
1272 static void hns_dsaf_inode_init(struct dsaf_device *dsaf_dev) in hns_dsaf_inode_init() argument
1278 if (dsaf_dev->dsaf_tc_mode == HRD_DSAF_4TC_MODE) in hns_dsaf_inode_init()
1283 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_inode_init()
1286 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1294 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1297 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1300 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1303 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1306 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1309 dsaf_set_dev_field(dsaf_dev, reg, in hns_dsaf_inode_init()
1316 dsaf_write_dev(dsaf_dev, reg, tc_cfg); in hns_dsaf_inode_init()
1324 static int hns_dsaf_sbm_init(struct dsaf_device *dsaf_dev) in hns_dsaf_sbm_init() argument
1331 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_sbm_init()
1332 hns_dsaf_sbm_bp_wl_cfg(dsaf_dev); in hns_dsaf_sbm_init()
1335 hns_dsafv2_sbm_bp_wl_cfg(dsaf_dev); in hns_dsaf_sbm_init()
1340 hns_dsaf_sbm_cfg(dsaf_dev); in hns_dsaf_sbm_init()
1343 ret = hns_dsaf_sbm_cfg_mib_en(dsaf_dev); in hns_dsaf_sbm_init()
1345 dev_err(dsaf_dev->dev, in hns_dsaf_sbm_init()
1347 dsaf_dev->ae_dev.name, ret); in hns_dsaf_sbm_init()
1352 hns_dsaf_sbm_link_sram_init_en(dsaf_dev); in hns_dsaf_sbm_init()
1356 flag = dsaf_get_dev_field(dsaf_dev, DSAF_SRAM_INIT_OVER_0_REG, in hns_dsaf_sbm_init()
1363 dev_err(dsaf_dev->dev, in hns_dsaf_sbm_init()
1365 dsaf_dev->ae_dev.name, flag, cnt); in hns_dsaf_sbm_init()
1369 hns_dsaf_rocee_bp_en(dsaf_dev); in hns_dsaf_sbm_init()
1378 static void hns_dsaf_tbl_init(struct dsaf_device *dsaf_dev) in hns_dsaf_tbl_init() argument
1380 hns_dsaf_tbl_stat_en(dsaf_dev); in hns_dsaf_tbl_init()
1382 hns_dsaf_tbl_tcam_init(dsaf_dev); in hns_dsaf_tbl_init()
1383 hns_dsaf_tbl_line_init(dsaf_dev); in hns_dsaf_tbl_init()
1390 static void hns_dsaf_voq_init(struct dsaf_device *dsaf_dev) in hns_dsaf_voq_init() argument
1392 hns_dsaf_voq_bp_all_thrd_cfg(dsaf_dev); in hns_dsaf_voq_init()
1399 static int hns_dsaf_init_hw(struct dsaf_device *dsaf_dev) in hns_dsaf_init_hw() argument
1403 dev_dbg(dsaf_dev->dev, in hns_dsaf_init_hw()
1404 "hns_dsaf_init_hw begin %s !\n", dsaf_dev->ae_dev.name); in hns_dsaf_init_hw()
1406 dsaf_dev->misc_op->dsaf_reset(dsaf_dev, 0); in hns_dsaf_init_hw()
1408 dsaf_dev->misc_op->dsaf_reset(dsaf_dev, 1); in hns_dsaf_init_hw()
1410 hns_dsaf_comm_init(dsaf_dev); in hns_dsaf_init_hw()
1413 hns_dsaf_inode_init(dsaf_dev); in hns_dsaf_init_hw()
1416 ret = hns_dsaf_sbm_init(dsaf_dev); in hns_dsaf_init_hw()
1421 hns_dsaf_tbl_init(dsaf_dev); in hns_dsaf_init_hw()
1424 hns_dsaf_voq_init(dsaf_dev); in hns_dsaf_init_hw()
1433 static void hns_dsaf_remove_hw(struct dsaf_device *dsaf_dev) in hns_dsaf_remove_hw() argument
1436 dsaf_dev->misc_op->dsaf_reset(dsaf_dev, 0); in hns_dsaf_remove_hw()
1444 static int hns_dsaf_init(struct dsaf_device *dsaf_dev) in hns_dsaf_init() argument
1447 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_init()
1451 if (HNS_DSAF_IS_DEBUG(dsaf_dev)) in hns_dsaf_init()
1454 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) in hns_dsaf_init()
1455 dsaf_dev->tcam_max_num = DSAF_TCAM_SUM; in hns_dsaf_init()
1457 dsaf_dev->tcam_max_num = in hns_dsaf_init()
1460 spin_lock_init(&dsaf_dev->tcam_lock); in hns_dsaf_init()
1461 ret = hns_dsaf_init_hw(dsaf_dev); in hns_dsaf_init()
1480 hns_dsaf_remove_hw(dsaf_dev); in hns_dsaf_init()
1488 static void hns_dsaf_free(struct dsaf_device *dsaf_dev) in hns_dsaf_free() argument
1491 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_free()
1493 hns_dsaf_remove_hw(dsaf_dev); in hns_dsaf_free()
1506 struct dsaf_device *dsaf_dev, in hns_dsaf_find_soft_mac_entry() argument
1510 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_find_soft_mac_entry()
1515 for (i = 0; i < dsaf_dev->tcam_max_num; i++) { in hns_dsaf_find_soft_mac_entry()
1532 static u16 hns_dsaf_find_empty_mac_entry(struct dsaf_device *dsaf_dev) in hns_dsaf_find_empty_mac_entry() argument
1535 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_find_empty_mac_entry()
1540 for (i = 0; i < dsaf_dev->tcam_max_num; i++) { in hns_dsaf_find_empty_mac_entry()
1556 static u16 hns_dsaf_find_empty_mac_entry_reverse(struct dsaf_device *dsaf_dev) in hns_dsaf_find_empty_mac_entry_reverse() argument
1558 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_find_empty_mac_entry_reverse()
1581 struct dsaf_device *dsaf_dev, in hns_dsaf_set_mac_key() argument
1587 if (dsaf_dev->dsaf_mode <= DSAF_MODE_ENABLE) in hns_dsaf_set_mac_key()
1613 struct dsaf_device *dsaf_dev, in hns_dsaf_set_mac_uc_entry() argument
1620 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_set_mac_uc_entry()
1628 dev_err(dsaf_dev->dev, "set_uc %s Mac %pM err!\n", in hns_dsaf_set_mac_uc_entry()
1629 dsaf_dev->ae_dev.name, mac_entry->addr); in hns_dsaf_set_mac_uc_entry()
1634 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, mac_entry->in_vlan_id, in hns_dsaf_set_mac_uc_entry()
1638 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in hns_dsaf_set_mac_uc_entry()
1641 entry_index = hns_dsaf_find_empty_mac_entry(dsaf_dev); in hns_dsaf_set_mac_uc_entry()
1644 dev_err(dsaf_dev->dev, in hns_dsaf_set_mac_uc_entry()
1646 dsaf_dev->ae_dev.name, in hns_dsaf_set_mac_uc_entry()
1652 dev_dbg(dsaf_dev->dev, in hns_dsaf_set_mac_uc_entry()
1654 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_set_mac_uc_entry()
1667 hns_dsaf_tcam_uc_cfg(dsaf_dev, entry_index, &tcam_data, &mac_data); in hns_dsaf_set_mac_uc_entry()
1679 struct dsaf_device *dsaf_dev, in hns_dsaf_rm_mac_addr() argument
1688 dev_err(dsaf_dev->dev, "rm_uc_addr %s Mac %pM err!\n", in hns_dsaf_rm_mac_addr()
1689 dsaf_dev->ae_dev.name, mac_entry->addr); in hns_dsaf_rm_mac_addr()
1694 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, mac_entry->in_vlan_id, in hns_dsaf_rm_mac_addr()
1697 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in hns_dsaf_rm_mac_addr()
1700 dev_info(dsaf_dev->dev, in hns_dsaf_rm_mac_addr()
1702 dsaf_dev->ae_dev.name, in hns_dsaf_rm_mac_addr()
1707 dev_dbg(dsaf_dev->dev, in hns_dsaf_rm_mac_addr()
1709 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_rm_mac_addr()
1713 dsaf_dev, entry_index, in hns_dsaf_rm_mac_addr()
1721 return hns_dsaf_del_mac_entry(dsaf_dev, in hns_dsaf_rm_mac_addr()
1727 static void hns_dsaf_setup_mc_mask(struct dsaf_device *dsaf_dev, in hns_dsaf_setup_mc_mask() argument
1733 memcpy(mask, dsaf_dev->mac_cb[port_num]->mc_mask, ETH_ALEN); in hns_dsaf_setup_mc_mask()
1751 int hns_dsaf_add_mac_mc_port(struct dsaf_device *dsaf_dev, in hns_dsaf_add_mac_mc_port() argument
1759 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_add_mac_mc_port()
1767 dev_err(dsaf_dev->dev, "set_entry failed,addr %pM!\n", in hns_dsaf_add_mac_mc_port()
1773 if (!AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_add_mac_mc_port()
1777 hns_dsaf_setup_mc_mask(dsaf_dev, mac_entry->in_port_num, in hns_dsaf_add_mac_mc_port()
1782 hns_dsaf_set_mac_key(dsaf_dev, &mask_key, in hns_dsaf_add_mac_mc_port()
1792 dsaf_dev, &mac_key, mac_entry->in_vlan_id, in hns_dsaf_add_mac_mc_port()
1798 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in hns_dsaf_add_mac_mc_port()
1801 entry_index = hns_dsaf_find_empty_mac_entry(dsaf_dev); in hns_dsaf_add_mac_mc_port()
1804 dev_err(dsaf_dev->dev, in hns_dsaf_add_mac_mc_port()
1806 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_add_mac_mc_port()
1812 hns_dsaf_tcam_mc_get(dsaf_dev, entry_index, &tcam_data, in hns_dsaf_add_mac_mc_port()
1823 dev_err(dsaf_dev->dev, in hns_dsaf_add_mac_mc_port()
1825 dsaf_dev->ae_dev.name, mac_entry->port_num, in hns_dsaf_add_mac_mc_port()
1833 dev_dbg(dsaf_dev->dev, in hns_dsaf_add_mac_mc_port()
1835 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_add_mac_mc_port()
1842 hns_dsaf_tcam_mc_cfg(dsaf_dev, entry_index, &tcam_data, in hns_dsaf_add_mac_mc_port()
1861 int hns_dsaf_del_mac_entry(struct dsaf_device *dsaf_dev, u16 vlan_id, in hns_dsaf_del_mac_entry() argument
1867 (struct dsaf_drv_priv *)hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_del_mac_entry()
1872 dev_err(dsaf_dev->dev, "del_entry failed,addr %pM!\n", in hns_dsaf_del_mac_entry()
1878 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, vlan_id, in_port_num, addr); in hns_dsaf_del_mac_entry()
1881 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in hns_dsaf_del_mac_entry()
1884 dev_err(dsaf_dev->dev, in hns_dsaf_del_mac_entry()
1886 dsaf_dev->ae_dev.name, in hns_dsaf_del_mac_entry()
1890 dev_dbg(dsaf_dev->dev, in hns_dsaf_del_mac_entry()
1892 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_del_mac_entry()
1896 hns_dsaf_tcam_mc_invld(dsaf_dev, entry_index); in hns_dsaf_del_mac_entry()
1910 int hns_dsaf_del_mac_mc_port(struct dsaf_device *dsaf_dev, in hns_dsaf_del_mac_mc_port() argument
1915 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_del_mac_mc_port()
1928 dev_err(dsaf_dev->dev, in hns_dsaf_del_mac_mc_port()
1935 dev_err(dsaf_dev->dev, "del_port failed, addr %pM!\n", in hns_dsaf_del_mac_mc_port()
1943 if (!AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_del_mac_mc_port()
1947 hns_dsaf_setup_mc_mask(dsaf_dev, mac_entry->in_port_num, in hns_dsaf_del_mac_mc_port()
1952 hns_dsaf_set_mac_key(dsaf_dev, &mask_key, 0x00, 0xff, mc_mask); in hns_dsaf_del_mac_mc_port()
1962 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, vlan_id, in_port_num, mc_addr); in hns_dsaf_del_mac_mc_port()
1965 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in hns_dsaf_del_mac_mc_port()
1968 dev_err(dsaf_dev->dev, in hns_dsaf_del_mac_mc_port()
1970 dsaf_dev->ae_dev.name, in hns_dsaf_del_mac_mc_port()
1975 dev_dbg(dsaf_dev->dev, in hns_dsaf_del_mac_mc_port()
1977 dsaf_dev->ae_dev.name, mac_key.high.val, in hns_dsaf_del_mac_mc_port()
1981 hns_dsaf_tcam_mc_get(dsaf_dev, entry_index, &tcam_data, &mac_data); in hns_dsaf_del_mac_mc_port()
1990 dev_err(dsaf_dev->dev, in hns_dsaf_del_mac_mc_port()
1992 dsaf_dev->ae_dev.name, mac_entry->port_num, in hns_dsaf_del_mac_mc_port()
2001 hns_dsaf_tcam_mc_invld(dsaf_dev, entry_index); in hns_dsaf_del_mac_mc_port()
2010 hns_dsaf_tcam_mc_cfg(dsaf_dev, entry_index, in hns_dsaf_del_mac_mc_port()
2018 int hns_dsaf_clr_mac_mc_port(struct dsaf_device *dsaf_dev, u8 mac_id, in hns_dsaf_clr_mac_mc_port() argument
2021 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in hns_dsaf_clr_mac_mc_port()
2026 if (HNS_DSAF_IS_DEBUG(dsaf_dev)) in hns_dsaf_clr_mac_mc_port()
2058 if (hns_dsaf_del_mac_mc_port(dsaf_dev, &mac_entry)) { in hns_dsaf_clr_mac_mc_port()
2066 hns_dsaf_tcam_mc_get(dsaf_dev, i, in hns_dsaf_clr_mac_mc_port()
2075 if (hns_dsaf_del_mac_mc_port(dsaf_dev, in hns_dsaf_clr_mac_mc_port()
2090 struct dsaf_device *dsaf_dev; in hns_dsaf_alloc_dev() local
2092 dsaf_dev = devm_kzalloc(dev, in hns_dsaf_alloc_dev()
2093 sizeof(*dsaf_dev) + sizeof_priv, GFP_KERNEL); in hns_dsaf_alloc_dev()
2094 if (unlikely(!dsaf_dev)) { in hns_dsaf_alloc_dev()
2095 dsaf_dev = ERR_PTR(-ENOMEM); in hns_dsaf_alloc_dev()
2097 dsaf_dev->dev = dev; in hns_dsaf_alloc_dev()
2098 dev_set_drvdata(dev, dsaf_dev); in hns_dsaf_alloc_dev()
2101 return dsaf_dev; in hns_dsaf_alloc_dev()
2108 static void hns_dsaf_free_dev(struct dsaf_device *dsaf_dev) in hns_dsaf_free_dev() argument
2110 (void)dev_set_drvdata(dsaf_dev->dev, NULL); in hns_dsaf_free_dev()
2119 static void hns_dsaf_pfc_unit_cnt(struct dsaf_device *dsaf_dev, int mac_id, in hns_dsaf_pfc_unit_cnt() argument
2138 dsaf_set_dev_field(dsaf_dev, in hns_dsaf_pfc_unit_cnt()
2151 hns_dsaf_port_work_rate_cfg(struct dsaf_device *dsaf_dev, int mac_id, in hns_dsaf_port_work_rate_cfg() argument
2157 dsaf_dev, DSAF_XGE_GE_WORK_MODE_0_REG + 0x4 * (u64)mac_id); in hns_dsaf_port_work_rate_cfg()
2164 dsaf_write_dev(dsaf_dev, in hns_dsaf_port_work_rate_cfg()
2168 hns_dsaf_pfc_unit_cnt(dsaf_dev, mac_id, rate_mode); in hns_dsaf_port_work_rate_cfg()
2178 struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev; in hns_dsaf_fix_mac_mode() local
2188 hns_dsaf_port_work_rate_cfg(dsaf_dev, mac_id, mode); in hns_dsaf_fix_mac_mode()
2203 void hns_dsaf_update_stats(struct dsaf_device *dsaf_dev, u32 node_num) in hns_dsaf_update_stats() argument
2206 = &dsaf_dev->hw_stats[node_num]; in hns_dsaf_update_stats()
2207 bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver); in hns_dsaf_update_stats()
2211 hw_stats->pad_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2213 hw_stats->man_pkts += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2215 hw_stats->rx_pkts += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2217 hw_stats->rx_pkt_id += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2223 dsaf_read_dev(dsaf_dev, reg_tmp + 0x80 * (u64)node_num); in hns_dsaf_update_stats()
2225 hw_stats->release_buf_num += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2227 hw_stats->sbm_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2229 hw_stats->crc_false += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2231 hw_stats->bp_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2233 hw_stats->rslt_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2235 hw_stats->local_addr_false += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2238 hw_stats->vlan_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2240 hw_stats->stp_drop += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2247 hw_stats->rx_pfc[i] += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2249 hw_stats->tx_pfc[i] += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2255 hw_stats->tx_pkts += dsaf_read_dev(dsaf_dev, in hns_dsaf_update_stats()
2594 struct dsaf_device *dsaf_dev) in hns_dsaf_get_node_stats_strings() argument
2598 bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver); in hns_dsaf_get_node_stats_strings()
2703 int hns_dsaf_get_sset_count(struct dsaf_device *dsaf_dev, int stringset) in hns_dsaf_get_sset_count() argument
2705 bool is_ver1 = AE_IS_VER1(dsaf_dev->dsaf_ver); in hns_dsaf_get_sset_count()
2724 struct dsaf_device *dsaf_dev) in hns_dsaf_get_strings() argument
2733 buff = hns_dsaf_get_node_stats_strings(buff, node, dsaf_dev); in hns_dsaf_get_strings()
2737 (void)hns_dsaf_get_node_stats_strings(buff, node, dsaf_dev); in hns_dsaf_get_strings()
2760 static void set_promisc_tcam_enable(struct dsaf_device *dsaf_dev, u32 port) in set_promisc_tcam_enable() argument
2766 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in set_promisc_tcam_enable()
2779 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, 0x00, port, addr); in set_promisc_tcam_enable()
2780 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in set_promisc_tcam_enable()
2786 entry_index = hns_dsaf_find_empty_mac_entry_reverse(dsaf_dev); in set_promisc_tcam_enable()
2788 dev_err(dsaf_dev->dev, in set_promisc_tcam_enable()
2794 mac_cb = dsaf_dev->mac_cb[port]; in set_promisc_tcam_enable()
2799 hns_dsaf_tcam_uc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_uc, in set_promisc_tcam_enable()
2812 entry_index = hns_dsaf_find_empty_mac_entry_reverse(dsaf_dev); in set_promisc_tcam_enable()
2814 dev_err(dsaf_dev->dev, in set_promisc_tcam_enable()
2824 hns_dsaf_set_mac_key(dsaf_dev, &mask_key, mask_entry.in_vlan_id, in set_promisc_tcam_enable()
2832 dev_err(dsaf_dev->dev, "%s,pnum(%d)error,key(%#x:%#x)\n", in set_promisc_tcam_enable()
2833 dsaf_dev->ae_dev.name, port, in set_promisc_tcam_enable()
2843 dev_err(dsaf_dev->dev, in set_promisc_tcam_enable()
2845 dsaf_dev->ae_dev.name, port_num, in set_promisc_tcam_enable()
2853 hns_dsaf_tcam_mc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_mc, in set_promisc_tcam_enable()
2864 static void set_promisc_tcam_disable(struct dsaf_device *dsaf_dev, u32 port) in set_promisc_tcam_disable() argument
2869 struct dsaf_drv_priv *priv = hns_dsaf_dev_priv(dsaf_dev); in set_promisc_tcam_disable()
2879 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, 0x00, port, addr); in set_promisc_tcam_disable()
2880 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in set_promisc_tcam_disable()
2886 hns_dsaf_tcam_uc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_uc, in set_promisc_tcam_disable()
2898 hns_dsaf_set_mac_key(dsaf_dev, &mac_key, 0x00, port, addr); in set_promisc_tcam_disable()
2899 entry_index = hns_dsaf_find_soft_mac_entry(dsaf_dev, &mac_key); in set_promisc_tcam_disable()
2905 hns_dsaf_tcam_mc_cfg_vague(dsaf_dev, entry_index, &tbl_tcam_data_mc, in set_promisc_tcam_disable()
2913 void hns_dsaf_set_promisc_tcam(struct dsaf_device *dsaf_dev, in hns_dsaf_set_promisc_tcam() argument
2917 set_promisc_tcam_enable(dsaf_dev, port); in hns_dsaf_set_promisc_tcam()
2919 set_promisc_tcam_disable(dsaf_dev, port); in hns_dsaf_set_promisc_tcam()
2922 int hns_dsaf_wait_pkt_clean(struct dsaf_device *dsaf_dev, int port) in hns_dsaf_wait_pkt_clean() argument
2932 val = dsaf_read_dev(dsaf_dev, DSAF_VOQ_IN_PKT_NUM_0_REG + in hns_dsaf_wait_pkt_clean()
2934 val_tmp = dsaf_read_dev(dsaf_dev, DSAF_VOQ_OUT_PKT_NUM_0_REG + in hns_dsaf_wait_pkt_clean()
2943 dev_err(dsaf_dev->dev, "hns dsaf clean wait timeout(%u - %u).\n", in hns_dsaf_wait_pkt_clean()
2958 struct dsaf_device *dsaf_dev; in hns_dsaf_probe() local
2961 dsaf_dev = hns_dsaf_alloc_dev(&pdev->dev, sizeof(struct dsaf_drv_priv)); in hns_dsaf_probe()
2962 if (IS_ERR(dsaf_dev)) { in hns_dsaf_probe()
2963 ret = PTR_ERR(dsaf_dev); in hns_dsaf_probe()
2969 ret = hns_dsaf_get_cfg(dsaf_dev); in hns_dsaf_probe()
2973 ret = hns_dsaf_init(dsaf_dev); in hns_dsaf_probe()
2977 ret = hns_mac_init(dsaf_dev); in hns_dsaf_probe()
2981 ret = hns_ppe_init(dsaf_dev); in hns_dsaf_probe()
2985 ret = hns_dsaf_ae_init(dsaf_dev); in hns_dsaf_probe()
2992 hns_ppe_uninit(dsaf_dev); in hns_dsaf_probe()
2995 hns_mac_uninit(dsaf_dev); in hns_dsaf_probe()
2998 hns_dsaf_free(dsaf_dev); in hns_dsaf_probe()
3001 hns_dsaf_free_dev(dsaf_dev); in hns_dsaf_probe()
3012 struct dsaf_device *dsaf_dev = dev_get_drvdata(&pdev->dev); in hns_dsaf_remove() local
3014 hns_dsaf_ae_uninit(dsaf_dev); in hns_dsaf_remove()
3016 hns_ppe_uninit(dsaf_dev); in hns_dsaf_remove()
3018 hns_mac_uninit(dsaf_dev); in hns_dsaf_remove()
3020 hns_dsaf_free(dsaf_dev); in hns_dsaf_remove()
3022 hns_dsaf_free_dev(dsaf_dev); in hns_dsaf_remove()
3052 struct dsaf_device *dsaf_dev; in hns_dsaf_roce_reset() local
3096 dsaf_dev = dev_get_drvdata(&pdev->dev); in hns_dsaf_roce_reset()
3097 if (!dsaf_dev) { in hns_dsaf_roce_reset()
3104 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) { in hns_dsaf_roce_reset()
3105 dev_err(dsaf_dev->dev, "%s v1 chip doesn't support RoCE!\n", in hns_dsaf_roce_reset()
3106 dsaf_dev->ae_dev.name); in hns_dsaf_roce_reset()
3114 dsaf_dev->misc_op->hns_dsaf_srst_chns(dsaf_dev, DSAF_CHNS_MASK, in hns_dsaf_roce_reset()
3116 dsaf_dev->misc_op->hns_dsaf_roce_srst(dsaf_dev, false); in hns_dsaf_roce_reset()
3119 mp = dsaf_read_dev(dsaf_dev, DSAF_ROCE_PORT_MAP_REG); in hns_dsaf_roce_reset()
3124 dsaf_write_dev(dsaf_dev, DSAF_ROCE_PORT_MAP_REG, mp); in hns_dsaf_roce_reset()
3126 sl = dsaf_read_dev(dsaf_dev, DSAF_ROCE_SL_MAP_REG); in hns_dsaf_roce_reset()
3130 dsaf_write_dev(dsaf_dev, DSAF_ROCE_SL_MAP_REG, sl); in hns_dsaf_roce_reset()
3133 dsaf_dev->misc_op->hns_dsaf_srst_chns(dsaf_dev, DSAF_CHNS_MASK, in hns_dsaf_roce_reset()
3136 dsaf_dev->misc_op->hns_dsaf_roce_srst(dsaf_dev, true); in hns_dsaf_roce_reset()
3139 credit = dsaf_read_dev(dsaf_dev, DSAF_SBM_ROCEE_CFG_REG_REG); in hns_dsaf_roce_reset()
3141 dsaf_write_dev(dsaf_dev, DSAF_SBM_ROCEE_CFG_REG_REG, credit); in hns_dsaf_roce_reset()
3144 dsaf_write_dev(dsaf_dev, DSAF_SBM_ROCEE_CFG_REG_REG, credit); in hns_dsaf_roce_reset()