net/ice/base: update switch training packets with open ports
authorQi Zhang <qi.z.zhang@intel.com>
Thu, 29 Aug 2019 02:36:44 +0000 (10:36 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:53 +0000 (15:00 +0200)
This patch updates UDP tunneled training packets with an appropriate
UDP dest port. For the correct profile to be chosen, an open tunnel
port must be included in the training packet.

Added GENEVE tunnel labels in the test package in order to test GENEVE
tunnel rule creation.

Signed-off-by: Dan Nowlin <dan.nowlin@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Xiaolong Ye <xiaolong.ye@intel.com>
drivers/net/ice/base/ice_switch.c

index ef12df5..c39a77a 100644 (file)
@@ -5825,6 +5825,55 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
        return ICE_SUCCESS;
 }
 
+/**
+ * ice_fill_adv_packet_tun - fill dummy packet with udp tunnel port
+ * @hw: pointer to the hardware structure
+ * @tun_type: tunnel type
+ * @pkt: dummy packet to fill in
+ * @offsets: offset info for the dummy packet
+ */
+static enum ice_status
+ice_fill_adv_packet_tun(struct ice_hw *hw, enum ice_sw_tunnel_type tun_type,
+                       u8 *pkt, const struct ice_dummy_pkt_offsets *offsets)
+{
+       u16 open_port, i;
+
+       switch (tun_type) {
+       case ICE_SW_TUN_AND_NON_TUN:
+       case ICE_SW_TUN_VXLAN_GPE:
+       case ICE_SW_TUN_VXLAN:
+       case ICE_SW_TUN_UDP:
+               if (!ice_get_open_tunnel_port(hw, TNL_VXLAN, &open_port))
+                       return ICE_ERR_CFG;
+               break;
+
+       case ICE_SW_TUN_GENEVE:
+               if (!ice_get_open_tunnel_port(hw, TNL_GENEVE, &open_port))
+                       return ICE_ERR_CFG;
+               break;
+
+       default:
+               /* Nothing needs to be done for this tunnel type */
+               return ICE_SUCCESS;
+       }
+
+       /* Find the outer UDP protocol header and insert the port number */
+       for (i = 0; offsets[i].type != ICE_PROTOCOL_LAST; i++) {
+               if (offsets[i].type == ICE_UDP_OF) {
+                       struct ice_l4_hdr *hdr;
+                       u16 offset;
+
+                       offset = offsets[i].offset;
+                       hdr = (struct ice_l4_hdr *)&pkt[offset];
+                       hdr->dst_port = open_port << 8 | open_port >> 8;
+
+                       return ICE_SUCCESS;
+               }
+       }
+
+       return ICE_ERR_CFG;
+}
+
 /**
  * ice_find_adv_rule_entry - Search a rule entry
  * @hw: pointer to the hardware structure
@@ -6129,6 +6178,14 @@ ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
        ice_fill_adv_dummy_packet(lkups, lkups_cnt, s_rule, pkt, pkt_len,
                                  pkt_offsets);
 
+       if (rinfo->tun_type != ICE_NON_TUN) {
+               status = ice_fill_adv_packet_tun(hw, rinfo->tun_type,
+                                                s_rule->pdata.lkup_tx_rx.hdr,
+                                                pkt_offsets);
+               if (status)
+                       goto err_ice_add_adv_rule;
+       }
+
        status = ice_aq_sw_rules(hw, (struct ice_aqc_sw_rules *)s_rule,
                                 rule_buf_sz, 1, ice_aqc_opc_add_sw_rules,
                                 NULL);