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