Skip to content

Commit de6acd1

Browse files
Michal Swiatkowskianguy11
authored andcommitted
ice: fix adding different tunnels
Adding filters with the same values inside for VXLAN and Geneve causes HW error, because it looks exactly the same. To choose between different type of tunnels new recipe is needed. Add storing tunnel types in creating recipes function and start checking it in finding function. Change getting open tunnels function to return port on correct tunnel type. This is needed to copy correct port to dummy packet. Block user from adding enc_dst_port via tc flower, because VXLAN and Geneve filters can be created only with destination port which was previously opened. Fixes: 8b032a5 ("ice: low level support for tunnels") Signed-off-by: Michal Swiatkowski <[email protected]> Tested-by: Sandeep Penigalapati <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 0e32ff0 commit de6acd1

File tree

6 files changed

+25
-13
lines changed

6 files changed

+25
-13
lines changed

drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ ice_fdir_write_all_fltr(struct ice_pf *pf, struct ice_fdir_fltr *input,
12681268
bool is_tun = tun == ICE_FD_HW_SEG_TUN;
12691269
int err;
12701270

1271-
if (is_tun && !ice_get_open_tunnel_port(&pf->hw, &port_num))
1271+
if (is_tun && !ice_get_open_tunnel_port(&pf->hw, &port_num, TNL_ALL))
12721272
continue;
12731273
err = ice_fdir_write_fltr(pf, input, add, is_tun);
12741274
if (err)
@@ -1652,7 +1652,7 @@ int ice_add_fdir_ethtool(struct ice_vsi *vsi, struct ethtool_rxnfc *cmd)
16521652
}
16531653

16541654
/* return error if not an update and no available filters */
1655-
fltrs_needed = ice_get_open_tunnel_port(hw, &tunnel_port) ? 2 : 1;
1655+
fltrs_needed = ice_get_open_tunnel_port(hw, &tunnel_port, TNL_ALL) ? 2 : 1;
16561656
if (!ice_fdir_find_fltr_by_idx(hw, fsp->location) &&
16571657
ice_fdir_num_avail_fltr(hw, pf->vsi[vsi->idx]) < fltrs_needed) {
16581658
dev_err(dev, "Failed to add filter. The maximum number of flow director filters has been reached.\n");

drivers/net/ethernet/intel/ice/ice_fdir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input,
924924
memcpy(pkt, ice_fdir_pkt[idx].pkt, ice_fdir_pkt[idx].pkt_len);
925925
loc = pkt;
926926
} else {
927-
if (!ice_get_open_tunnel_port(hw, &tnl_port))
927+
if (!ice_get_open_tunnel_port(hw, &tnl_port, TNL_ALL))
928928
return ICE_ERR_DOES_NOT_EXIST;
929929
if (!ice_fdir_pkt[idx].tun_pkt)
930930
return ICE_ERR_PARAM;

drivers/net/ethernet/intel/ice/ice_flex_pipe.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,17 +1899,20 @@ static struct ice_buf *ice_pkg_buf(struct ice_buf_build *bld)
18991899
* ice_get_open_tunnel_port - retrieve an open tunnel port
19001900
* @hw: pointer to the HW structure
19011901
* @port: returns open port
1902+
* @type: type of tunnel, can be TNL_LAST if it doesn't matter
19021903
*/
19031904
bool
1904-
ice_get_open_tunnel_port(struct ice_hw *hw, u16 *port)
1905+
ice_get_open_tunnel_port(struct ice_hw *hw, u16 *port,
1906+
enum ice_tunnel_type type)
19051907
{
19061908
bool res = false;
19071909
u16 i;
19081910

19091911
mutex_lock(&hw->tnl_lock);
19101912

19111913
for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++)
1912-
if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].port) {
1914+
if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].port &&
1915+
(type == TNL_LAST || type == hw->tnl.tbl[i].type)) {
19131916
*port = hw->tnl.tbl[i].port;
19141917
res = true;
19151918
break;

drivers/net/ethernet/intel/ice/ice_flex_pipe.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ enum ice_status
3333
ice_get_sw_fv_list(struct ice_hw *hw, u8 *prot_ids, u16 ids_cnt,
3434
unsigned long *bm, struct list_head *fv_list);
3535
bool
36-
ice_get_open_tunnel_port(struct ice_hw *hw, u16 *port);
36+
ice_get_open_tunnel_port(struct ice_hw *hw, u16 *port,
37+
enum ice_tunnel_type type);
3738
int ice_udp_tunnel_set_port(struct net_device *netdev, unsigned int table,
3839
unsigned int idx, struct udp_tunnel_info *ti);
3940
int ice_udp_tunnel_unset_port(struct net_device *netdev, unsigned int table,

drivers/net/ethernet/intel/ice/ice_switch.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3796,10 +3796,13 @@ static struct ice_protocol_entry ice_prot_id_tbl[ICE_PROTOCOL_LAST] = {
37963796
* ice_find_recp - find a recipe
37973797
* @hw: pointer to the hardware structure
37983798
* @lkup_exts: extension sequence to match
3799+
* @tun_type: type of recipe tunnel
37993800
*
38003801
* Returns index of matching recipe, or ICE_MAX_NUM_RECIPES if not found.
38013802
*/
3802-
static u16 ice_find_recp(struct ice_hw *hw, struct ice_prot_lkup_ext *lkup_exts)
3803+
static u16
3804+
ice_find_recp(struct ice_hw *hw, struct ice_prot_lkup_ext *lkup_exts,
3805+
enum ice_sw_tunnel_type tun_type)
38033806
{
38043807
bool refresh_required = true;
38053808
struct ice_sw_recipe *recp;
@@ -3860,8 +3863,9 @@ static u16 ice_find_recp(struct ice_hw *hw, struct ice_prot_lkup_ext *lkup_exts)
38603863
}
38613864
/* If for "i"th recipe the found was never set to false
38623865
* then it means we found our match
3866+
* Also tun type of recipe needs to be checked
38633867
*/
3864-
if (found)
3868+
if (found && recp[i].tun_type == tun_type)
38653869
return i; /* Return the recipe ID */
38663870
}
38673871
}
@@ -4651,11 +4655,12 @@ ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
46514655
}
46524656

