Lines Matching +full:flags +full:- +full:mask
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 /* Copyright (C) 2017-2018 Netronome Systems, Inc. */
15 ext->nfp_flow_key_layer = key_type; in nfp_flower_compile_meta()
16 ext->mask_id = ~0; in nfp_flower_compile_meta()
18 msk->nfp_flow_key_layer = key_type; in nfp_flower_compile_meta()
19 msk->mask_id = ~0; in nfp_flower_compile_meta()
36 match.key->vlan_priority) | in nfp_flower_compile_tci()
38 match.key->vlan_id); in nfp_flower_compile_tci()
42 match.mask->vlan_priority) | in nfp_flower_compile_tci()
44 match.mask->vlan_id); in nfp_flower_compile_tci()
46 ext->tci |= cpu_to_be16((key_tci & msk_tci)); in nfp_flower_compile_tci()
47 msk->tci |= cpu_to_be16(msk_tci); in nfp_flower_compile_tci()
68 frame->nfp_flow_key_layer2 = cpu_to_be32(key_ext); in nfp_flower_compile_ext_meta()
77 frame->in_port = cpu_to_be32(~0); in nfp_flower_compile_port()
82 frame->in_port = cpu_to_be32(NFP_FL_PORT_TYPE_TUN | tun_type); in nfp_flower_compile_port()
86 return -EOPNOTSUPP; in nfp_flower_compile_port()
88 frame->in_port = cpu_to_be32(cmsg_port); in nfp_flower_compile_port()
107 tmp = match.key->dst[i] & match.mask->dst[i]; in nfp_flower_compile_mac()
108 ext->mac_dst[i] |= tmp & (~msk->mac_dst[i]); in nfp_flower_compile_mac()
109 msk->mac_dst[i] |= match.mask->dst[i]; in nfp_flower_compile_mac()
111 tmp = match.key->src[i] & match.mask->src[i]; in nfp_flower_compile_mac()
112 ext->mac_src[i] |= tmp & (~msk->mac_src[i]); in nfp_flower_compile_mac()
113 msk->mac_src[i] |= match.mask->src[i]; in nfp_flower_compile_mac()
131 if (match.mask->used_lses != 1) { in nfp_flower_compile_mpls()
134 return -EOPNOTSUPP; in nfp_flower_compile_mpls()
138 match.key->ls[0].mpls_label) | in nfp_flower_compile_mpls()
140 match.key->ls[0].mpls_tc) | in nfp_flower_compile_mpls()
142 match.key->ls[0].mpls_bos) | in nfp_flower_compile_mpls()
146 match.mask->ls[0].mpls_label) | in nfp_flower_compile_mpls()
148 match.mask->ls[0].mpls_tc) | in nfp_flower_compile_mpls()
150 match.mask->ls[0].mpls_bos) | in nfp_flower_compile_mpls()
153 ext->mpls_lse |= cpu_to_be32((key_mpls & msk_mpls)); in nfp_flower_compile_mpls()
154 msk->mpls_lse |= cpu_to_be32(msk_mpls); in nfp_flower_compile_mpls()
163 if (match.key->n_proto == cpu_to_be16(ETH_P_MPLS_UC) || in nfp_flower_compile_mpls()
164 match.key->n_proto == cpu_to_be16(ETH_P_MPLS_MC)) { in nfp_flower_compile_mpls()
165 ext->mpls_lse |= cpu_to_be32(NFP_FLOWER_MASK_MPLS_Q); in nfp_flower_compile_mpls()
166 msk->mpls_lse |= cpu_to_be32(NFP_FLOWER_MASK_MPLS_Q); in nfp_flower_compile_mpls()
198 tmp = match.key->src & match.mask->src; in nfp_flower_compile_tport()
199 ext->port_src |= tmp & (~msk->port_src); in nfp_flower_compile_tport()
200 msk->port_src |= match.mask->src; in nfp_flower_compile_tport()
202 tmp = match.key->dst & match.mask->dst; in nfp_flower_compile_tport()
203 ext->port_dst |= tmp & (~msk->port_dst); in nfp_flower_compile_tport()
204 msk->port_dst |= match.mask->dst; in nfp_flower_compile_tport()
216 ext->proto |= match.key->ip_proto & match.mask->ip_proto; in nfp_flower_compile_ip_ext()
217 msk->proto |= match.mask->ip_proto; in nfp_flower_compile_ip_ext()
226 tmp = match.key->tos & match.mask->tos; in nfp_flower_compile_ip_ext()
227 ext->tos |= tmp & (~msk->tos); in nfp_flower_compile_ip_ext()
228 msk->tos |= match.mask->tos; in nfp_flower_compile_ip_ext()
230 tmp = match.key->ttl & match.mask->ttl; in nfp_flower_compile_ip_ext()
231 ext->ttl |= tmp & (~msk->ttl); in nfp_flower_compile_ip_ext()
232 msk->ttl |= match.mask->ttl; in nfp_flower_compile_ip_ext()
240 tcp_flags = be16_to_cpu(match.key->flags); in nfp_flower_compile_ip_ext()
241 tcp_flags_mask = be16_to_cpu(match.mask->flags); in nfp_flower_compile_ip_ext()
244 ext->flags |= NFP_FL_TCP_FLAG_FIN; in nfp_flower_compile_ip_ext()
246 msk->flags |= NFP_FL_TCP_FLAG_FIN; in nfp_flower_compile_ip_ext()
249 ext->flags |= NFP_FL_TCP_FLAG_SYN; in nfp_flower_compile_ip_ext()
251 msk->flags |= NFP_FL_TCP_FLAG_SYN; in nfp_flower_compile_ip_ext()
254 ext->flags |= NFP_FL_TCP_FLAG_RST; in nfp_flower_compile_ip_ext()
256 msk->flags |= NFP_FL_TCP_FLAG_RST; in nfp_flower_compile_ip_ext()
259 ext->flags |= NFP_FL_TCP_FLAG_PSH; in nfp_flower_compile_ip_ext()
261 msk->flags |= NFP_FL_TCP_FLAG_PSH; in nfp_flower_compile_ip_ext()
264 ext->flags |= NFP_FL_TCP_FLAG_URG; in nfp_flower_compile_ip_ext()
266 msk->flags |= NFP_FL_TCP_FLAG_URG; in nfp_flower_compile_ip_ext()
273 if (match.key->flags & FLOW_DIS_IS_FRAGMENT) in nfp_flower_compile_ip_ext()
274 ext->flags |= NFP_FL_IP_FRAGMENTED; in nfp_flower_compile_ip_ext()
275 if (match.mask->flags & FLOW_DIS_IS_FRAGMENT) in nfp_flower_compile_ip_ext()
276 msk->flags |= NFP_FL_IP_FRAGMENTED; in nfp_flower_compile_ip_ext()
277 if (match.key->flags & FLOW_DIS_FIRST_FRAG) in nfp_flower_compile_ip_ext()
278 ext->flags |= NFP_FL_IP_FRAG_FIRST; in nfp_flower_compile_ip_ext()
279 if (match.mask->flags & FLOW_DIS_FIRST_FRAG) in nfp_flower_compile_ip_ext()
280 msk->flags |= NFP_FL_IP_FRAG_FIRST; in nfp_flower_compile_ip_ext()
289 struct flow_dissector_key_vlan *mask = match->mask; in nfp_flower_fill_vlan() local
290 struct flow_dissector_key_vlan *key = match->key; in nfp_flower_fill_vlan()
295 key->vlan_priority) | in nfp_flower_fill_vlan()
297 key->vlan_id); in nfp_flower_fill_vlan()
300 mask->vlan_priority) | in nfp_flower_fill_vlan()
302 mask->vlan_id); in nfp_flower_fill_vlan()
305 ext->outer_tci |= cpu_to_be16((key_tci & msk_tci)); in nfp_flower_fill_vlan()
306 ext->outer_tpid |= key->vlan_tpid & mask->vlan_tpid; in nfp_flower_fill_vlan()
307 msk->outer_tci |= cpu_to_be16(msk_tci); in nfp_flower_fill_vlan()
308 msk->outer_tpid |= mask->vlan_tpid; in nfp_flower_fill_vlan()
310 ext->inner_tci |= cpu_to_be16((key_tci & msk_tci)); in nfp_flower_fill_vlan()
311 ext->inner_tpid |= key->vlan_tpid & mask->vlan_tpid; in nfp_flower_fill_vlan()
312 msk->inner_tci |= cpu_to_be16(msk_tci); in nfp_flower_fill_vlan()
313 msk->inner_tpid |= mask->vlan_tpid; in nfp_flower_fill_vlan()
344 tmp = match.key->src & match.mask->src; in nfp_flower_compile_ipv4()
345 ext->ipv4_src |= tmp & (~msk->ipv4_src); in nfp_flower_compile_ipv4()
346 msk->ipv4_src |= match.mask->src; in nfp_flower_compile_ipv4()
348 tmp = match.key->dst & match.mask->dst; in nfp_flower_compile_ipv4()
349 ext->ipv4_dst |= tmp & (~msk->ipv4_dst); in nfp_flower_compile_ipv4()
350 msk->ipv4_dst |= match.mask->dst; in nfp_flower_compile_ipv4()
353 nfp_flower_compile_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); in nfp_flower_compile_ipv4()
366 for (i = 0; i < sizeof(ext->ipv6_src); i++) { in nfp_flower_compile_ipv6()
367 tmp = match.key->src.s6_addr[i] & in nfp_flower_compile_ipv6()
368 match.mask->src.s6_addr[i]; in nfp_flower_compile_ipv6()
369 ext->ipv6_src.s6_addr[i] |= tmp & in nfp_flower_compile_ipv6()
370 (~msk->ipv6_src.s6_addr[i]); in nfp_flower_compile_ipv6()
371 msk->ipv6_src.s6_addr[i] |= match.mask->src.s6_addr[i]; in nfp_flower_compile_ipv6()
373 tmp = match.key->dst.s6_addr[i] & in nfp_flower_compile_ipv6()
374 match.mask->dst.s6_addr[i]; in nfp_flower_compile_ipv6()
375 ext->ipv6_dst.s6_addr[i] |= tmp & in nfp_flower_compile_ipv6()
376 (~msk->ipv6_dst.s6_addr[i]); in nfp_flower_compile_ipv6()
377 msk->ipv6_dst.s6_addr[i] |= match.mask->dst.s6_addr[i]; in nfp_flower_compile_ipv6()
381 nfp_flower_compile_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); in nfp_flower_compile_ipv6()
393 for (i = 0; i < match.mask->len; i++) { in nfp_flower_compile_geneve_opt()
394 ext[i] |= match.key->data[i] & match.mask->data[i]; in nfp_flower_compile_geneve_opt()
395 msk[i] |= match.mask->data[i]; in nfp_flower_compile_geneve_opt()
409 ext->src |= match.key->src & match.mask->src; in nfp_flower_compile_tun_ipv4_addrs()
410 ext->dst |= match.key->dst & match.mask->dst; in nfp_flower_compile_tun_ipv4_addrs()
411 msk->src |= match.mask->src; in nfp_flower_compile_tun_ipv4_addrs()
412 msk->dst |= match.mask->dst; in nfp_flower_compile_tun_ipv4_addrs()
426 for (i = 0; i < sizeof(ext->src); i++) { in nfp_flower_compile_tun_ipv6_addrs()
427 ext->src.s6_addr[i] |= match.key->src.s6_addr[i] & in nfp_flower_compile_tun_ipv6_addrs()
428 match.mask->src.s6_addr[i]; in nfp_flower_compile_tun_ipv6_addrs()
429 ext->dst.s6_addr[i] |= match.key->dst.s6_addr[i] & in nfp_flower_compile_tun_ipv6_addrs()
430 match.mask->dst.s6_addr[i]; in nfp_flower_compile_tun_ipv6_addrs()
431 msk->src.s6_addr[i] |= match.mask->src.s6_addr[i]; in nfp_flower_compile_tun_ipv6_addrs()
432 msk->dst.s6_addr[i] |= match.mask->dst.s6_addr[i]; in nfp_flower_compile_tun_ipv6_addrs()
446 ext->tos |= match.key->tos & match.mask->tos; in nfp_flower_compile_tun_ip_ext()
447 ext->ttl |= match.key->ttl & match.mask->ttl; in nfp_flower_compile_tun_ip_ext()
448 msk->tos |= match.mask->tos; in nfp_flower_compile_tun_ip_ext()
449 msk->ttl |= match.mask->ttl; in nfp_flower_compile_tun_ip_ext()
462 vni = be32_to_cpu((match.key->keyid & match.mask->keyid)) << in nfp_flower_compile_tun_udp_key()
465 vni = be32_to_cpu(match.mask->keyid) << NFP_FL_TUN_VNI_OFFSET; in nfp_flower_compile_tun_udp_key()
471 nfp_flower_compile_tun_gre_key(__be32 *key, __be32 *key_msk, __be16 *flags, in nfp_flower_compile_tun_gre_key() argument
478 *key |= match.key->keyid & match.mask->keyid; in nfp_flower_compile_tun_gre_key()
479 *key_msk |= match.mask->keyid; in nfp_flower_compile_tun_gre_key()
481 *flags = cpu_to_be16(NFP_FL_GRE_FLAG_KEY); in nfp_flower_compile_tun_gre_key()
492 ext->ethertype = cpu_to_be16(ETH_P_TEB); in nfp_flower_compile_ipv4_gre_tun()
493 msk->ethertype = cpu_to_be16(~0); in nfp_flower_compile_ipv4_gre_tun()
495 nfp_flower_compile_tun_ipv4_addrs(&ext->ipv4, &msk->ipv4, rule); in nfp_flower_compile_ipv4_gre_tun()
496 nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); in nfp_flower_compile_ipv4_gre_tun()
497 nfp_flower_compile_tun_gre_key(&ext->tun_key, &msk->tun_key, in nfp_flower_compile_ipv4_gre_tun()
498 &ext->tun_flags, &msk->tun_flags, rule); in nfp_flower_compile_ipv4_gre_tun()
506 nfp_flower_compile_tun_ipv4_addrs(&ext->ipv4, &msk->ipv4, rule); in nfp_flower_compile_ipv4_udp_tun()
507 nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); in nfp_flower_compile_ipv4_udp_tun()
508 nfp_flower_compile_tun_udp_key(&ext->tun_id, &msk->tun_id, rule); in nfp_flower_compile_ipv4_udp_tun()
516 nfp_flower_compile_tun_ipv6_addrs(&ext->ipv6, &msk->ipv6, rule); in nfp_flower_compile_ipv6_udp_tun()
517 nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); in nfp_flower_compile_ipv6_udp_tun()
518 nfp_flower_compile_tun_udp_key(&ext->tun_id, &msk->tun_id, rule); in nfp_flower_compile_ipv6_udp_tun()
527 ext->ethertype = cpu_to_be16(ETH_P_TEB); in nfp_flower_compile_ipv6_gre_tun()
528 msk->ethertype = cpu_to_be16(~0); in nfp_flower_compile_ipv6_gre_tun()
530 nfp_flower_compile_tun_ipv6_addrs(&ext->ipv6, &msk->ipv6, rule); in nfp_flower_compile_ipv6_gre_tun()
531 nfp_flower_compile_tun_ip_ext(&ext->ip_ext, &msk->ip_ext, rule); in nfp_flower_compile_ipv6_gre_tun()
532 nfp_flower_compile_tun_gre_key(&ext->tun_key, &msk->tun_key, in nfp_flower_compile_ipv6_gre_tun()
533 &ext->tun_flags, &msk->tun_flags, rule); in nfp_flower_compile_ipv6_gre_tun()
544 struct nfp_flower_priv *priv = app->priv; in nfp_flower_compile_flow_match()
554 memset(nfp_flow->unmasked_data, 0, key_ls->key_size); in nfp_flower_compile_flow_match()
555 memset(nfp_flow->mask_data, 0, key_ls->key_size); in nfp_flower_compile_flow_match()
557 ext = nfp_flow->unmasked_data; in nfp_flower_compile_flow_match()
558 msk = nfp_flow->mask_data; in nfp_flower_compile_flow_match()
560 qinq_sup = !!(priv->flower_ext_feats & NFP_FL_FEATS_VLAN_QINQ); in nfp_flower_compile_flow_match()
564 rule, key_ls->key_layer, qinq_sup); in nfp_flower_compile_flow_match()
569 if (NFP_FLOWER_LAYER_EXT_META & key_ls->key_layer) { in nfp_flower_compile_flow_match()
571 key_ls->key_layer_two); in nfp_flower_compile_flow_match()
573 key_ls->key_layer_two); in nfp_flower_compile_flow_match()
584 /* Populate Mask Port Data. */ in nfp_flower_compile_flow_match()
593 if (NFP_FLOWER_LAYER_MAC & key_ls->key_layer) { in nfp_flower_compile_flow_match()
604 if (NFP_FLOWER_LAYER_TP & key_ls->key_layer) { in nfp_flower_compile_flow_match()
612 if (NFP_FLOWER_LAYER_IPV4 & key_ls->key_layer) { in nfp_flower_compile_flow_match()
620 if (NFP_FLOWER_LAYER_IPV6 & key_ls->key_layer) { in nfp_flower_compile_flow_match()
628 if (NFP_FLOWER_LAYER2_QINQ & key_ls->key_layer_two) { in nfp_flower_compile_flow_match()
636 if (key_ls->key_layer_two & NFP_FLOWER_LAYER2_GRE) { in nfp_flower_compile_flow_match()
637 if (key_ls->key_layer_two & NFP_FLOWER_LAYER2_TUN_IPV6) { in nfp_flower_compile_flow_match()
645 dst = &gre_match->ipv6.dst; in nfp_flower_compile_flow_match()
651 return -EOPNOTSUPP; in nfp_flower_compile_flow_match()
653 nfp_flow->nfp_tun_ipv6 = entry; in nfp_flower_compile_flow_match()
659 dst = ((struct nfp_flower_ipv4_gre_tun *)ext)->ipv4.dst; in nfp_flower_compile_flow_match()
666 nfp_flow->nfp_tun_ipv4_addr = dst; in nfp_flower_compile_flow_match()
671 if (key_ls->key_layer & NFP_FLOWER_LAYER_VXLAN || in nfp_flower_compile_flow_match()
672 key_ls->key_layer_two & NFP_FLOWER_LAYER2_GENEVE) { in nfp_flower_compile_flow_match()
673 if (key_ls->key_layer_two & NFP_FLOWER_LAYER2_TUN_IPV6) { in nfp_flower_compile_flow_match()
681 dst = &udp_match->ipv6.dst; in nfp_flower_compile_flow_match()
687 return -EOPNOTSUPP; in nfp_flower_compile_flow_match()
689 nfp_flow->nfp_tun_ipv6 = entry; in nfp_flower_compile_flow_match()
695 dst = ((struct nfp_flower_ipv4_udp_tun *)ext)->ipv4.dst; in nfp_flower_compile_flow_match()
702 nfp_flow->nfp_tun_ipv4_addr = dst; in nfp_flower_compile_flow_match()
706 if (key_ls->key_layer_two & NFP_FLOWER_LAYER2_GENEVE_OP) { in nfp_flower_compile_flow_match()
714 ext_len = (u32 *)ext - (u32 *)nfp_flow->unmasked_data; in nfp_flower_compile_flow_match()
718 return -EOPNOTSUPP; in nfp_flower_compile_flow_match()