Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/nex t-queue

Tony Nguyen says:

====================
100GbE Intel Wired LAN Driver Updates 2022-06-30

This series contains updates to ice driver only.

Martyna adds support for VLAN related TC switchdev filters and reworks
dummy packet implementation of VLANs to enable dynamic header insertion to
allow for more rule types.

Lu Wei utilizes eth_broadcast_addr() helper over an open coded version.

Ziyang Xuan removes unneeded NULL checks.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+283 -189
+2 -4
drivers/net/ethernet/intel/ice/ice_lag.c
··· 447 447 if (lag->pf) 448 448 ice_unregister_lag_handler(lag); 449 449 450 - if (lag->upper_netdev) 451 - dev_put(lag->upper_netdev); 450 + dev_put(lag->upper_netdev); 452 451 453 - if (lag->peer_netdev) 454 - dev_put(lag->peer_netdev); 452 + dev_put(lag->peer_netdev); 455 453 456 454 kfree(lag); 457 455
+8 -1
drivers/net/ethernet/intel/ice/ice_protocol_type.h
··· 43 43 ICE_NVGRE, 44 44 ICE_GTP, 45 45 ICE_GTP_NO_PAY, 46 + ICE_VLAN_EX, 47 + ICE_VLAN_IN, 46 48 ICE_VXLAN_GPE, 47 49 ICE_SCTP_IL, 48 50 ICE_PROTOCOL_LAST ··· 111 109 #define ICE_GRE_OF_HW 64 112 110 113 111 #define ICE_UDP_OF_HW 52 /* UDP Tunnels */ 114 - #define ICE_META_DATA_ID_HW 255 /* this is used for tunnel type */ 112 + #define ICE_META_DATA_ID_HW 255 /* this is used for tunnel and VLAN type */ 115 113 116 114 #define ICE_MDID_SIZE 2 115 + 117 116 #define ICE_TUN_FLAG_MDID 21 118 117 #define ICE_TUN_FLAG_MDID_OFF (ICE_MDID_SIZE * ICE_TUN_FLAG_MDID) 119 118 #define ICE_TUN_FLAG_MASK 0xFF 119 + 120 + #define ICE_VLAN_FLAG_MDID 20 121 + #define ICE_VLAN_FLAG_MDID_OFF (ICE_MDID_SIZE * ICE_VLAN_FLAG_MDID) 122 + #define ICE_PKT_FLAGS_0_TO_15_VLAN_FLAGS_MASK 0xD000 120 123 121 124 #define ICE_TUN_FLAG_FV_IND 2 122 125
+205 -181
drivers/net/ethernet/intel/ice/ice_switch.c
··· 31 31 0x81, 0, 0, 0}; 32 32 33 33 enum { 34 - ICE_PKT_VLAN = BIT(0), 35 - ICE_PKT_OUTER_IPV6 = BIT(1), 36 - ICE_PKT_TUN_GTPC = BIT(2), 37 - ICE_PKT_TUN_GTPU = BIT(3), 38 - ICE_PKT_TUN_NVGRE = BIT(4), 39 - ICE_PKT_TUN_UDP = BIT(5), 40 - ICE_PKT_INNER_IPV6 = BIT(6), 41 - ICE_PKT_INNER_TCP = BIT(7), 42 - ICE_PKT_INNER_UDP = BIT(8), 43 - ICE_PKT_GTP_NOPAY = BIT(9), 34 + ICE_PKT_OUTER_IPV6 = BIT(0), 35 + ICE_PKT_TUN_GTPC = BIT(1), 36 + ICE_PKT_TUN_GTPU = BIT(2), 37 + ICE_PKT_TUN_NVGRE = BIT(3), 38 + ICE_PKT_TUN_UDP = BIT(4), 39 + ICE_PKT_INNER_IPV6 = BIT(5), 40 + ICE_PKT_INNER_TCP = BIT(6), 41 + ICE_PKT_INNER_UDP = BIT(7), 42 + ICE_PKT_GTP_NOPAY = BIT(8), 43 + ICE_PKT_KMALLOC = BIT(9), 44 44 }; 45 45 46 46 struct ice_dummy_pkt_offsets { ··· 53 53 const u8 *pkt; 54 54 u32 match; 55 55 u16 pkt_len; 56 + u16 offsets_len; 56 57 }; 57 58 58 - #define ICE_DECLARE_PKT_OFFSETS(type) \ 59 - static const struct ice_dummy_pkt_offsets \ 59 + #define ICE_DECLARE_PKT_OFFSETS(type) \ 60 + static const struct ice_dummy_pkt_offsets \ 60 61 ice_dummy_##type##_packet_offsets[] 61 62 62 - #define ICE_DECLARE_PKT_TEMPLATE(type) \ 63 + #define ICE_DECLARE_PKT_TEMPLATE(type) \ 63 64 static const u8 ice_dummy_##type##_packet[] 64 65 65 - #define ICE_PKT_PROFILE(type, m) { \ 66 - .match = (m), \ 67 - .pkt = ice_dummy_##type##_packet, \ 68 - .pkt_len = sizeof(ice_dummy_##type##_packet), \ 69 - .offsets = ice_dummy_##type##_packet_offsets, \ 66 + #define ICE_PKT_PROFILE(type, m) { \ 67 + .match = (m), \ 68 + .pkt = ice_dummy_##type##_packet, \ 69 + .pkt_len = sizeof(ice_dummy_##type##_packet), \ 70 + .offsets = ice_dummy_##type##_packet_offsets, \ 71 + .offsets_len = sizeof(ice_dummy_##type##_packet_offsets), \ 70 72 } 73 + 74 + ICE_DECLARE_PKT_OFFSETS(vlan) = { 75 + { ICE_VLAN_OFOS, 12 }, 76 + }; 77 + 78 + ICE_DECLARE_PKT_TEMPLATE(vlan) = { 79 + 0x81, 0x00, 0x00, 0x00, /* ICE_VLAN_OFOS 12 */ 80 + }; 81 + 82 + ICE_DECLARE_PKT_OFFSETS(qinq) = { 83 + { ICE_VLAN_EX, 12 }, 84 + { ICE_VLAN_IN, 16 }, 85 + }; 86 + 87 + ICE_DECLARE_PKT_TEMPLATE(qinq) = { 88 + 0x91, 0x00, 0x00, 0x00, /* ICE_VLAN_EX 12 */ 89 + 0x81, 0x00, 0x00, 0x00, /* ICE_VLAN_IN 16 */ 90 + }; 71 91 72 92 ICE_DECLARE_PKT_OFFSETS(gre_tcp) = { 73 93 { ICE_MAC_OFOS, 0 }, ··· 526 506 0x00, 0x00, /* 2 bytes for 4 byte alignment */ 527 507 }; 528 508 529 - /* offset info for MAC + VLAN + IPv4 + UDP dummy packet */ 530 - ICE_DECLARE_PKT_OFFSETS(vlan_udp) = { 531 - { ICE_MAC_OFOS, 0 }, 532 - { ICE_VLAN_OFOS, 12 }, 533 - { ICE_ETYPE_OL, 16 }, 534 - { ICE_IPV4_OFOS, 18 }, 535 - { ICE_UDP_ILOS, 38 }, 536 - { ICE_PROTOCOL_LAST, 0 }, 537 - }; 538 - 539 - /* C-tag (801.1Q), IPv4:UDP dummy packet */ 540 - ICE_DECLARE_PKT_TEMPLATE(vlan_udp) = { 541 - 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 542 - 0x00, 0x00, 0x00, 0x00, 543 - 0x00, 0x00, 0x00, 0x00, 544 - 545 - 0x81, 0x00, 0x00, 0x00, /* ICE_VLAN_OFOS 12 */ 546 - 547 - 0x08, 0x00, /* ICE_ETYPE_OL 16 */ 548 - 549 - 0x45, 0x00, 0x00, 0x1c, /* ICE_IPV4_OFOS 18 */ 550 - 0x00, 0x01, 0x00, 0x00, 551 - 0x00, 0x11, 0x00, 0x00, 552 - 0x00, 0x00, 0x00, 0x00, 553 - 0x00, 0x00, 0x00, 0x00, 554 - 555 - 0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 38 */ 556 - 0x00, 0x08, 0x00, 0x00, 557 - 558 - 0x00, 0x00, /* 2 bytes for 4 byte alignment */ 559 - }; 560 - 561 509 /* offset info for MAC + IPv4 + TCP dummy packet */ 562 510 ICE_DECLARE_PKT_OFFSETS(tcp) = { 563 511 { ICE_MAC_OFOS, 0 }, ··· 550 562 0x00, 0x00, 0x00, 0x00, 551 563 552 564 0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 34 */ 553 - 0x00, 0x00, 0x00, 0x00, 554 - 0x00, 0x00, 0x00, 0x00, 555 - 0x50, 0x00, 0x00, 0x00, 556 - 0x00, 0x00, 0x00, 0x00, 557 - 558 - 0x00, 0x00, /* 2 bytes for 4 byte alignment */ 559 - }; 560 - 561 - /* offset info for MAC + VLAN (C-tag, 802.1Q) + IPv4 + TCP dummy packet */ 562 - ICE_DECLARE_PKT_OFFSETS(vlan_tcp) = { 563 - { ICE_MAC_OFOS, 0 }, 564 - { ICE_VLAN_OFOS, 12 }, 565 - { ICE_ETYPE_OL, 16 }, 566 - { ICE_IPV4_OFOS, 18 }, 567 - { ICE_TCP_IL, 38 }, 568 - { ICE_PROTOCOL_LAST, 0 }, 569 - }; 570 - 571 - /* C-tag (801.1Q), IPv4:TCP dummy packet */ 572 - ICE_DECLARE_PKT_TEMPLATE(vlan_tcp) = { 573 - 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 574 - 0x00, 0x00, 0x00, 0x00, 575 - 0x00, 0x00, 0x00, 0x00, 576 - 577 - 0x81, 0x00, 0x00, 0x00, /* ICE_VLAN_OFOS 12 */ 578 - 579 - 0x08, 0x00, /* ICE_ETYPE_OL 16 */ 580 - 581 - 0x45, 0x00, 0x00, 0x28, /* ICE_IPV4_OFOS 18 */ 582 - 0x00, 0x01, 0x00, 0x00, 583 - 0x00, 0x06, 0x00, 0x00, 584 - 0x00, 0x00, 0x00, 0x00, 585 - 0x00, 0x00, 0x00, 0x00, 586 - 587 - 0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 38 */ 588 565 0x00, 0x00, 0x00, 0x00, 589 566 0x00, 0x00, 0x00, 0x00, 590 567 0x50, 0x00, 0x00, 0x00, ··· 593 640 0x00, 0x00, /* 2 bytes for 4 byte alignment */ 594 641 }; 595 642 596 - /* C-tag (802.1Q): IPv6 + TCP */ 597 - ICE_DECLARE_PKT_OFFSETS(vlan_tcp_ipv6) = { 598 - { ICE_MAC_OFOS, 0 }, 599 - { ICE_VLAN_OFOS, 12 }, 600 - { ICE_ETYPE_OL, 16 }, 601 - { ICE_IPV6_OFOS, 18 }, 602 - { ICE_TCP_IL, 58 }, 603 - { ICE_PROTOCOL_LAST, 0 }, 604 - }; 605 - 606 - /* C-tag (802.1Q), IPv6 + TCP dummy packet */ 607 - ICE_DECLARE_PKT_TEMPLATE(vlan_tcp_ipv6) = { 608 - 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 609 - 0x00, 0x00, 0x00, 0x00, 610 - 0x00, 0x00, 0x00, 0x00, 611 - 612 - 0x81, 0x00, 0x00, 0x00, /* ICE_VLAN_OFOS 12 */ 613 - 614 - 0x86, 0xDD, /* ICE_ETYPE_OL 16 */ 615 - 616 - 0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 18 */ 617 - 0x00, 0x14, 0x06, 0x00, /* Next header is TCP */ 618 - 0x00, 0x00, 0x00, 0x00, 619 - 0x00, 0x00, 0x00, 0x00, 620 - 0x00, 0x00, 0x00, 0x00, 621 - 0x00, 0x00, 0x00, 0x00, 622 - 0x00, 0x00, 0x00, 0x00, 623 - 0x00, 0x00, 0x00, 0x00, 624 - 0x00, 0x00, 0x00, 0x00, 625 - 0x00, 0x00, 0x00, 0x00, 626 - 627 - 0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 58 */ 628 - 0x00, 0x00, 0x00, 0x00, 629 - 0x00, 0x00, 0x00, 0x00, 630 - 0x50, 0x00, 0x00, 0x00, 631 - 0x00, 0x00, 0x00, 0x00, 632 - 633 - 0x00, 0x00, /* 2 bytes for 4 byte alignment */ 634 - }; 635 - 636 643 /* IPv6 + UDP */ 637 644 ICE_DECLARE_PKT_OFFSETS(udp_ipv6) = { 638 645 { ICE_MAC_OFOS, 0 }, ··· 626 713 627 714 0x00, 0x00, 0x00, 0x00, /* needed for ESP packets */ 628 715 0x00, 0x00, 0x00, 0x00, 629 - 630 - 0x00, 0x00, /* 2 bytes for 4 byte alignment */ 631 - }; 632 - 633 - /* C-tag (802.1Q): IPv6 + UDP */ 634 - ICE_DECLARE_PKT_OFFSETS(vlan_udp_ipv6) = { 635 - { ICE_MAC_OFOS, 0 }, 636 - { ICE_VLAN_OFOS, 12 }, 637 - { ICE_ETYPE_OL, 16 }, 638 - { ICE_IPV6_OFOS, 18 }, 639 - { ICE_UDP_ILOS, 58 }, 640 - { ICE_PROTOCOL_LAST, 0 }, 641 - }; 642 - 643 - /* C-tag (802.1Q), IPv6 + UDP dummy packet */ 644 - ICE_DECLARE_PKT_TEMPLATE(vlan_udp_ipv6) = { 645 - 0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */ 646 - 0x00, 0x00, 0x00, 0x00, 647 - 0x00, 0x00, 0x00, 0x00, 648 - 649 - 0x81, 0x00, 0x00, 0x00,/* ICE_VLAN_OFOS 12 */ 650 - 651 - 0x86, 0xDD, /* ICE_ETYPE_OL 16 */ 652 - 653 - 0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 18 */ 654 - 0x00, 0x08, 0x11, 0x00, /* Next header UDP */ 655 - 0x00, 0x00, 0x00, 0x00, 656 - 0x00, 0x00, 0x00, 0x00, 657 - 0x00, 0x00, 0x00, 0x00, 658 - 0x00, 0x00, 0x00, 0x00, 659 - 0x00, 0x00, 0x00, 0x00, 660 - 0x00, 0x00, 0x00, 0x00, 661 - 0x00, 0x00, 0x00, 0x00, 662 - 0x00, 0x00, 0x00, 0x00, 663 - 664 - 0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 58 */ 665 - 0x00, 0x08, 0x00, 0x00, 666 716 667 717 0x00, 0x00, /* 2 bytes for 4 byte alignment */ 668 718 }; ··· 1147 1271 ICE_PKT_PROFILE(udp_tun_ipv6_udp, ICE_PKT_TUN_UDP | 1148 1272 ICE_PKT_INNER_IPV6), 1149 1273 ICE_PKT_PROFILE(udp_tun_udp, ICE_PKT_TUN_UDP), 1150 - ICE_PKT_PROFILE(vlan_udp_ipv6, ICE_PKT_OUTER_IPV6 | ICE_PKT_INNER_UDP | 1151 - ICE_PKT_VLAN), 1152 1274 ICE_PKT_PROFILE(udp_ipv6, ICE_PKT_OUTER_IPV6 | ICE_PKT_INNER_UDP), 1153 - ICE_PKT_PROFILE(vlan_udp, ICE_PKT_INNER_UDP | ICE_PKT_VLAN), 1154 1275 ICE_PKT_PROFILE(udp, ICE_PKT_INNER_UDP), 1155 - ICE_PKT_PROFILE(vlan_tcp_ipv6, ICE_PKT_OUTER_IPV6 | ICE_PKT_VLAN), 1156 1276 ICE_PKT_PROFILE(tcp_ipv6, ICE_PKT_OUTER_IPV6), 1157 - ICE_PKT_PROFILE(vlan_tcp, ICE_PKT_VLAN), 1158 1277 ICE_PKT_PROFILE(tcp, 0), 1159 1278 }; 1160 1279 ··· 4480 4609 { ICE_NVGRE, { 0, 2, 4, 6 } }, 4481 4610 { ICE_GTP, { 8, 10, 12, 14, 16, 18, 20, 22 } }, 4482 4611 { ICE_GTP_NO_PAY, { 8, 10, 12, 14 } }, 4612 + { ICE_VLAN_EX, { 2, 0 } }, 4613 + { ICE_VLAN_IN, { 2, 0 } }, 4483 4614 }; 4484 4615 4485 4616 static struct ice_protocol_entry ice_prot_id_tbl[ICE_PROTOCOL_LAST] = { ··· 4502 4629 { ICE_NVGRE, ICE_GRE_OF_HW }, 4503 4630 { ICE_GTP, ICE_UDP_OF_HW }, 4504 4631 { ICE_GTP_NO_PAY, ICE_UDP_ILOS_HW }, 4632 + { ICE_VLAN_EX, ICE_VLAN_OF_HW }, 4633 + { ICE_VLAN_IN, ICE_VLAN_OL_HW }, 4505 4634 }; 4506 4635 4507 4636 /** ··· 5188 5313 * ice_add_special_words - Add words that are not protocols, such as metadata 5189 5314 * @rinfo: other information regarding the rule e.g. priority and action info 5190 5315 * @lkup_exts: lookup word structure 5316 + * @dvm_ena: is double VLAN mode enabled 5191 5317 */ 5192 5318 static int 5193 5319 ice_add_special_words(struct ice_adv_rule_info *rinfo, 5194 - struct ice_prot_lkup_ext *lkup_exts) 5320 + struct ice_prot_lkup_ext *lkup_exts, bool dvm_ena) 5195 5321 { 5196 5322 u16 mask; 5197 5323 ··· 5206 5330 lkup_exts->fv_words[word].prot_id = ICE_META_DATA_ID_HW; 5207 5331 lkup_exts->fv_words[word].off = ICE_TUN_FLAG_MDID_OFF; 5208 5332 lkup_exts->field_mask[word] = mask; 5333 + } else { 5334 + return -ENOSPC; 5335 + } 5336 + } 5337 + 5338 + if (rinfo->vlan_type != 0 && dvm_ena) { 5339 + if (lkup_exts->n_val_words < ICE_MAX_CHAIN_WORDS) { 5340 + u8 word = lkup_exts->n_val_words++; 5341 + 5342 + lkup_exts->fv_words[word].prot_id = ICE_META_DATA_ID_HW; 5343 + lkup_exts->fv_words[word].off = ICE_VLAN_FLAG_MDID_OFF; 5344 + lkup_exts->field_mask[word] = 5345 + ICE_PKT_FLAGS_0_TO_15_VLAN_FLAGS_MASK; 5209 5346 } else { 5210 5347 return -ENOSPC; 5211 5348 } ··· 5343 5454 /* Create any special protocol/offset pairs, such as looking at tunnel 5344 5455 * bits by extracting metadata 5345 5456 */ 5346 - status = ice_add_special_words(rinfo, lkup_exts); 5457 + status = ice_add_special_words(rinfo, lkup_exts, ice_is_dvm_ena(hw)); 5347 5458 if (status) 5348 5459 goto err_free_lkup_exts; 5349 5460 ··· 5444 5555 } 5445 5556 5446 5557 /** 5558 + * ice_dummy_packet_add_vlan - insert VLAN header to dummy pkt 5559 + * 5560 + * @dummy_pkt: dummy packet profile pattern to which VLAN tag(s) will be added 5561 + * @num_vlan: number of VLAN tags 5562 + */ 5563 + static struct ice_dummy_pkt_profile * 5564 + ice_dummy_packet_add_vlan(const struct ice_dummy_pkt_profile *dummy_pkt, 5565 + u32 num_vlan) 5566 + { 5567 + struct ice_dummy_pkt_profile *profile; 5568 + struct ice_dummy_pkt_offsets *offsets; 5569 + u32 buf_len, off, etype_off, i; 5570 + u8 *pkt; 5571 + 5572 + if (num_vlan < 1 || num_vlan > 2) 5573 + return ERR_PTR(-EINVAL); 5574 + 5575 + off = num_vlan * VLAN_HLEN; 5576 + 5577 + buf_len = array_size(num_vlan, sizeof(ice_dummy_vlan_packet_offsets)) + 5578 + dummy_pkt->offsets_len; 5579 + offsets = kzalloc(buf_len, GFP_KERNEL); 5580 + if (!offsets) 5581 + return ERR_PTR(-ENOMEM); 5582 + 5583 + offsets[0] = dummy_pkt->offsets[0]; 5584 + if (num_vlan == 2) { 5585 + offsets[1] = ice_dummy_qinq_packet_offsets[0]; 5586 + offsets[2] = ice_dummy_qinq_packet_offsets[1]; 5587 + } else if (num_vlan == 1) { 5588 + offsets[1] = ice_dummy_vlan_packet_offsets[0]; 5589 + } 5590 + 5591 + for (i = 1; dummy_pkt->offsets[i].type != ICE_PROTOCOL_LAST; i++) { 5592 + offsets[i + num_vlan].type = dummy_pkt->offsets[i].type; 5593 + offsets[i + num_vlan].offset = 5594 + dummy_pkt->offsets[i].offset + off; 5595 + } 5596 + offsets[i + num_vlan] = dummy_pkt->offsets[i]; 5597 + 5598 + etype_off = dummy_pkt->offsets[1].offset; 5599 + 5600 + buf_len = array_size(num_vlan, sizeof(ice_dummy_vlan_packet)) + 5601 + dummy_pkt->pkt_len; 5602 + pkt = kzalloc(buf_len, GFP_KERNEL); 5603 + if (!pkt) { 5604 + kfree(offsets); 5605 + return ERR_PTR(-ENOMEM); 5606 + } 5607 + 5608 + memcpy(pkt, dummy_pkt->pkt, etype_off); 5609 + memcpy(pkt + etype_off, 5610 + num_vlan == 2 ? ice_dummy_qinq_packet : ice_dummy_vlan_packet, 5611 + off); 5612 + memcpy(pkt + etype_off + off, dummy_pkt->pkt + etype_off, 5613 + dummy_pkt->pkt_len - etype_off); 5614 + 5615 + profile = kzalloc(sizeof(*profile), GFP_KERNEL); 5616 + if (!profile) { 5617 + kfree(offsets); 5618 + kfree(pkt); 5619 + return ERR_PTR(-ENOMEM); 5620 + } 5621 + 5622 + profile->offsets = offsets; 5623 + profile->pkt = pkt; 5624 + profile->pkt_len = buf_len; 5625 + profile->match |= ICE_PKT_KMALLOC; 5626 + 5627 + return profile; 5628 + } 5629 + 5630 + /** 5447 5631 * ice_find_dummy_packet - find dummy packet 5448 5632 * 5449 5633 * @lkups: lookup elements or match criteria for the advanced recipe, one ··· 5531 5569 enum ice_sw_tunnel_type tun_type) 5532 5570 { 5533 5571 const struct ice_dummy_pkt_profile *ret = ice_dummy_pkt_profiles; 5534 - u32 match = 0; 5572 + u32 match = 0, vlan_count = 0; 5535 5573 u16 i; 5536 5574 5537 5575 switch (tun_type) { ··· 5559 5597 match |= ICE_PKT_INNER_TCP; 5560 5598 else if (lkups[i].type == ICE_IPV6_OFOS) 5561 5599 match |= ICE_PKT_OUTER_IPV6; 5562 - else if (lkups[i].type == ICE_VLAN_OFOS) 5563 - match |= ICE_PKT_VLAN; 5600 + else if (lkups[i].type == ICE_VLAN_OFOS || 5601 + lkups[i].type == ICE_VLAN_EX) 5602 + vlan_count++; 5603 + else if (lkups[i].type == ICE_VLAN_IN) 5604 + vlan_count++; 5564 5605 else if (lkups[i].type == ICE_ETYPE_OL && 5565 5606 lkups[i].h_u.ethertype.ethtype_id == 5566 5607 cpu_to_be16(ICE_IPV6_ETHER_ID) && ··· 5584 5619 5585 5620 while (ret->match && (match & ret->match) != ret->match) 5586 5621 ret++; 5622 + 5623 + if (vlan_count != 0) 5624 + ret = ice_dummy_packet_add_vlan(ret, vlan_count); 5587 5625 5588 5626 return ret; 5589 5627 } ··· 5646 5678 len = sizeof(struct ice_ethtype_hdr); 5647 5679 break; 5648 5680 case ICE_VLAN_OFOS: 5681 + case ICE_VLAN_EX: 5682 + case ICE_VLAN_IN: 5649 5683 len = sizeof(struct ice_vlan_hdr); 5650 5684 break; 5651 5685 case ICE_IPV4_OFOS: ··· 5753 5783 } 5754 5784 5755 5785 /** 5786 + * ice_fill_adv_packet_vlan - fill dummy packet with VLAN tag type 5787 + * @vlan_type: VLAN tag type 5788 + * @pkt: dummy packet to fill in 5789 + * @offsets: offset info for the dummy packet 5790 + */ 5791 + static int 5792 + ice_fill_adv_packet_vlan(u16 vlan_type, u8 *pkt, 5793 + const struct ice_dummy_pkt_offsets *offsets) 5794 + { 5795 + u16 i; 5796 + 5797 + /* Find VLAN header and insert VLAN TPID */ 5798 + for (i = 0; offsets[i].type != ICE_PROTOCOL_LAST; i++) { 5799 + if (offsets[i].type == ICE_VLAN_OFOS || 5800 + offsets[i].type == ICE_VLAN_EX) { 5801 + struct ice_vlan_hdr *hdr; 5802 + u16 offset; 5803 + 5804 + offset = offsets[i].offset; 5805 + hdr = (struct ice_vlan_hdr *)&pkt[offset]; 5806 + hdr->type = cpu_to_be16(vlan_type); 5807 + 5808 + return 0; 5809 + } 5810 + } 5811 + 5812 + return -EIO; 5813 + } 5814 + 5815 + /** 5756 5816 * ice_find_adv_rule_entry - Search a rule entry 5757 5817 * @hw: pointer to the hardware structure 5758 5818 * @lkups: lookup elements or match criteria for the advanced recipe, one ··· 5817 5817 } 5818 5818 if (rinfo->sw_act.flag == list_itr->rule_info.sw_act.flag && 5819 5819 rinfo->tun_type == list_itr->rule_info.tun_type && 5820 + rinfo->vlan_type == list_itr->rule_info.vlan_type && 5820 5821 lkups_matched) 5821 5822 return list_itr; 5822 5823 } ··· 5994 5993 5995 5994 /* locate a dummy packet */ 5996 5995 profile = ice_find_dummy_packet(lkups, lkups_cnt, rinfo->tun_type); 5996 + if (IS_ERR(profile)) 5997 + return PTR_ERR(profile); 5997 5998 5998 5999 if (!(rinfo->sw_act.fltr_act == ICE_FWD_TO_VSI || 5999 6000 rinfo->sw_act.fltr_act == ICE_FWD_TO_Q || 6000 6001 rinfo->sw_act.fltr_act == ICE_FWD_TO_QGRP || 6001 - rinfo->sw_act.fltr_act == ICE_DROP_PACKET)) 6002 - return -EIO; 6002 + rinfo->sw_act.fltr_act == ICE_DROP_PACKET)) { 6003 + status = -EIO; 6004 + goto free_pkt_profile; 6005 + } 6003 6006 6004 6007 vsi_handle = rinfo->sw_act.vsi_handle; 6005 - if (!ice_is_vsi_valid(hw, vsi_handle)) 6006 - return -EINVAL; 6008 + if (!ice_is_vsi_valid(hw, vsi_handle)) { 6009 + status = -EINVAL; 6010 + goto free_pkt_profile; 6011 + } 6007 6012 6008 6013 if (rinfo->sw_act.fltr_act == ICE_FWD_TO_VSI) 6009 6014 rinfo->sw_act.fwd_id.hw_vsi_id = ··· 6019 6012 6020 6013 status = ice_add_adv_recipe(hw, lkups, lkups_cnt, rinfo, &rid); 6021 6014 if (status) 6022 - return status; 6015 + goto free_pkt_profile; 6023 6016 m_entry = ice_find_adv_rule_entry(hw, lkups, lkups_cnt, rid, rinfo); 6024 6017 if (m_entry) { 6025 6018 /* we have to add VSI to VSI_LIST and increment vsi_count. ··· 6038 6031 added_entry->rule_id = m_entry->rule_info.fltr_rule_id; 6039 6032 added_entry->vsi_handle = rinfo->sw_act.vsi_handle; 6040 6033 } 6041 - return status; 6034 + goto free_pkt_profile; 6042 6035 } 6043 6036 rule_buf_sz = ICE_SW_RULE_RX_TX_HDR_SIZE(s_rule, profile->pkt_len); 6044 6037 s_rule = kzalloc(rule_buf_sz, GFP_KERNEL); 6045 - if (!s_rule) 6046 - return -ENOMEM; 6038 + if (!s_rule) { 6039 + status = -ENOMEM; 6040 + goto free_pkt_profile; 6041 + } 6047 6042 if (!rinfo->flags_info.act_valid) { 6048 6043 act |= ICE_SINGLE_ACT_LAN_ENABLE; 6049 6044 act |= ICE_SINGLE_ACT_LB_ENABLE; ··· 6114 6105 goto err_ice_add_adv_rule; 6115 6106 } 6116 6107 6108 + if (rinfo->vlan_type != 0 && ice_is_dvm_ena(hw)) { 6109 + status = ice_fill_adv_packet_vlan(rinfo->vlan_type, 6110 + s_rule->hdr_data, 6111 + profile->offsets); 6112 + if (status) 6113 + goto err_ice_add_adv_rule; 6114 + } 6115 + 6117 6116 status = ice_aq_sw_rules(hw, (struct ice_aqc_sw_rules *)s_rule, 6118 6117 rule_buf_sz, 1, ice_aqc_opc_add_sw_rules, 6119 6118 NULL); ··· 6166 6149 } 6167 6150 6168 6151 kfree(s_rule); 6152 + 6153 + free_pkt_profile: 6154 + if (profile->match & ICE_PKT_KMALLOC) { 6155 + kfree(profile->offsets); 6156 + kfree(profile->pkt); 6157 + kfree(profile); 6158 + } 6169 6159 6170 6160 return status; 6171 6161 } ··· 6366 6342 /* Create any special protocol/offset pairs, such as looking at tunnel 6367 6343 * bits by extracting metadata 6368 6344 */ 6369 - status = ice_add_special_words(rinfo, &lkup_exts); 6345 + status = ice_add_special_words(rinfo, &lkup_exts, ice_is_dvm_ena(hw)); 6370 6346 if (status) 6371 6347 return status; 6372 6348
+1
drivers/net/ethernet/intel/ice/ice_switch.h
··· 192 192 u32 priority; 193 193 u8 rx; /* true means LOOKUP_RX otherwise LOOKUP_TX */ 194 194 u16 fltr_rule_id; 195 + u16 vlan_type; 195 196 struct ice_adv_rule_flags_info flags_info; 196 197 }; 197 198
+64 -2
drivers/net/ethernet/intel/ice/ice_tc_lib.c
··· 50 50 if (flags & ICE_TC_FLWR_FIELD_VLAN) 51 51 lkups_cnt++; 52 52 53 + /* is CVLAN specified? */ 54 + if (flags & ICE_TC_FLWR_FIELD_CVLAN) 55 + lkups_cnt++; 56 + 53 57 /* are IPv[4|6] fields specified? */ 54 58 if (flags & (ICE_TC_FLWR_FIELD_DEST_IPV4 | ICE_TC_FLWR_FIELD_SRC_IPV4 | 55 59 ICE_TC_FLWR_FIELD_DEST_IPV6 | ICE_TC_FLWR_FIELD_SRC_IPV6)) ··· 135 131 return ICE_SW_TUN_GTPC; 136 132 default: 137 133 return ICE_NON_TUN; 134 + } 135 + } 136 + 137 + static u16 ice_check_supported_vlan_tpid(u16 vlan_tpid) 138 + { 139 + switch (vlan_tpid) { 140 + case ETH_P_8021Q: 141 + case ETH_P_8021AD: 142 + case ETH_P_QINQ1: 143 + return vlan_tpid; 144 + default: 145 + return 0; 138 146 } 139 147 } 140 148 ··· 285 269 { 286 270 struct ice_tc_flower_lyr_2_4_hdrs *headers = &tc_fltr->outer_headers; 287 271 bool inner = false; 272 + u16 vlan_tpid = 0; 288 273 int i = 0; 274 + 275 + rule_info->vlan_type = vlan_tpid; 289 276 290 277 rule_info->tun_type = ice_sw_type_from_tunnel(tc_fltr->tunnel_type); 291 278 if (tc_fltr->tunnel_type != TNL_LAST) { ··· 330 311 331 312 /* copy VLAN info */ 332 313 if (flags & ICE_TC_FLWR_FIELD_VLAN) { 333 - list[i].type = ICE_VLAN_OFOS; 314 + vlan_tpid = be16_to_cpu(headers->vlan_hdr.vlan_tpid); 315 + rule_info->vlan_type = 316 + ice_check_supported_vlan_tpid(vlan_tpid); 317 + 318 + if (flags & ICE_TC_FLWR_FIELD_CVLAN) 319 + list[i].type = ICE_VLAN_EX; 320 + else 321 + list[i].type = ICE_VLAN_OFOS; 334 322 list[i].h_u.vlan_hdr.vlan = headers->vlan_hdr.vlan_id; 323 + list[i].m_u.vlan_hdr.vlan = cpu_to_be16(0xFFFF); 324 + i++; 325 + } 326 + 327 + if (flags & ICE_TC_FLWR_FIELD_CVLAN) { 328 + list[i].type = ICE_VLAN_IN; 329 + list[i].h_u.vlan_hdr.vlan = headers->cvlan_hdr.vlan_id; 335 330 list[i].m_u.vlan_hdr.vlan = cpu_to_be16(0xFFFF); 336 331 i++; 337 332 } ··· 978 945 BIT(FLOW_DISSECTOR_KEY_BASIC) | 979 946 BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) | 980 947 BIT(FLOW_DISSECTOR_KEY_VLAN) | 948 + BIT(FLOW_DISSECTOR_KEY_CVLAN) | 981 949 BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) | 982 950 BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) | 983 951 BIT(FLOW_DISSECTOR_KEY_ENC_CONTROL) | ··· 1094 1060 cpu_to_be16(match.key->vlan_id & VLAN_VID_MASK); 1095 1061 if (match.mask->vlan_priority) 1096 1062 headers->vlan_hdr.vlan_prio = match.key->vlan_priority; 1063 + if (match.mask->vlan_tpid) 1064 + headers->vlan_hdr.vlan_tpid = match.key->vlan_tpid; 1065 + } 1066 + 1067 + if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CVLAN)) { 1068 + struct flow_match_vlan match; 1069 + 1070 + if (!ice_is_dvm_ena(&vsi->back->hw)) { 1071 + NL_SET_ERR_MSG_MOD(fltr->extack, "Double VLAN mode is not enabled"); 1072 + return -EINVAL; 1073 + } 1074 + 1075 + flow_rule_match_cvlan(rule, &match); 1076 + 1077 + if (match.mask->vlan_id) { 1078 + if (match.mask->vlan_id == VLAN_VID_MASK) { 1079 + fltr->flags |= ICE_TC_FLWR_FIELD_CVLAN; 1080 + } else { 1081 + NL_SET_ERR_MSG_MOD(fltr->extack, 1082 + "Bad CVLAN mask"); 1083 + return -EINVAL; 1084 + } 1085 + } 1086 + 1087 + headers->cvlan_hdr.vlan_id = 1088 + cpu_to_be16(match.key->vlan_id & VLAN_VID_MASK); 1089 + if (match.mask->vlan_priority) 1090 + headers->cvlan_hdr.vlan_prio = match.key->vlan_priority; 1097 1091 } 1098 1092 1099 1093 if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL)) { ··· 1256 1194 ICE_TC_FLWR_FIELD_ENC_DST_MAC)) { 1257 1195 ether_addr_copy(fltr->outer_headers.l2_key.dst_mac, 1258 1196 vsi->netdev->dev_addr); 1259 - memset(fltr->outer_headers.l2_mask.dst_mac, 0xff, ETH_ALEN); 1197 + eth_broadcast_addr(fltr->outer_headers.l2_mask.dst_mac); 1260 1198 } 1261 1199 1262 1200 /* validate specified dest MAC address, make sure either it belongs to
+3
drivers/net/ethernet/intel/ice/ice_tc_lib.h
··· 23 23 #define ICE_TC_FLWR_FIELD_ENC_DST_MAC BIT(16) 24 24 #define ICE_TC_FLWR_FIELD_ETH_TYPE_ID BIT(17) 25 25 #define ICE_TC_FLWR_FIELD_ENC_OPTS BIT(18) 26 + #define ICE_TC_FLWR_FIELD_CVLAN BIT(19) 26 27 27 28 #define ICE_TC_FLOWER_MASK_32 0xFFFFFFFF 28 29 ··· 41 40 struct ice_tc_vlan_hdr { 42 41 __be16 vlan_id; /* Only last 12 bits valid */ 43 42 u16 vlan_prio; /* Only last 3 bits valid (valid values: 0..7) */ 43 + __be16 vlan_tpid; 44 44 }; 45 45 46 46 struct ice_tc_l2_hdr { ··· 83 81 struct ice_tc_l2_hdr l2_key; 84 82 struct ice_tc_l2_hdr l2_mask; 85 83 struct ice_tc_vlan_hdr vlan_hdr; 84 + struct ice_tc_vlan_hdr cvlan_hdr; 86 85 /* L3 (IPv4[6]) layer fields with their mask */ 87 86 struct ice_tc_l3_hdr l3_key; 88 87 struct ice_tc_l3_hdr l3_mask;
-1
drivers/net/ethernet/intel/ice/ice_vlan_mode.c
··· 199 199 #define ICE_SW_LKUP_VLAN_PKT_FLAGS_LKUP_IDX 2 200 200 #define ICE_SW_LKUP_PROMISC_VLAN_LOC_LKUP_IDX 2 201 201 #define ICE_PKT_FLAGS_0_TO_15_FV_IDX 1 202 - #define ICE_PKT_FLAGS_0_TO_15_VLAN_FLAGS_MASK 0xD000 203 202 static struct ice_update_recipe_lkup_idx_params ice_dvm_dflt_recipes[] = { 204 203 { 205 204 /* Update recipe ICE_SW_LKUP_VLAN to filter based on the