From: Qi Zhang Date: Thu, 29 Aug 2019 02:36:35 +0000 (+0800) Subject: net/ice/base: add routine for tunnel port query X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=56c0ab44051261d99a13849afec3a88dbd3c75de;p=dpdk.git net/ice/base: add routine for tunnel port query Add ice_get_open_tunnel_port routine, which can be used to find an open tunnel port for creating switch and flow director training packets. Signed-off-by: Dan Nowlin Signed-off-by: Paul M Stillwell Jr Signed-off-by: Qi Zhang Acked-by: Xiaolong Ye --- diff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c index 3beb4d9613..8161ccaec2 100644 --- a/drivers/net/ice/base/ice_flex_pipe.c +++ b/drivers/net/ice/base/ice_flex_pipe.c @@ -1873,6 +1873,28 @@ ice_find_free_tunnel_entry(struct ice_hw *hw, enum ice_tunnel_type type, return false; } +/** + * ice_get_tunnel_port - retrieve an open tunnel port + * @hw: pointer to the HW structure + * @type: tunnel type (TNL_ALL will return any open port) + * @port: returns open port + */ +bool +ice_get_open_tunnel_port(struct ice_hw *hw, enum ice_tunnel_type type, + u16 *port) +{ + u16 i; + + for (i = 0; i < hw->tnl.count && i < ICE_TUNNEL_MAX_ENTRIES; i++) + if (hw->tnl.tbl[i].valid && hw->tnl.tbl[i].in_use && + (type == TNL_ALL || hw->tnl.tbl[i].type == type)) { + *port = hw->tnl.tbl[i].port; + return true; + } + + return false; +} + /** * ice_create_tunnel * @hw: pointer to the HW structure diff --git a/drivers/net/ice/base/ice_flex_pipe.h b/drivers/net/ice/base/ice_flex_pipe.h index 17285efe04..ab16635747 100644 --- a/drivers/net/ice/base/ice_flex_pipe.h +++ b/drivers/net/ice/base/ice_flex_pipe.h @@ -36,6 +36,9 @@ ice_get_sw_fv_bitmap(struct ice_hw *hw, enum ice_prof_type type, enum ice_status ice_get_sw_fv_list(struct ice_hw *hw, u16 *prot_ids, u8 ids_cnt, ice_bitmap_t *bm, struct LIST_HEAD_TYPE *fv_list); +bool +ice_get_open_tunnel_port(struct ice_hw *hw, enum ice_tunnel_type type, + u16 *port); enum ice_status ice_create_tunnel(struct ice_hw *hw, enum ice_tunnel_type type, u16 port); enum ice_status ice_destroy_tunnel(struct ice_hw *hw, u16 port, bool all);