46534657
/* Look for a recipe which matches our requested fv / mask list */
4654-
*rid = ice_find_recp(hw, lkup_exts);
4658+
*rid = ice_find_recp(hw, lkup_exts, rinfo->tun_type);
46554659
if (*rid < ICE_MAX_NUM_RECIPES)
46564660
/* Success if found a recipe that match the existing criteria */
46574661
goto err_unroll;
46584662

4663+
rm->tun_type = rinfo->tun_type;
46594664
/* Recipe we need does not exist, add a recipe */
46604665
status = ice_add_sw_recipe(hw, rm, profiles);
46614666
if (status)
@@ -4958,11 +4963,13 @@ ice_fill_adv_packet_tun(struct ice_hw *hw, enum ice_sw_tunnel_type tun_type,
49584963

49594964
switch (tun_type) {
49604965
case ICE_SW_TUN_VXLAN:
4966+
if (!ice_get_open_tunnel_port(hw, &open_port, TNL_VXLAN))
4967+
return ICE_ERR_CFG;
4968+
break;
49614969
case ICE_SW_TUN_GENEVE:
4962-
if (!ice_get_open_tunnel_port(hw, &open_port))
4970+
if (!ice_get_open_tunnel_port(hw, &open_port, TNL_GENEVE))
49634971
return ICE_ERR_CFG;
49644972
break;
4965-
49664973
default:
49674974
/* Nothing needs to be done for this tunnel type */
49684975
return 0;
@@ -5555,7 +5562,7 @@ ice_rem_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
55555562
if (status)
55565563
return status;
55575564

5558-
rid = ice_find_recp(hw, &lkup_exts);
5565+
rid = ice_find_recp(hw, &lkup_exts, rinfo->tun_type);
55595566
/* If did not find a recipe that match the existing criteria */
55605567
if (rid == ICE_MAX_NUM_RECIPES)
55615568
return ICE_ERR_PARAM;

drivers/net/ethernet/intel/ice/ice_tc_lib.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,8 @@ ice_parse_tunnel_attr(struct net_device *dev, struct flow_rule *rule,
795795
headers->l3_mask.ttl = match.mask->ttl;
796796
}
797797

798-
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_PORTS)) {
798+
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ENC_PORTS) &&
799+
fltr->tunnel_type != TNL_VXLAN && fltr->tunnel_type != TNL_GENEVE) {
799800
struct flow_match_ports match;
800801

801802
flow_rule_match_enc_ports(rule, &match);

0 commit comments

Comments
 (0)