net/ice/base: support removing VSI from flow profile
[dpdk.git] / drivers / net / ice / base / ice_switch.c
index a4ba6a8..afc51d8 100644 (file)
@@ -912,39 +912,7 @@ static const u8 dummy_ipv6_gtpu_ipv6_udp_packet[] = {
        0x00, 0x00, /* 2 bytes for 4 byte alignment */
 };
 
-static const struct ice_dummy_pkt_offsets dummy_udp_gtp_packet_offsets[] = {
-       { ICE_MAC_OFOS,         0 },
-       { ICE_IPV4_OFOS,        14 },
-       { ICE_UDP_OF,           34 },
-       { ICE_GTP,              42 },
-       { ICE_PROTOCOL_LAST,    0 },
-};
-
-static const u8 dummy_udp_gtp_packet[] = {
-       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
-       0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00,
-       0x08, 0x00,
-
-       0x45, 0x00, 0x00, 0x30, /* ICE_IPV4_OFOS 14 */
-       0x00, 0x00, 0x00, 0x00,
-       0x00, 0x11, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00,
-
-       0x00, 0x00, 0x08, 0x68, /* ICE_UDP_OF 34 */
-       0x00, 0x1c, 0x00, 0x00,
-
-       0x34, 0xff, 0x00, 0x0c, /* ICE_GTP 42 */
-       0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x85,
-
-       0x02, 0x00, 0x00, 0x00, /* PDU Session extension header */
-       0x00, 0x00, 0x00, 0x00,
-};
-
-static const
-struct ice_dummy_pkt_offsets dummy_ipv4_gtpu_ipv4_packet_offsets[] = {
+static const struct ice_dummy_pkt_offsets dummy_ipv4_gtpu_ipv4_packet_offsets[] = {
        { ICE_MAC_OFOS,         0 },
        { ICE_IPV4_OFOS,        14 },
        { ICE_UDP_OF,           34 },
@@ -1126,8 +1094,38 @@ static const u8 dummy_ipv6_gtpu_ipv6_packet[] = {
        0x00, 0x00,
 };
 
-static const
-struct ice_dummy_pkt_offsets dummy_ipv4_gtp_no_pay_packet_offsets[] = {
+static const struct ice_dummy_pkt_offsets dummy_udp_gtp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_IPV4_OFOS,        14 },
+       { ICE_UDP_OF,           34 },
+       { ICE_GTP,              42 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_udp_gtp_packet[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x08, 0x00,
+
+       0x45, 0x00, 0x00, 0x30, /* ICE_IPV4_OFOS 14 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x11, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x08, 0x68, /* ICE_UDP_OF 34 */
+       0x00, 0x1c, 0x00, 0x00,
+
+       0x34, 0xff, 0x00, 0x0c, /* ICE_GTP 42 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x85,
+
+       0x02, 0x00, 0x00, 0x00, /* PDU Session extension header */
+       0x00, 0x00, 0x00, 0x00,
+};
+
+static const struct ice_dummy_pkt_offsets dummy_ipv4_gtp_no_pay_packet_offsets[] = {
        { ICE_MAC_OFOS,         0 },
        { ICE_IPV4_OFOS,        14 },
        { ICE_UDP_OF,           34 },
@@ -1612,6 +1610,7 @@ static const u8 dummy_ipv6_l2tpv3_pkt[] = {
 
 static const struct ice_dummy_pkt_offsets dummy_qinq_ipv4_packet_offsets[] = {
        { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
        { ICE_VLAN_EX,          14 },
        { ICE_VLAN_OFOS,        18 },
        { ICE_IPV4_OFOS,        22 },
@@ -1622,7 +1621,8 @@ static const u8 dummy_qinq_ipv4_pkt[] = {
        0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
-       0x91, 0x00,
+
+       0x91, 0x00,             /* ICE_ETYPE_OL 12 */
 
        0x00, 0x00, 0x81, 0x00, /* ICE_VLAN_EX 14 */
        0x00, 0x00, 0x08, 0x00, /* ICE_VLAN_OFOS 18 */
@@ -1641,6 +1641,7 @@ static const u8 dummy_qinq_ipv4_pkt[] = {
 
 static const struct ice_dummy_pkt_offsets dummy_qinq_ipv6_packet_offsets[] = {
        { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
        { ICE_VLAN_EX,          14 },
        { ICE_VLAN_OFOS,        18 },
        { ICE_IPV6_OFOS,        22 },
@@ -1651,7 +1652,8 @@ static const u8 dummy_qinq_ipv6_pkt[] = {
        0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
-       0x91, 0x00,
+
+       0x91, 0x00,             /* ICE_ETYPE_OL 12 */
 
        0x00, 0x00, 0x81, 0x00, /* ICE_VLAN_EX 14 */
        0x00, 0x00, 0x86, 0xDD, /* ICE_VLAN_OFOS 18 */
@@ -1678,6 +1680,7 @@ static const u8 dummy_qinq_ipv6_pkt[] = {
 
 static const struct ice_dummy_pkt_offsets dummy_qinq_pppoe_packet_offsets[] = {
        { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
        { ICE_VLAN_EX,          14 },
        { ICE_VLAN_OFOS,        18 },
        { ICE_PPPOE,            22 },
@@ -1687,6 +1690,7 @@ static const struct ice_dummy_pkt_offsets dummy_qinq_pppoe_packet_offsets[] = {
 static const
 struct ice_dummy_pkt_offsets dummy_qinq_pppoe_ipv4_packet_offsets[] = {
        { ICE_MAC_OFOS,         0 },
+       { ICE_ETYPE_OL,         12 },
        { ICE_VLAN_EX,          14 },
        { ICE_VLAN_OFOS,        18 },
        { ICE_PPPOE,            22 },
@@ -1698,7 +1702,8 @@ static const u8 dummy_qinq_pppoe_ipv4_pkt[] = {
        0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
-       0x91, 0x00,
+
+       0x91, 0x00,             /* ICE_ETYPE_OL 12 */
 
        0x00, 0x00, 0x81, 0x00, /* ICE_VLAN_EX 14 */
        0x00, 0x00, 0x88, 0x64, /* ICE_VLAN_OFOS 18 */
@@ -2293,7 +2298,7 @@ ice_alloc_global_lut_exit:
 }
 
 /**
- * ice_free_global_lut - free a RSS global LUT
+ * ice_free_rss_global_lut - free a RSS global LUT
  * @hw: pointer to the HW struct
  * @global_lut_id: ID of the RSS global LUT to free
  */
@@ -3169,7 +3174,6 @@ ice_aq_get_recipe(struct ice_hw *hw,
        buf_size = *num_recipes * sizeof(*s_recipe_list);
 
        status = ice_aq_send_cmd(hw, &desc, s_recipe_list, buf_size, cd);
-       /* cppcheck-suppress constArgument */
        *num_recipes = LE16_TO_CPU(cmd->num_sub_recipes);
 
        return status;
@@ -4974,7 +4978,7 @@ enum ice_status ice_add_vlan(struct ice_hw *hw, struct LIST_HEAD_TYPE *v_list)
 }
 
 /**
- * ice_add_mac_vlan - Add MAC and VLAN pair based filter rule
+ * ice_add_mac_vlan_rule - Add MAC and VLAN pair based filter rule
  * @hw: pointer to the hardware structure
  * @mv_list: list of MAC and VLAN filters
  * @sw: pointer to switch info struct for which function add rule
@@ -5666,7 +5670,7 @@ ice_get_vsi_promisc(struct ice_hw *hw, u16 vsi_handle, u8 *promisc_mask,
 }
 
 /**
- * ice_get_vsi_vlan_promisc - get VLAN promiscuous mode of given VSI
+ * _ice_get_vsi_vlan_promisc - get VLAN promiscuous mode of given VSI
  * @hw: pointer to the hardware structure
  * @vsi_handle: VSI handle to retrieve info from
  * @promisc_mask: pointer to mask to be filled in
@@ -6073,7 +6077,7 @@ ice_remove_vsi_lkup_fltr(struct ice_hw *hw, u16 vsi_handle,
                                          &remove_list_head);
        ice_release_lock(rule_lock);
        if (status)
-               return;
+               goto free_fltr_list;
 
        switch (lkup) {
        case ICE_SW_LKUP_MAC:
@@ -6101,6 +6105,7 @@ ice_remove_vsi_lkup_fltr(struct ice_hw *hw, u16 vsi_handle,
                break;
        }
 
+free_fltr_list:
        LIST_FOR_EACH_ENTRY_SAFE(fm_entry, tmp, &remove_list_head,
                                 ice_fltr_list_entry, list_entry) {
                LIST_DEL(&fm_entry->list_entry);
@@ -6658,7 +6663,7 @@ static bool ice_prot_type_to_id(enum ice_protocol_type type, u8 *id)
 }
 
 /**
- * ice_find_valid_words - count valid words
+ * ice_fill_valid_words - count valid words
  * @rule: advanced rule with lookup information
  * @lkup_exts: byte offset extractions of the words that are valid
  *
@@ -6677,7 +6682,7 @@ ice_fill_valid_words(struct ice_adv_lkup_elem *rule,
 
        for (j = 0; j < sizeof(rule->m_u) / sizeof(u16); j++)
                if (((u16 *)&rule->m_u)[j] &&
-                   rule->type < ARRAY_SIZE(ice_prot_ext)) {
+                   (size_t)rule->type < ARRAY_SIZE(ice_prot_ext)) {
                        /* No more space to accommodate */
                        if (word >= ICE_MAX_CHAIN_WORDS)
                                return 0;
@@ -7257,7 +7262,7 @@ free_mem:
 }
 
 /**
- * ice_tun_type_match_mask - determine if tun type needs a match mask
+ * ice_tun_type_match_word - determine if tun type needs a match mask
  * @tun_type: tunnel type
  * @mask: mask to be used for the tunnel
  */
@@ -7801,26 +7806,6 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
                *pkt_len = sizeof(dummy_ipv6_gtpu_ipv6_packet);
                *offsets = dummy_ipv6_gtp_no_pay_packet_offsets;
                return;
-       } else if (tun_type == ICE_SW_TUN_IPV4_GTPU_IPV4) {
-               *pkt = dummy_ipv4_gtpu_ipv4_packet;
-               *pkt_len = sizeof(dummy_ipv4_gtpu_ipv4_packet);
-               *offsets = dummy_ipv4_gtpu_ipv4_packet_offsets;
-               return;
-       } else if (tun_type == ICE_SW_TUN_IPV4_GTPU_IPV6) {
-               *pkt = dummy_ipv4_gtpu_ipv6_packet;
-               *pkt_len = sizeof(dummy_ipv4_gtpu_ipv6_packet);
-               *offsets = dummy_ipv4_gtpu_ipv6_packet_offsets;
-               return;
-       } else if (tun_type == ICE_SW_TUN_IPV6_GTPU_IPV4) {
-               *pkt = dummy_ipv6_gtpu_ipv4_packet;
-               *pkt_len = sizeof(dummy_ipv6_gtpu_ipv4_packet);
-               *offsets = dummy_ipv6_gtpu_ipv4_packet_offsets;
-               return;
-       } else if (tun_type == ICE_SW_TUN_IPV6_GTPU_IPV6) {
-               *pkt = dummy_ipv6_gtpu_ipv6_packet;
-               *pkt_len = sizeof(dummy_ipv6_gtpu_ipv6_packet);
-               *offsets = dummy_ipv6_gtpu_ipv6_packet_offsets;
-               return;
        }
 
        if (tun_type == ICE_SW_TUN_IPV4_ESP) {
@@ -7969,6 +7954,32 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
                return;
        }
 
+       /* Support GTP tunnel + L3 */
+       if (tun_type == ICE_SW_TUN_IPV4_GTPU_IPV4) {
+               *pkt = dummy_ipv4_gtpu_ipv4_packet;
+               *pkt_len = sizeof(dummy_ipv4_gtpu_ipv4_packet);
+               *offsets = dummy_ipv4_gtpu_ipv4_packet_offsets;
+               return;
+       }
+       if (tun_type == ICE_SW_TUN_IPV4_GTPU_IPV6) {
+               *pkt = dummy_ipv4_gtpu_ipv6_packet;
+               *pkt_len = sizeof(dummy_ipv4_gtpu_ipv6_packet);
+               *offsets = dummy_ipv4_gtpu_ipv6_packet_offsets;
+               return;
+       }
+       if (tun_type == ICE_SW_TUN_IPV6_GTPU_IPV4) {
+               *pkt = dummy_ipv6_gtpu_ipv4_packet;
+               *pkt_len = sizeof(dummy_ipv6_gtpu_ipv4_packet);
+               *offsets = dummy_ipv6_gtpu_ipv4_packet_offsets;
+               return;
+       }
+       if (tun_type == ICE_SW_TUN_IPV6_GTPU_IPV6) {
+               *pkt = dummy_ipv6_gtpu_ipv6_packet;
+               *pkt_len = sizeof(dummy_ipv6_gtpu_ipv6_packet);
+               *offsets = dummy_ipv6_gtpu_ipv6_packet_offsets;
+               return;
+       }
+
        if (tun_type == ICE_ALL_TUNNELS) {
                *pkt = dummy_gre_udp_packet;
                *pkt_len = sizeof(dummy_gre_udp_packet);
@@ -8848,7 +8859,7 @@ ice_rem_adv_rule_by_id(struct ice_hw *hw,
 }
 
 /**
- * ice_rem_adv_for_vsi - removes existing advanced switch rules for a
+ * ice_rem_adv_rule_for_vsi - removes existing advanced switch rules for a
  *                       given VSI handle
  * @hw: pointer to the hardware structure
  * @vsi_handle: VSI handle for which we are supposed to remove all the rules.
@@ -9130,7 +9141,7 @@ ice_replay_vsi_all_fltr(struct ice_hw *hw, struct ice_port_info *pi,
 }
 
 /**
- * ice_rm_all_sw_replay_rule - helper function to delete filter replay rules
+ * ice_rm_sw_replay_rule_info - helper function to delete filter replay rules
  * @hw: pointer to the HW struct
  * @sw: pointer to switch info struct for which function removes filters
  *