Lines Matching refs:filter

147 	struct ocelot_vcap_filter *filter;
158 list_for_each_entry(filter, &block->rules, list)
159 if (filter->type == OCELOT_VCAP_FILTER_PAG &&
160 filter->goto_target == chain)
161 return filter;
164 list_for_each_entry(filter, &ocelot->dummy_rules, list)
165 if (filter->goto_target == chain)
166 return filter;
173 struct ocelot_vcap_filter *filter,
179 if (filter->goto_target != -1) {
191 filter->action.vid_replace_ena = true;
192 filter->action.pcp_dei_ena = true;
193 filter->action.vid = a->vlan.vid;
194 filter->action.pcp = a->vlan.prio;
195 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
201 ocelot_flower_parse_egress_vlan_modify(struct ocelot_vcap_filter *filter,
220 filter->action.tag_a_tpid_sel = tpid;
221 filter->action.push_outer_tag = OCELOT_ES0_TAG;
222 filter->action.tag_a_vid_sel = OCELOT_ES0_VID_PLUS_CLASSIFIED_VID;
223 filter->action.vid_a_val = a->vlan.vid;
224 filter->action.pcp_a_val = a->vlan.prio;
225 filter->action.tag_a_pcp_sel = OCELOT_ES0_PCP;
226 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
233 struct ocelot_vcap_filter *filter)
250 filter->block_id = ocelot_chain_to_block(chain, ingress);
251 if (filter->block_id < 0) {
255 if (filter->block_id == VCAP_IS1 || filter->block_id == VCAP_IS2)
256 filter->lookup = ocelot_chain_to_lookup(chain);
257 if (filter->block_id == VCAP_IS2)
258 filter->pag = ocelot_chain_to_pag(chain);
260 filter->goto_target = -1;
261 filter->type = OCELOT_VCAP_FILTER_DUMMY;
266 if (filter->block_id != VCAP_IS2) {
271 if (filter->goto_target != -1) {
276 filter->action.mask_mode = OCELOT_MASK_MODE_PERMIT_DENY;
277 filter->action.port_mask = 0;
278 filter->action.police_ena = true;
279 filter->action.pol_ix = OCELOT_POLICER_DISCARD;
280 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
283 if (filter->block_id != VCAP_ES0 &&
284 filter->block_id != VCAP_IS1 &&
285 filter->block_id != VCAP_IS2) {
290 if (filter->block_id != VCAP_ES0 &&
291 filter->goto_target != -1) {
296 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
299 if (filter->block_id != VCAP_IS2 ||
300 filter->lookup != 0) {
305 if (filter->goto_target != -1) {
310 filter->action.mask_mode = OCELOT_MASK_MODE_PERMIT_DENY;
311 filter->action.port_mask = 0;
312 filter->action.cpu_copy_ena = true;
313 filter->action.cpu_qu_num = 0;
314 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
315 filter->is_trap = true;
318 if (filter->block_id == PSFP_BLOCK_ID) {
319 filter->type = OCELOT_PSFP_FILTER_OFFLOAD;
322 if (filter->block_id != VCAP_IS2 ||
323 filter->lookup != 0) {
328 if (filter->goto_target != -1) {
338 filter->action.police_ena = true;
351 filter->action.pol_ix = pol_ix;
354 filter->action.pol.rate = div_u64(rate, 1000) * 8;
355 filter->action.pol.burst = a->police.burst;
356 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
359 if (filter->block_id != VCAP_IS2) {
364 if (filter->goto_target != -1) {
375 filter->action.mask_mode = OCELOT_MASK_MODE_REDIRECT;
376 filter->action.port_mask = BIT(egress_port);
377 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
380 if (filter->block_id != VCAP_IS2) {
385 if (filter->goto_target != -1) {
396 filter->egress_port.value = egress_port;
397 filter->action.mirror_ena = true;
398 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
401 if (filter->block_id != VCAP_IS1) {
406 if (filter->goto_target != -1) {
411 filter->action.vlan_pop_cnt_ena = true;
412 filter->action.vlan_pop_cnt++;
413 if (filter->action.vlan_pop_cnt > 2) {
418 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
421 if (filter->block_id == VCAP_IS1) {
423 filter, a,
425 } else if (filter->block_id == VCAP_ES0) {
426 err = ocelot_flower_parse_egress_vlan_modify(filter, a,
437 if (filter->block_id != VCAP_IS1) {
442 if (filter->goto_target != -1) {
447 filter->action.qos_ena = true;
448 filter->action.qos_val = a->priority;
449 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
452 filter->goto_target = a->chain_index;
454 if (filter->block_id == VCAP_IS1 && filter->lookup == 2) {
455 int pag = ocelot_chain_to_pag(filter->goto_target);
457 filter->action.pag_override_mask = 0xff;
458 filter->action.pag_val = pag;
459 filter->type = OCELOT_VCAP_FILTER_PAG;
463 if (filter->block_id != VCAP_ES0) {
480 filter->action.tag_a_tpid_sel = tpid;
481 filter->action.push_outer_tag = OCELOT_ES0_TAG;
482 filter->action.tag_a_vid_sel = OCELOT_ES0_VID;
483 filter->action.vid_a_val = a->vlan.vid;
484 filter->action.pcp_a_val = a->vlan.prio;
485 filter->type = OCELOT_VCAP_FILTER_OFFLOAD;
488 if (filter->block_id != PSFP_BLOCK_ID) {
493 filter->type = OCELOT_PSFP_FILTER_OFFLOAD;
501 if (filter->goto_target == -1) {
502 if ((filter->block_id == VCAP_IS2 && filter->lookup == 1) ||
503 chain == 0 || filter->block_id == PSFP_BLOCK_ID) {
511 if (!ocelot_is_goto_target_valid(filter->goto_target, chain, ingress) &&
522 struct ocelot_vcap_filter *filter)
565 filter->ingress_port.value = ingress_port;
566 filter->ingress_port.mask = GENMASK(key_length - 1, 0);
574 struct ocelot_vcap_filter *filter)
607 ret = ocelot_flower_parse_indev(ocelot, port, f, filter);
619 filter->key_type = OCELOT_VCAP_KEY_ANY;
620 filter->vlan.vid.value = match.key->vlan_id;
621 filter->vlan.vid.mask = match.mask->vlan_id;
622 filter->vlan.pcp.value[0] = match.key->vlan_priority;
623 filter->vlan.pcp.mask[0] = match.mask->vlan_priority;
630 if (filter->block_id == VCAP_ES0) {
651 if (filter->block_id == VCAP_IS1 &&
658 filter->key_type = OCELOT_VCAP_KEY_ETYPE;
659 ether_addr_copy(filter->key.etype.dmac.value,
661 ether_addr_copy(filter->key.etype.smac.value,
663 ether_addr_copy(filter->key.etype.dmac.mask,
665 ether_addr_copy(filter->key.etype.smac.mask,
675 if (filter->block_id == VCAP_ES0) {
681 filter->key_type = OCELOT_VCAP_KEY_IPV4;
682 filter->key.ipv4.proto.value[0] =
684 filter->key.ipv4.proto.mask[0] =
689 if (filter->block_id == VCAP_ES0) {
695 filter->key_type = OCELOT_VCAP_KEY_IPV6;
696 filter->key.ipv6.proto.value[0] =
698 filter->key.ipv6.proto.mask[0] =
709 if (filter->block_id == VCAP_ES0) {
717 if (filter->block_id == VCAP_IS1 && *(u32 *)&match.mask->dst) {
723 tmp = &filter->key.ipv4.sip.value.addr[0];
726 tmp = &filter->key.ipv4.sip.mask.addr[0];
729 tmp = &filter->key.ipv4.dip.value.addr[0];
732 tmp = &filter->key.ipv4.dip.mask.addr[0];
745 if (filter->block_id == VCAP_ES0) {
752 filter->key.ipv4.sport.value = ntohs(match.key->src);
753 filter->key.ipv4.sport.mask = ntohs(match.mask->src);
754 filter->key.ipv4.dport.value = ntohs(match.key->dst);
755 filter->key.ipv4.dport.mask = ntohs(match.mask->dst);
761 if (filter->block_id == VCAP_ES0) {
770 filter->key_type = OCELOT_VCAP_KEY_ETYPE;
771 *(__be16 *)filter->key.etype.etype.value = htons(proto);
772 *(__be16 *)filter->key.etype.etype.mask = htons(0xffff);
774 /* else, a filter of type OCELOT_VCAP_KEY_ANY is implicitly added */
781 struct ocelot_vcap_filter *filter)
785 filter->prio = f->common.prio;
786 filter->id.cookie = f->cookie;
787 filter->id.tc_offload = true;
789 ret = ocelot_flower_parse_action(ocelot, port, ingress, f, filter);
793 /* PSFP filter need to parse key by stream identification function. */
794 if (filter->type == OCELOT_PSFP_FILTER_OFFLOAD)
797 return ocelot_flower_parse_key(ocelot, port, ingress, f, filter);
804 struct ocelot_vcap_filter *filter;
806 filter = kzalloc(sizeof(*filter), GFP_KERNEL);
807 if (!filter)
811 filter->ingress_port_mask = BIT(port);
816 filter->egress_port.value = port;
817 filter->egress_port.mask = GENMASK(key_length - 1, 0);
820 return filter;
824 struct ocelot_vcap_filter *filter)
826 list_add(&filter->list, &ocelot->dummy_rules);
832 struct ocelot_vcap_filter *filter)
834 list_del(&filter->list);
835 kfree(filter);
846 ocelot_flower_patch_es0_vlan_modify(struct ocelot_vcap_filter *filter,
849 if (filter->block_id != VCAP_ES0 ||
850 filter->action.tag_a_vid_sel != OCELOT_ES0_VID_PLUS_CLASSIFIED_VID)
853 if (filter->vlan.vid.mask != VLAN_VID_MASK) {
859 filter->action.vid_a_val -= filter->vlan.vid.value;
860 filter->action.vid_a_val &= VLAN_VID_MASK;
869 struct ocelot_vcap_filter *filter;
884 filter = ocelot_vcap_block_find_filter_by_id(&ocelot->block[block_id],
886 if (filter) {
893 filter->ingress_port_mask |= BIT(port);
895 return ocelot_vcap_filter_replace(ocelot, filter);
899 filter = ocelot_vcap_filter_create(ocelot, port, ingress, f);
900 if (!filter)
903 ret = ocelot_flower_parse(ocelot, port, ingress, f, filter);
905 kfree(filter);
909 ret = ocelot_flower_patch_es0_vlan_modify(filter, extack);
911 kfree(filter);
918 if (filter->type == OCELOT_VCAP_FILTER_DUMMY)
919 return ocelot_vcap_dummy_filter_add(ocelot, filter);
921 if (filter->type == OCELOT_PSFP_FILTER_OFFLOAD) {
922 kfree(filter);
930 return ocelot_vcap_filter_add(ocelot, filter, f->common.extack);
937 struct ocelot_vcap_filter *filter;
954 filter = ocelot_vcap_block_find_filter_by_id(block, f->cookie, true);
955 if (!filter)
958 if (filter->type == OCELOT_VCAP_FILTER_DUMMY)
959 return ocelot_vcap_dummy_filter_del(ocelot, filter);
962 filter->ingress_port_mask &= ~BIT(port);
963 if (filter->ingress_port_mask)
964 return ocelot_vcap_filter_replace(ocelot, filter);
967 return ocelot_vcap_filter_del(ocelot, filter);
974 struct ocelot_vcap_filter *filter;
997 filter = ocelot_vcap_block_find_filter_by_id(block, f->cookie, true);
998 if (!filter || filter->type == OCELOT_VCAP_FILTER_DUMMY)
1001 ret = ocelot_vcap_filter_stats_update(ocelot, filter);
1005 stats.pkts = filter->stats.pkts;