Lines Matching full:ocelot

2 /* Microsemi Ocelot Switch driver
49 static u32 vcap_read_update_ctrl(struct ocelot *ocelot, in vcap_read_update_ctrl() argument
52 return ocelot_target_read(ocelot, vcap->target, VCAP_CORE_UPDATE_CTRL); in vcap_read_update_ctrl()
55 static void vcap_cmd(struct ocelot *ocelot, const struct vcap_props *vcap, in vcap_cmd() argument
74 ocelot_target_write(ocelot, vcap->target, value, VCAP_CORE_UPDATE_CTRL); in vcap_cmd()
78 10, 100000, false, ocelot, vcap); in vcap_cmd()
82 static void vcap_row_cmd(struct ocelot *ocelot, const struct vcap_props *vcap, in vcap_row_cmd() argument
85 vcap_cmd(ocelot, vcap, vcap->entry_count - row - 1, cmd, sel); in vcap_row_cmd()
88 static void vcap_entry2cache(struct ocelot *ocelot, in vcap_entry2cache() argument
97 ocelot_target_write_rix(ocelot, vcap->target, data->entry[i], in vcap_entry2cache()
99 ocelot_target_write_rix(ocelot, vcap->target, ~data->mask[i], in vcap_entry2cache()
102 ocelot_target_write(ocelot, vcap->target, data->tg, VCAP_CACHE_TG_DAT); in vcap_entry2cache()
105 static void vcap_cache2entry(struct ocelot *ocelot, in vcap_cache2entry() argument
114 data->entry[i] = ocelot_target_read_rix(ocelot, vcap->target, in vcap_cache2entry()
117 data->mask[i] = ~ocelot_target_read_rix(ocelot, vcap->target, in vcap_cache2entry()
120 data->tg = ocelot_target_read(ocelot, vcap->target, VCAP_CACHE_TG_DAT); in vcap_cache2entry()
123 static void vcap_action2cache(struct ocelot *ocelot, in vcap_action2cache() argument
140 ocelot_target_write_rix(ocelot, vcap->target, data->action[i], in vcap_action2cache()
144 ocelot_target_write_rix(ocelot, vcap->target, data->counter[i], in vcap_action2cache()
148 static void vcap_cache2action(struct ocelot *ocelot, in vcap_cache2action() argument
158 data->action[i] = ocelot_target_read_rix(ocelot, vcap->target, in vcap_cache2action()
163 data->counter[i] = ocelot_target_read_rix(ocelot, vcap->target, in vcap_cache2action()
330 static void is2_action_set(struct ocelot *ocelot, struct vcap_data *data, in is2_action_set() argument
333 const struct vcap_props *vcap = &ocelot->vcap[VCAP_IS2]; in is2_action_set()
345 static void is2_entry_set(struct ocelot *ocelot, int ix, in is2_entry_set() argument
348 const struct vcap_props *vcap = &ocelot->vcap[VCAP_IS2]; in is2_entry_set()
359 vcap_row_cmd(ocelot, vcap, row, VCAP_CMD_READ, VCAP_SEL_ALL); in is2_entry_set()
360 vcap_cache2entry(ocelot, vcap, &data); in is2_entry_set()
361 vcap_cache2action(ocelot, vcap, &data); in is2_entry_set()
636 is2_action_set(ocelot, &data, filter); in is2_entry_set()
641 vcap_entry2cache(ocelot, vcap, &data); in is2_entry_set()
642 vcap_action2cache(ocelot, vcap, &data); in is2_entry_set()
643 vcap_row_cmd(ocelot, vcap, row, VCAP_CMD_WRITE, VCAP_SEL_ALL); in is2_entry_set()
646 static void is1_action_set(struct ocelot *ocelot, struct vcap_data *data, in is1_action_set() argument
649 const struct vcap_props *vcap = &ocelot->vcap[VCAP_IS1]; in is1_action_set()
669 static void is1_entry_set(struct ocelot *ocelot, int ix, in is1_entry_set() argument
672 const struct vcap_props *vcap = &ocelot->vcap[VCAP_IS1]; in is1_entry_set()
681 vcap_row_cmd(ocelot, vcap, row, VCAP_CMD_READ, VCAP_SEL_ALL); in is1_entry_set()
682 vcap_cache2entry(ocelot, vcap, &data); in is1_entry_set()
683 vcap_cache2action(ocelot, vcap, &data); in is1_entry_set()
771 is1_action_set(ocelot, &data, filter); in is1_entry_set()
776 vcap_entry2cache(ocelot, vcap, &data); in is1_entry_set()
777 vcap_action2cache(ocelot, vcap, &data); in is1_entry_set()
778 vcap_row_cmd(ocelot, vcap, row, VCAP_CMD_WRITE, VCAP_SEL_ALL); in is1_entry_set()
781 static void es0_action_set(struct ocelot *ocelot, struct vcap_data *data, in es0_action_set() argument
784 const struct vcap_props *vcap = &ocelot->vcap[VCAP_ES0]; in es0_action_set()
809 static void es0_entry_set(struct ocelot *ocelot, int ix, in es0_entry_set() argument
812 const struct vcap_props *vcap = &ocelot->vcap[VCAP_ES0]; in es0_entry_set()
820 vcap_row_cmd(ocelot, vcap, row, VCAP_CMD_READ, VCAP_SEL_ALL); in es0_entry_set()
821 vcap_cache2entry(ocelot, vcap, &data); in es0_entry_set()
822 vcap_cache2action(ocelot, vcap, &data); in es0_entry_set()
842 es0_action_set(ocelot, &data, filter); in es0_entry_set()
847 vcap_entry2cache(ocelot, vcap, &data); in es0_entry_set()
848 vcap_action2cache(ocelot, vcap, &data); in es0_entry_set()
849 vcap_row_cmd(ocelot, vcap, row, VCAP_CMD_WRITE, VCAP_SEL_ALL); in es0_entry_set()
852 static void vcap_entry_get(struct ocelot *ocelot, int ix, in vcap_entry_get() argument
855 const struct vcap_props *vcap = &ocelot->vcap[filter->block_id]; in vcap_entry_get()
867 vcap_row_cmd(ocelot, vcap, row, VCAP_CMD_READ, VCAP_SEL_COUNTER); in vcap_entry_get()
868 vcap_cache2action(ocelot, vcap, &data); in vcap_entry_get()
876 static void vcap_entry_set(struct ocelot *ocelot, int ix, in vcap_entry_set() argument
880 return is1_entry_set(ocelot, ix, filter); in vcap_entry_set()
882 return is2_entry_set(ocelot, ix, filter); in vcap_entry_set()
884 return es0_entry_set(ocelot, ix, filter); in vcap_entry_set()
893 int ocelot_vcap_policer_add(struct ocelot *ocelot, u32 pol_ix, in ocelot_vcap_policer_add() argument
907 list_for_each_entry(tmp, &ocelot->vcap_pol.pol_list, list) in ocelot_vcap_policer_add()
917 ret = qos_policer_conf_set(ocelot, pol_ix, &pp); in ocelot_vcap_policer_add()
925 list_add_tail(&tmp->list, &ocelot->vcap_pol.pol_list); in ocelot_vcap_policer_add()
931 int ocelot_vcap_policer_del(struct ocelot *ocelot, u32 pol_ix) in ocelot_vcap_policer_del() argument
937 list_for_each_entry_safe(tmp, n, &ocelot->vcap_pol.pol_list, list) in ocelot_vcap_policer_del()
948 return qos_policer_conf_set(ocelot, pol_ix, &pp); in ocelot_vcap_policer_del()
956 ocelot_vcap_filter_add_aux_resources(struct ocelot *ocelot, in ocelot_vcap_filter_add_aux_resources() argument
964 m = ocelot_mirror_get(ocelot, filter->egress_port.value, in ocelot_vcap_filter_add_aux_resources()
971 ret = ocelot_vcap_policer_add(ocelot, filter->action.pol_ix, in ocelot_vcap_filter_add_aux_resources()
981 ocelot_vcap_filter_del_aux_resources(struct ocelot *ocelot, in ocelot_vcap_filter_del_aux_resources() argument
985 ocelot_vcap_policer_del(ocelot, filter->action.pol_ix); in ocelot_vcap_filter_del_aux_resources()
988 ocelot_mirror_put(ocelot); in ocelot_vcap_filter_del_aux_resources()
991 static int ocelot_vcap_filter_add_to_block(struct ocelot *ocelot, in ocelot_vcap_filter_add_to_block() argument
1000 ret = ocelot_vcap_filter_add_aux_resources(ocelot, filter, extack); in ocelot_vcap_filter_add_to_block()
1079 static void ocelot_match_all_as_mac_etype(struct ocelot *ocelot, int port, in ocelot_match_all_as_mac_etype() argument
1091 ocelot_rmw_gix(ocelot, val, in ocelot_match_all_as_mac_etype()
1139 ocelot_exclusive_mac_etype_filter_rules(struct ocelot *ocelot, in ocelot_exclusive_mac_etype_filter_rules() argument
1142 struct ocelot_vcap_block *block = &ocelot->block[filter->block_id]; in ocelot_exclusive_mac_etype_filter_rules()
1162 ocelot->num_phys_ports) in ocelot_exclusive_mac_etype_filter_rules()
1163 ocelot_match_all_as_mac_etype(ocelot, port, in ocelot_exclusive_mac_etype_filter_rules()
1176 ocelot->num_phys_ports) in ocelot_exclusive_mac_etype_filter_rules()
1177 ocelot_match_all_as_mac_etype(ocelot, port, in ocelot_exclusive_mac_etype_filter_rules()
1184 int ocelot_vcap_filter_add(struct ocelot *ocelot, in ocelot_vcap_filter_add() argument
1188 struct ocelot_vcap_block *block = &ocelot->block[filter->block_id]; in ocelot_vcap_filter_add()
1191 if (!ocelot_exclusive_mac_etype_filter_rules(ocelot, filter)) { in ocelot_vcap_filter_add()
1198 ret = ocelot_vcap_filter_add_to_block(ocelot, block, filter, extack); in ocelot_vcap_filter_add()
1213 vcap_entry_get(ocelot, i - 1, tmp); in ocelot_vcap_filter_add()
1214 vcap_entry_set(ocelot, i, tmp); in ocelot_vcap_filter_add()
1218 vcap_entry_set(ocelot, index, filter); in ocelot_vcap_filter_add()
1223 static void ocelot_vcap_block_remove_filter(struct ocelot *ocelot, in ocelot_vcap_block_remove_filter() argument
1231 ocelot_vcap_filter_del_aux_resources(ocelot, tmp); in ocelot_vcap_block_remove_filter()
1240 int ocelot_vcap_filter_del(struct ocelot *ocelot, in ocelot_vcap_filter_del() argument
1243 struct ocelot_vcap_block *block = &ocelot->block[filter->block_id]; in ocelot_vcap_filter_del()
1259 ocelot_vcap_block_remove_filter(ocelot, block, filter); in ocelot_vcap_filter_del()
1267 vcap_entry_get(ocelot, i + 1, tmp); in ocelot_vcap_filter_del()
1268 vcap_entry_set(ocelot, i, tmp); in ocelot_vcap_filter_del()
1272 vcap_entry_set(ocelot, block->count, &del_filter); in ocelot_vcap_filter_del()
1278 int ocelot_vcap_filter_replace(struct ocelot *ocelot, in ocelot_vcap_filter_replace() argument
1281 struct ocelot_vcap_block *block = &ocelot->block[filter->block_id]; in ocelot_vcap_filter_replace()
1288 vcap_entry_set(ocelot, index, filter); in ocelot_vcap_filter_replace()
1294 int ocelot_vcap_filter_stats_update(struct ocelot *ocelot, in ocelot_vcap_filter_stats_update() argument
1297 struct ocelot_vcap_block *block = &ocelot->block[filter->block_id]; in ocelot_vcap_filter_stats_update()
1305 vcap_entry_get(ocelot, index, filter); in ocelot_vcap_filter_stats_update()
1310 vcap_entry_set(ocelot, index, &tmp); in ocelot_vcap_filter_stats_update()
1315 static void ocelot_vcap_init_one(struct ocelot *ocelot, in ocelot_vcap_init_one() argument
1322 vcap_entry2cache(ocelot, vcap, &data); in ocelot_vcap_init_one()
1323 ocelot_target_write(ocelot, vcap->target, vcap->entry_count, in ocelot_vcap_init_one()
1325 vcap_cmd(ocelot, vcap, 0, VCAP_CMD_INITIALIZE, VCAP_SEL_ENTRY); in ocelot_vcap_init_one()
1327 vcap_action2cache(ocelot, vcap, &data); in ocelot_vcap_init_one()
1328 ocelot_target_write(ocelot, vcap->target, vcap->action_count, in ocelot_vcap_init_one()
1330 vcap_cmd(ocelot, vcap, 0, VCAP_CMD_INITIALIZE, in ocelot_vcap_init_one()
1334 static void ocelot_vcap_detect_constants(struct ocelot *ocelot, in ocelot_vcap_detect_constants() argument
1341 version = ocelot_target_read(ocelot, vcap->target, in ocelot_vcap_detect_constants()
1348 vcap->tg_width = ocelot_target_read(ocelot, vcap->target, in ocelot_vcap_detect_constants()
1351 vcap->sw_count = ocelot_target_read(ocelot, vcap->target, in ocelot_vcap_detect_constants()
1356 vcap->entry_count = ocelot_target_read(ocelot, vcap->target, in ocelot_vcap_detect_constants()
1384 vcap->entry_width = ocelot_target_read(ocelot, vcap->target, in ocelot_vcap_detect_constants()
1387 num_default_actions = ocelot_target_read(ocelot, vcap->target, in ocelot_vcap_detect_constants()
1390 vcap->action_width = ocelot_target_read(ocelot, vcap->target, in ocelot_vcap_detect_constants()
1398 counter_memory_width = ocelot_target_read(ocelot, vcap->target, in ocelot_vcap_detect_constants()
1403 int ocelot_vcap_init(struct ocelot *ocelot) in ocelot_vcap_init() argument
1414 ret = qos_policer_conf_set(ocelot, OCELOT_POLICER_DISCARD, &cpu_drop); in ocelot_vcap_init()
1419 struct ocelot_vcap_block *block = &ocelot->block[i]; in ocelot_vcap_init()
1420 struct vcap_props *vcap = &ocelot->vcap[i]; in ocelot_vcap_init()
1424 ocelot_vcap_detect_constants(ocelot, vcap); in ocelot_vcap_init()
1425 ocelot_vcap_init_one(ocelot, vcap); in ocelot_vcap_init()
1428 INIT_LIST_HEAD(&ocelot->dummy_rules); in ocelot_vcap_init()
1429 INIT_LIST_HEAD(&ocelot->traps); in ocelot_vcap_init()
1430 INIT_LIST_HEAD(&ocelot->vcap_pol.pol_list); in ocelot_vcap_init()