Lines Matching +full:protocol +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0
22 * iavf_pkt_udp_no_pay_len - the length of UDP packet without payload
28 (fltr->ip_ver == 4 ? sizeof(struct iphdr) : sizeof(struct ipv6hdr)) + in iavf_pkt_udp_no_pay_len()
33 * iavf_fill_fdir_gtpu_hdr - fill the GTP-U protocol header
35 * @proto_hdrs: Flow Director protocol headers data structure
37 * Returns 0 if the GTP-U protocol header is set successfully
43 struct virtchnl_proto_hdr *uhdr = &proto_hdrs->proto_hdr[proto_hdrs->count - 1]; in iavf_fill_fdir_gtpu_hdr()
44 struct virtchnl_proto_hdr *ghdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_gtpu_hdr()
53 for (i = 0; i < fltr->flex_cnt; i++) { in iavf_fill_fdir_gtpu_hdr()
64 if (fltr->flex_words[i].offset < adj_offs) in iavf_fill_fdir_gtpu_hdr()
65 return -EINVAL; in iavf_fill_fdir_gtpu_hdr()
67 hdr_offs = fltr->flex_words[i].offset - adj_offs; in iavf_fill_fdir_gtpu_hdr()
72 __be16 *pay_word = (__be16 *)ghdr->buffer; in iavf_fill_fdir_gtpu_hdr()
74 pay_word[hdr_offs >> 1] = htons(fltr->flex_words[i].word); in iavf_fill_fdir_gtpu_hdr()
79 if ((fltr->flex_words[i].word & in iavf_fill_fdir_gtpu_hdr()
82 return -EOPNOTSUPP; in iavf_fill_fdir_gtpu_hdr()
84 ehdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_gtpu_hdr()
89 return -EINVAL; in iavf_fill_fdir_gtpu_hdr()
90 ehdr->buffer[IAVF_GTPU_EH_QFI_IDX] = in iavf_fill_fdir_gtpu_hdr()
91 fltr->flex_words[i].word & in iavf_fill_fdir_gtpu_hdr()
96 return -EINVAL; in iavf_fill_fdir_gtpu_hdr()
100 uhdr->field_selector = 0; /* The PF ignores the UDP header fields */ in iavf_fill_fdir_gtpu_hdr()
106 * iavf_fill_fdir_pfcp_hdr - fill the PFCP protocol header
108 * @proto_hdrs: Flow Director protocol headers data structure
110 * Returns 0 if the PFCP protocol header is set successfully
116 struct virtchnl_proto_hdr *uhdr = &proto_hdrs->proto_hdr[proto_hdrs->count - 1]; in iavf_fill_fdir_pfcp_hdr()
117 struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_pfcp_hdr()
125 for (i = 0; i < fltr->flex_cnt; i++) { in iavf_fill_fdir_pfcp_hdr()
127 if (fltr->flex_words[i].offset < adj_offs) in iavf_fill_fdir_pfcp_hdr()
128 return -EINVAL; in iavf_fill_fdir_pfcp_hdr()
130 hdr_offs = fltr->flex_words[i].offset - adj_offs; in iavf_fill_fdir_pfcp_hdr()
134 hdr->buffer[0] = (fltr->flex_words[i].word >> 8) & 0xff; in iavf_fill_fdir_pfcp_hdr()
138 return -EINVAL; in iavf_fill_fdir_pfcp_hdr()
142 uhdr->field_selector = 0; /* The PF ignores the UDP header fields */ in iavf_fill_fdir_pfcp_hdr()
148 * iavf_fill_fdir_nat_t_esp_hdr - fill the NAT-T-ESP protocol header
150 * @proto_hdrs: Flow Director protocol headers data structure
152 * Returns 0 if the NAT-T-ESP protocol header is set successfully
158 struct virtchnl_proto_hdr *uhdr = &proto_hdrs->proto_hdr[proto_hdrs->count - 1]; in iavf_fill_fdir_nat_t_esp_hdr()
159 struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_nat_t_esp_hdr()
168 for (i = 0; i < fltr->flex_cnt; i++) { in iavf_fill_fdir_nat_t_esp_hdr()
171 if (fltr->flex_words[i].offset < adj_offs) in iavf_fill_fdir_nat_t_esp_hdr()
172 return -EINVAL; in iavf_fill_fdir_nat_t_esp_hdr()
174 hdr_offs = fltr->flex_words[i].offset - adj_offs; in iavf_fill_fdir_nat_t_esp_hdr()
178 spi |= fltr->flex_words[i].word << 16; in iavf_fill_fdir_nat_t_esp_hdr()
181 spi |= fltr->flex_words[i].word; in iavf_fill_fdir_nat_t_esp_hdr()
184 return -EINVAL; in iavf_fill_fdir_nat_t_esp_hdr()
189 return -EOPNOTSUPP; /* Not support IKE Header Format with SPI 0 */ in iavf_fill_fdir_nat_t_esp_hdr()
191 *(__be32 *)hdr->buffer = htonl(spi); in iavf_fill_fdir_nat_t_esp_hdr()
194 uhdr->field_selector = 0; /* The PF ignores the UDP header fields */ in iavf_fill_fdir_nat_t_esp_hdr()
200 * iavf_fill_fdir_udp_flex_pay_hdr - fill the UDP payload header
202 * @proto_hdrs: Flow Director protocol headers data structure
204 * Returns 0 if the UDP payload defined protocol header is set successfully
212 switch (ntohs(fltr->ip_data.dst_port)) { in iavf_fill_fdir_udp_flex_pay_hdr()
223 err = -EOPNOTSUPP; in iavf_fill_fdir_udp_flex_pay_hdr()
231 * iavf_fill_fdir_ip4_hdr - fill the IPv4 protocol header
233 * @proto_hdrs: Flow Director protocol headers data structure
235 * Returns 0 if the IPv4 protocol header is set successfully
241 struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_ip4_hdr()
242 struct iphdr *iph = (struct iphdr *)hdr->buffer; in iavf_fill_fdir_ip4_hdr()
246 if (fltr->ip_mask.tos == U8_MAX) { in iavf_fill_fdir_ip4_hdr()
247 iph->tos = fltr->ip_data.tos; in iavf_fill_fdir_ip4_hdr()
251 if (fltr->ip_mask.proto == U8_MAX) { in iavf_fill_fdir_ip4_hdr()
252 iph->protocol = fltr->ip_data.proto; in iavf_fill_fdir_ip4_hdr()
256 if (fltr->ip_mask.v4_addrs.src_ip == htonl(U32_MAX)) { in iavf_fill_fdir_ip4_hdr()
257 iph->saddr = fltr->ip_data.v4_addrs.src_ip; in iavf_fill_fdir_ip4_hdr()
261 if (fltr->ip_mask.v4_addrs.dst_ip == htonl(U32_MAX)) { in iavf_fill_fdir_ip4_hdr()
262 iph->daddr = fltr->ip_data.v4_addrs.dst_ip; in iavf_fill_fdir_ip4_hdr()
266 fltr->ip_ver = 4; in iavf_fill_fdir_ip4_hdr()
272 * iavf_fill_fdir_ip6_hdr - fill the IPv6 protocol header
274 * @proto_hdrs: Flow Director protocol headers data structure
276 * Returns 0 if the IPv6 protocol header is set successfully
282 struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_ip6_hdr()
283 struct ipv6hdr *iph = (struct ipv6hdr *)hdr->buffer; in iavf_fill_fdir_ip6_hdr()
287 if (fltr->ip_mask.tclass == U8_MAX) { in iavf_fill_fdir_ip6_hdr()
288 iph->priority = (fltr->ip_data.tclass >> 4) & 0xF; in iavf_fill_fdir_ip6_hdr()
289 iph->flow_lbl[0] = (fltr->ip_data.tclass << 4) & 0xF0; in iavf_fill_fdir_ip6_hdr()
293 if (fltr->ip_mask.proto == U8_MAX) { in iavf_fill_fdir_ip6_hdr()
294 iph->nexthdr = fltr->ip_data.proto; in iavf_fill_fdir_ip6_hdr()
298 if (!memcmp(&fltr->ip_mask.v6_addrs.src_ip, &ipv6_addr_full_mask, in iavf_fill_fdir_ip6_hdr()
300 memcpy(&iph->saddr, &fltr->ip_data.v6_addrs.src_ip, in iavf_fill_fdir_ip6_hdr()
305 if (!memcmp(&fltr->ip_mask.v6_addrs.dst_ip, &ipv6_addr_full_mask, in iavf_fill_fdir_ip6_hdr()
307 memcpy(&iph->daddr, &fltr->ip_data.v6_addrs.dst_ip, in iavf_fill_fdir_ip6_hdr()
312 fltr->ip_ver = 6; in iavf_fill_fdir_ip6_hdr()
318 * iavf_fill_fdir_tcp_hdr - fill the TCP protocol header
320 * @proto_hdrs: Flow Director protocol headers data structure
322 * Returns 0 if the TCP protocol header is set successfully
328 struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_tcp_hdr()
329 struct tcphdr *tcph = (struct tcphdr *)hdr->buffer; in iavf_fill_fdir_tcp_hdr()
333 if (fltr->ip_mask.src_port == htons(U16_MAX)) { in iavf_fill_fdir_tcp_hdr()
334 tcph->source = fltr->ip_data.src_port; in iavf_fill_fdir_tcp_hdr()
338 if (fltr->ip_mask.dst_port == htons(U16_MAX)) { in iavf_fill_fdir_tcp_hdr()
339 tcph->dest = fltr->ip_data.dst_port; in iavf_fill_fdir_tcp_hdr()
347 * iavf_fill_fdir_udp_hdr - fill the UDP protocol header
349 * @proto_hdrs: Flow Director protocol headers data structure
351 * Returns 0 if the UDP protocol header is set successfully
357 struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_udp_hdr()
358 struct udphdr *udph = (struct udphdr *)hdr->buffer; in iavf_fill_fdir_udp_hdr()
362 if (fltr->ip_mask.src_port == htons(U16_MAX)) { in iavf_fill_fdir_udp_hdr()
363 udph->source = fltr->ip_data.src_port; in iavf_fill_fdir_udp_hdr()
367 if (fltr->ip_mask.dst_port == htons(U16_MAX)) { in iavf_fill_fdir_udp_hdr()
368 udph->dest = fltr->ip_data.dst_port; in iavf_fill_fdir_udp_hdr()
372 if (!fltr->flex_cnt) in iavf_fill_fdir_udp_hdr()
379 * iavf_fill_fdir_sctp_hdr - fill the SCTP protocol header
381 * @proto_hdrs: Flow Director protocol headers data structure
383 * Returns 0 if the SCTP protocol header is set successfully
389 struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_sctp_hdr()
390 struct sctphdr *sctph = (struct sctphdr *)hdr->buffer; in iavf_fill_fdir_sctp_hdr()
394 if (fltr->ip_mask.src_port == htons(U16_MAX)) { in iavf_fill_fdir_sctp_hdr()
395 sctph->source = fltr->ip_data.src_port; in iavf_fill_fdir_sctp_hdr()
399 if (fltr->ip_mask.dst_port == htons(U16_MAX)) { in iavf_fill_fdir_sctp_hdr()
400 sctph->dest = fltr->ip_data.dst_port; in iavf_fill_fdir_sctp_hdr()
408 * iavf_fill_fdir_ah_hdr - fill the AH protocol header
410 * @proto_hdrs: Flow Director protocol headers data structure
412 * Returns 0 if the AH protocol header is set successfully
418 struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_ah_hdr()
419 struct ip_auth_hdr *ah = (struct ip_auth_hdr *)hdr->buffer; in iavf_fill_fdir_ah_hdr()
423 if (fltr->ip_mask.spi == htonl(U32_MAX)) { in iavf_fill_fdir_ah_hdr()
424 ah->spi = fltr->ip_data.spi; in iavf_fill_fdir_ah_hdr()
432 * iavf_fill_fdir_esp_hdr - fill the ESP protocol header
434 * @proto_hdrs: Flow Director protocol headers data structure
436 * Returns 0 if the ESP protocol header is set successfully
442 struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_esp_hdr()
443 struct ip_esp_hdr *esph = (struct ip_esp_hdr *)hdr->buffer; in iavf_fill_fdir_esp_hdr()
447 if (fltr->ip_mask.spi == htonl(U32_MAX)) { in iavf_fill_fdir_esp_hdr()
448 esph->spi = fltr->ip_data.spi; in iavf_fill_fdir_esp_hdr()
456 * iavf_fill_fdir_l4_hdr - fill the L4 protocol header
458 * @proto_hdrs: Flow Director protocol headers data structure
460 * Returns 0 if the L4 protocol header is set successfully
469 if (!fltr->ip_mask.proto) /* IPv4/IPv6 header only */ in iavf_fill_fdir_l4_hdr()
472 hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_l4_hdr()
473 l4_4_data = (__be32 *)hdr->buffer; in iavf_fill_fdir_l4_hdr()
475 /* L2TPv3 over IP with 'Session ID' */ in iavf_fill_fdir_l4_hdr()
476 if (fltr->ip_data.proto == 115 && fltr->ip_mask.l4_header == htonl(U32_MAX)) { in iavf_fill_fdir_l4_hdr()
480 *l4_4_data = fltr->ip_data.l4_header; in iavf_fill_fdir_l4_hdr()
482 return -EOPNOTSUPP; in iavf_fill_fdir_l4_hdr()
489 * iavf_fill_fdir_eth_hdr - fill the Ethernet protocol header
491 * @proto_hdrs: Flow Director protocol headers data structure
493 * Returns 0 if the Ethernet protocol header is set successfully
499 struct virtchnl_proto_hdr *hdr = &proto_hdrs->proto_hdr[proto_hdrs->count++]; in iavf_fill_fdir_eth_hdr()
500 struct ethhdr *ehdr = (struct ethhdr *)hdr->buffer; in iavf_fill_fdir_eth_hdr()
504 if (fltr->eth_mask.etype == htons(U16_MAX)) { in iavf_fill_fdir_eth_hdr()
505 if (fltr->eth_data.etype == htons(ETH_P_IP) || in iavf_fill_fdir_eth_hdr()
506 fltr->eth_data.etype == htons(ETH_P_IPV6)) in iavf_fill_fdir_eth_hdr()
507 return -EOPNOTSUPP; in iavf_fill_fdir_eth_hdr()
509 ehdr->h_proto = fltr->eth_data.etype; in iavf_fill_fdir_eth_hdr()
517 * iavf_fill_fdir_add_msg - fill the Flow Director filter into virtchnl message
525 struct virtchnl_fdir_add *vc_msg = &fltr->vc_add_msg; in iavf_fill_fdir_add_msg()
529 proto_hdrs = &vc_msg->rule_cfg.proto_hdrs; in iavf_fill_fdir_add_msg()
535 switch (fltr->flow_type) { in iavf_fill_fdir_add_msg()
587 err = -EINVAL; in iavf_fill_fdir_add_msg()
594 vc_msg->vsi_id = adapter->vsi.id; in iavf_fill_fdir_add_msg()
595 vc_msg->rule_cfg.action_set.count = 1; in iavf_fill_fdir_add_msg()
596 vc_msg->rule_cfg.action_set.actions[0].type = fltr->action; in iavf_fill_fdir_add_msg()
597 vc_msg->rule_cfg.action_set.actions[0].act_conf.queue.index = fltr->q_index; in iavf_fill_fdir_add_msg()
603 * iavf_fdir_flow_proto_name - get the flow protocol name
643 const char *proto = iavf_fdir_flow_proto_name(fltr->flow_type); in iavf_print_fdir_fltr()
648 switch (fltr->flow_type) { in iavf_print_fdir_fltr()
652 …dev_info(&adapter->pdev->dev, "Rule ID: %u dst_ip: %pI4 src_ip %pI4 %s: dst_port %hu src_port %hu\… in iavf_print_fdir_fltr()
653 fltr->loc, in iavf_print_fdir_fltr()
654 &fltr->ip_data.v4_addrs.dst_ip, in iavf_print_fdir_fltr()
655 &fltr->ip_data.v4_addrs.src_ip, in iavf_print_fdir_fltr()
657 ntohs(fltr->ip_data.dst_port), in iavf_print_fdir_fltr()
658 ntohs(fltr->ip_data.src_port)); in iavf_print_fdir_fltr()
662 dev_info(&adapter->pdev->dev, "Rule ID: %u dst_ip: %pI4 src_ip %pI4 %s: SPI %u\n", in iavf_print_fdir_fltr()
663 fltr->loc, in iavf_print_fdir_fltr()
664 &fltr->ip_data.v4_addrs.dst_ip, in iavf_print_fdir_fltr()
665 &fltr->ip_data.v4_addrs.src_ip, in iavf_print_fdir_fltr()
667 ntohl(fltr->ip_data.spi)); in iavf_print_fdir_fltr()
670 dev_info(&adapter->pdev->dev, "Rule ID: %u dst_ip: %pI4 src_ip %pI4 proto: %u L4_bytes: 0x%x\n", in iavf_print_fdir_fltr()
671 fltr->loc, in iavf_print_fdir_fltr()
672 &fltr->ip_data.v4_addrs.dst_ip, in iavf_print_fdir_fltr()
673 &fltr->ip_data.v4_addrs.src_ip, in iavf_print_fdir_fltr()
674 fltr->ip_data.proto, in iavf_print_fdir_fltr()
675 ntohl(fltr->ip_data.l4_header)); in iavf_print_fdir_fltr()
680 …dev_info(&adapter->pdev->dev, "Rule ID: %u dst_ip: %pI6 src_ip %pI6 %s: dst_port %hu src_port %hu\… in iavf_print_fdir_fltr()
681 fltr->loc, in iavf_print_fdir_fltr()
682 &fltr->ip_data.v6_addrs.dst_ip, in iavf_print_fdir_fltr()
683 &fltr->ip_data.v6_addrs.src_ip, in iavf_print_fdir_fltr()
685 ntohs(fltr->ip_data.dst_port), in iavf_print_fdir_fltr()
686 ntohs(fltr->ip_data.src_port)); in iavf_print_fdir_fltr()
690 dev_info(&adapter->pdev->dev, "Rule ID: %u dst_ip: %pI6 src_ip %pI6 %s: SPI %u\n", in iavf_print_fdir_fltr()
691 fltr->loc, in iavf_print_fdir_fltr()
692 &fltr->ip_data.v6_addrs.dst_ip, in iavf_print_fdir_fltr()
693 &fltr->ip_data.v6_addrs.src_ip, in iavf_print_fdir_fltr()
695 ntohl(fltr->ip_data.spi)); in iavf_print_fdir_fltr()
698 dev_info(&adapter->pdev->dev, "Rule ID: %u dst_ip: %pI6 src_ip %pI6 proto: %u L4_bytes: 0x%x\n", in iavf_print_fdir_fltr()
699 fltr->loc, in iavf_print_fdir_fltr()
700 &fltr->ip_data.v6_addrs.dst_ip, in iavf_print_fdir_fltr()
701 &fltr->ip_data.v6_addrs.src_ip, in iavf_print_fdir_fltr()
702 fltr->ip_data.proto, in iavf_print_fdir_fltr()
703 ntohl(fltr->ip_data.l4_header)); in iavf_print_fdir_fltr()
706 dev_info(&adapter->pdev->dev, "Rule ID: %u eth_type: 0x%x\n", in iavf_print_fdir_fltr()
707 fltr->loc, in iavf_print_fdir_fltr()
708 ntohs(fltr->eth_data.etype)); in iavf_print_fdir_fltr()
716 * iavf_fdir_is_dup_fltr - test if filter is already in list
726 list_for_each_entry(tmp, &adapter->fdir_list_head, list) { in iavf_fdir_is_dup_fltr()
727 if (tmp->flow_type != fltr->flow_type) in iavf_fdir_is_dup_fltr()
730 if (!memcmp(&tmp->eth_data, &fltr->eth_data, in iavf_fdir_is_dup_fltr()
731 sizeof(fltr->eth_data)) && in iavf_fdir_is_dup_fltr()
732 !memcmp(&tmp->ip_data, &fltr->ip_data, in iavf_fdir_is_dup_fltr()
733 sizeof(fltr->ip_data)) && in iavf_fdir_is_dup_fltr()
734 !memcmp(&tmp->ext_data, &fltr->ext_data, in iavf_fdir_is_dup_fltr()
735 sizeof(fltr->ext_data))) in iavf_fdir_is_dup_fltr()
743 * iavf_find_fdir_fltr_by_loc - find filter with location
753 list_for_each_entry(rule, &adapter->fdir_list_head, list) in iavf_find_fdir_fltr_by_loc()
754 if (rule->loc == loc) in iavf_find_fdir_fltr_by_loc()
761 * iavf_fdir_list_add_fltr - add a new node to the flow director filter list
769 list_for_each_entry(rule, &adapter->fdir_list_head, list) { in iavf_fdir_list_add_fltr()
770 if (rule->loc >= fltr->loc) in iavf_fdir_list_add_fltr()
776 list_add(&fltr->list, &parent->list); in iavf_fdir_list_add_fltr()
778 list_add(&fltr->list, &adapter->fdir_list_head); in iavf_fdir_list_add_fltr()