net/ice/base: support L4 for QinQ switch filter
[dpdk.git] / drivers / net / ice / base / ice_switch.c
index 2d8904d..43ad018 100644 (file)
@@ -1660,7 +1660,7 @@ static const struct ice_dummy_pkt_offsets dummy_qinq_ipv4_packet_offsets[] = {
        { ICE_MAC_OFOS,         0 },
        { ICE_VLAN_EX,          12 },
        { ICE_VLAN_IN,          16 },
-       { ICE_ETYPE_OL,         20 },
+       { ICE_ETYPE_OL,         20 },
        { ICE_IPV4_OFOS,        22 },
        { ICE_PROTOCOL_LAST,    0 },
 };
@@ -1674,6 +1674,35 @@ static const u8 dummy_qinq_ipv4_pkt[] = {
        0x81, 0x00, 0x00, 0x00, /* ICE_VLAN_IN 16 */
        0x08, 0x00,             /* ICE_ETYPE_OL 20 */
 
+       0x45, 0x00, 0x00, 0x14, /* ICE_IPV4_OFOS 22 */
+       0x00, 0x01, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00,     /* 2 bytes for 4 byte alignment */
+};
+
+static const
+struct ice_dummy_pkt_offsets dummy_qinq_ipv4_udp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_VLAN_EX,          12 },
+       { ICE_VLAN_IN,          16 },
+       { ICE_ETYPE_OL,         20 },
+       { ICE_IPV4_OFOS,        22 },
+       { ICE_UDP_ILOS,         42 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_qinq_ipv4_udp_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x91, 0x00, 0x00, 0x00, /* ICE_VLAN_EX 12 */
+       0x81, 0x00, 0x00, 0x00, /* ICE_VLAN_IN 16 */
+       0x08, 0x00,             /* ICE_ETYPE_OL 20 */
+
        0x45, 0x00, 0x00, 0x1c, /* ICE_IPV4_OFOS 22 */
        0x00, 0x01, 0x00, 0x00,
        0x00, 0x11, 0x00, 0x00,
@@ -1686,11 +1715,46 @@ static const u8 dummy_qinq_ipv4_pkt[] = {
        0x00, 0x00,     /* 2 bytes for 4 byte alignment */
 };
 
+static const
+struct ice_dummy_pkt_offsets dummy_qinq_ipv4_tcp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_VLAN_EX,          12 },
+       { ICE_VLAN_IN,          16 },
+       { ICE_ETYPE_OL,         20 },
+       { ICE_IPV4_OFOS,        22 },
+       { ICE_TCP_IL,           42 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_qinq_ipv4_tcp_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x91, 0x00, 0x00, 0x00, /* ICE_VLAN_EX 12 */
+       0x81, 0x00, 0x00, 0x00, /* ICE_VLAN_IN 16 */
+       0x08, 0x00,             /* ICE_ETYPE_OL 20 */
+
+       0x45, 0x00, 0x00, 0x28, /* ICE_IPV4_OFOS 22 */
+       0x00, 0x01, 0x00, 0x00,
+       0x00, 0x06, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 42 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x50, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00,     /* 2 bytes for 4 byte alignment */
+};
+
 static const struct ice_dummy_pkt_offsets dummy_qinq_ipv6_packet_offsets[] = {
        { ICE_MAC_OFOS,         0 },
        { ICE_VLAN_EX,          12 },
        { ICE_VLAN_IN,          16 },
-       { ICE_ETYPE_OL,         20 },
+       { ICE_ETYPE_OL,         20 },
        { ICE_IPV6_OFOS,        22 },
        { ICE_PROTOCOL_LAST,    0 },
 };
@@ -1705,7 +1769,41 @@ static const u8 dummy_qinq_ipv6_pkt[] = {
        0x86, 0xDD,             /* ICE_ETYPE_OL 20 */
 
        0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 22 */
-       0x00, 0x10, 0x11, 0x00, /* Next header UDP */
+       0x00, 0x00, 0x3b, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00,     /* 2 bytes for 4 byte alignment */
+};
+
+static const
+struct ice_dummy_pkt_offsets dummy_qinq_ipv6_udp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_VLAN_EX,          12 },
+       { ICE_VLAN_IN,          16 },
+       { ICE_ETYPE_OL,         20 },
+       { ICE_IPV6_OFOS,        22 },
+       { ICE_UDP_ILOS,         62 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_qinq_ipv6_udp_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x91, 0x00, 0x00, 0x00, /* ICE_VLAN_EX 12 */
+       0x81, 0x00, 0x00, 0x00, /* ICE_VLAN_IN 16 */
+       0x86, 0xDD,             /* ICE_ETYPE_OL 20 */
+
+       0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 22 */
+       0x00, 0x08, 0x11, 0x00, /* Next header UDP */
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
@@ -1716,9 +1814,46 @@ static const u8 dummy_qinq_ipv6_pkt[] = {
        0x00, 0x00, 0x00, 0x00,
 
        0x00, 0x00, 0x00, 0x00, /* ICE_UDP_ILOS 62 */
-       0x00, 0x10, 0x00, 0x00,
+       0x00, 0x08, 0x00, 0x00,
 
-       0x00, 0x00, 0x00, 0x00, /* needed for ESP packets */
+       0x00, 0x00,     /* 2 bytes for 4 byte alignment */
+};
+
+static const
+struct ice_dummy_pkt_offsets dummy_qinq_ipv6_tcp_packet_offsets[] = {
+       { ICE_MAC_OFOS,         0 },
+       { ICE_VLAN_EX,          12 },
+       { ICE_VLAN_IN,          16 },
+       { ICE_ETYPE_OL,         20 },
+       { ICE_IPV6_OFOS,        22 },
+       { ICE_TCP_IL,           62 },
+       { ICE_PROTOCOL_LAST,    0 },
+};
+
+static const u8 dummy_qinq_ipv6_tcp_pkt[] = {
+       0x00, 0x00, 0x00, 0x00, /* ICE_MAC_OFOS 0 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x91, 0x00, 0x00, 0x00, /* ICE_VLAN_EX 12 */
+       0x81, 0x00, 0x00, 0x00, /* ICE_VLAN_IN 16 */
+       0x86, 0xDD,             /* ICE_ETYPE_OL 20 */
+
+       0x60, 0x00, 0x00, 0x00, /* ICE_IPV6_OFOS 22 */
+       0x00, 0x14, 0x06, 0x00, /* Next header TCP */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+
+       0x00, 0x00, 0x00, 0x00, /* ICE_TCP_IL 62 */
+       0x00, 0x00, 0x00, 0x00,
+       0x00, 0x00, 0x00, 0x00,
+       0x50, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00,
 
        0x00, 0x00,     /* 2 bytes for 4 byte alignment */
@@ -3471,6 +3606,10 @@ enum ice_status ice_get_initial_sw_cfg(struct ice_hw *hw)
                                        ICE_AQC_GET_SW_CONF_RESP_TYPE_S);
 
                        switch (res_type) {
+                       case ICE_AQC_GET_SW_CONF_RESP_VSI:
+                               if (hw->dcf_enabled && !is_vf)
+                                       hw->pf_id = pf_vf_num;
+                               break;
                        case ICE_AQC_GET_SW_CONF_RESP_PHYS_PORT:
                        case ICE_AQC_GET_SW_CONF_RESP_VIRT_PORT:
                                if (j == num_total_ports) {
@@ -4681,7 +4820,7 @@ ice_aq_get_res_descs(struct ice_hw *hw, u16 num_entries,
  * @sw: pointer to switch info struct for which function add rule
  * @lport: logic port number on which function add rule
  *
- * IMPORTANT: When the ucast_shared flag is set to false and m_list has
+ * IMPORTANT: When the umac_shared flag is set to false and m_list has
  * multiple unicast addresses, the function assumes that all the
  * addresses are unique in a given add_mac call. It doesn't
  * check for duplicates in this case, removing duplicates from a given
@@ -4724,7 +4863,7 @@ ice_add_mac_rule(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list,
                if (m_list_itr->fltr_info.lkup_type != ICE_SW_LKUP_MAC ||
                    IS_ZERO_ETHER_ADDR(add))
                        return ICE_ERR_PARAM;
-               if (IS_UNICAST_ETHER_ADDR(add) && !hw->ucast_shared) {
+               if (IS_UNICAST_ETHER_ADDR(add) && !hw->umac_shared) {
                        /* Don't overwrite the unicast address */
                        ice_acquire_lock(rule_lock);
                        if (ice_find_rule_entry(rule_head,
@@ -4735,7 +4874,7 @@ ice_add_mac_rule(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list,
                        ice_release_lock(rule_lock);
                        num_unicast++;
                } else if (IS_MULTICAST_ETHER_ADDR(add) ||
-                          (IS_UNICAST_ETHER_ADDR(add) && hw->ucast_shared)) {
+                          (IS_UNICAST_ETHER_ADDR(add) && hw->umac_shared)) {
                        m_list_itr->status =
                                ice_add_rule_internal(hw, recp_list, lport,
                                                      m_list_itr);
@@ -5424,7 +5563,7 @@ ice_remove_mac_rule(struct ice_hw *hw, struct LIST_HEAD_TYPE *m_list,
 
                list_itr->fltr_info.fwd_id.hw_vsi_id =
                                        ice_get_hw_vsi_num(hw, vsi_handle);
-               if (IS_UNICAST_ETHER_ADDR(add) && !hw->ucast_shared) {
+               if (IS_UNICAST_ETHER_ADDR(add) && !hw->umac_shared) {
                        /* Don't remove the unicast address that belongs to
                         * another VSI on the switch, since it is not being
                         * shared...
@@ -7918,12 +8057,40 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
 
        if ((tun_type == ICE_SW_TUN_AND_NON_TUN_QINQ ||
             tun_type == ICE_NON_TUN_QINQ) && ipv6) {
+               if (tcp) {
+                       *pkt = dummy_qinq_ipv6_tcp_pkt;
+                       *pkt_len = sizeof(dummy_qinq_ipv6_tcp_pkt);
+                       *offsets = dummy_qinq_ipv6_tcp_packet_offsets;
+                       return;
+               }
+
+               if (udp) {
+                       *pkt = dummy_qinq_ipv6_udp_pkt;
+                       *pkt_len = sizeof(dummy_qinq_ipv6_udp_pkt);
+                       *offsets = dummy_qinq_ipv6_udp_packet_offsets;
+                       return;
+               }
+
                *pkt = dummy_qinq_ipv6_pkt;
                *pkt_len = sizeof(dummy_qinq_ipv6_pkt);
                *offsets = dummy_qinq_ipv6_packet_offsets;
                return;
        } else if (tun_type == ICE_SW_TUN_AND_NON_TUN_QINQ ||
                           tun_type == ICE_NON_TUN_QINQ) {
+               if (tcp) {
+                       *pkt = dummy_qinq_ipv4_tcp_pkt;
+                       *pkt_len = sizeof(dummy_qinq_ipv4_tcp_pkt);
+                       *offsets = dummy_qinq_ipv4_tcp_packet_offsets;
+                       return;
+               }
+
+               if (udp) {
+                       *pkt = dummy_qinq_ipv4_udp_pkt;
+                       *pkt_len = sizeof(dummy_qinq_ipv4_udp_pkt);
+                       *offsets = dummy_qinq_ipv4_udp_packet_offsets;
+                       return;
+               }
+
                *pkt = dummy_qinq_ipv4_pkt;
                *pkt_len = sizeof(dummy_qinq_ipv4_pkt);
                *offsets = dummy_qinq_ipv4_packet_offsets;