@@ -215,7 +215,7 @@ enum ice_prot_id {
*/
#define ICE_UDP_OF_HW 52 /* UDP Tunnels */
#define ICE_GRE_OF_HW 64 /* NVGRE */
-#define ICE_META_DATA_ID_HW 255 /* this is used for tunnel type */
+#define ICE_META_DATA_ID_HW 255 /* this is used for tunnel and VLAN type */
#define ICE_MDID_SIZE 2
#define ICE_TUN_FLAG_MDID 20
@@ -226,6 +226,10 @@ enum ice_prot_id {
#define ICE_TUN_FLAG_VLAN_MASK 0x01
#define ICE_TUN_FLAG_FV_IND 2
+#define ICE_VLAN_FLAG_MDID 20
+#define ICE_VLAN_FLAG_MDID_OFF (ICE_MDID_SIZE * ICE_VLAN_FLAG_MDID)
+#define ICE_PKT_FLAGS_0_TO_15_VLAN_FLAGS_MASK 0xD000
+
#define ICE_PROTOCOL_MAX_ENTRIES 16
/* Mapping of software defined protocol ID to hardware defined protocol ID */
@@ -7502,13 +7502,14 @@ ice_create_recipe_group(struct ice_hw *hw, struct ice_sw_recipe *rm,
/**
* ice_tun_type_match_word - determine if tun type needs a match mask
- * @tun_type: tunnel type
+ * @rinfo: other information regarding the rule e.g. priority and action info
* @off: offset of packet flag
* @mask: mask to be used for the tunnel
*/
-static bool ice_tun_type_match_word(enum ice_sw_tunnel_type tun_type, u16 *off, u16 *mask)
+static bool
+ice_tun_type_match_word(struct ice_adv_rule_info *rinfo, u16 *off, u16 *mask)
{
- switch (tun_type) {
+ switch (rinfo->tun_type) {
case ICE_SW_TUN_VXLAN_GPE:
case ICE_SW_TUN_GENEVE:
case ICE_SW_TUN_VXLAN:
@@ -7526,9 +7527,14 @@ static bool ice_tun_type_match_word(enum ice_sw_tunnel_type tun_type, u16 *off,
return true;
case ICE_SW_TUN_AND_NON_TUN:
- *mask = ICE_DIR_FLAG_MASK;
- *off = ICE_TUN_FLAG_MDID_OFF(0);
- return true;
+ if (rinfo->add_dir_lkup) {
+ *mask = ICE_DIR_FLAG_MASK;
+ *off = ICE_TUN_FLAG_MDID_OFF(0);
+ return true;
+ }
+ *mask = 0;
+ *off = 0;
+ return false;
case ICE_SW_TUN_GENEVE_VLAN:
case ICE_SW_TUN_VXLAN_VLAN:
@@ -7548,10 +7554,11 @@ static bool ice_tun_type_match_word(enum ice_sw_tunnel_type tun_type, u16 *off,
* ice_add_special_words - Add words that are not protocols, such as metadata
* @rinfo: other information regarding the rule e.g. priority and action info
* @lkup_exts: lookup word structure
+ * @dvm_ena: is double VLAN mode enabled
*/
static enum ice_status
ice_add_special_words(struct ice_adv_rule_info *rinfo,
- struct ice_prot_lkup_ext *lkup_exts)
+ struct ice_prot_lkup_ext *lkup_exts, bool dvm_ena)
{
u16 mask;
u16 off;
@@ -7560,7 +7567,7 @@ ice_add_special_words(struct ice_adv_rule_info *rinfo,
* tunnel bit in the packet metadata flags. If this is a tun_and_non_tun
* packet, then add recipe index to match the direction bit in the flag.
*/
- if (ice_tun_type_match_word(rinfo->tun_type, &off, &mask)) {
+ if (ice_tun_type_match_word(rinfo, &off, &mask)) {
if (lkup_exts->n_val_words < ICE_MAX_CHAIN_WORDS) {
u8 word = lkup_exts->n_val_words++;
@@ -7572,6 +7579,19 @@ ice_add_special_words(struct ice_adv_rule_info *rinfo,
}
}
+ if (rinfo->vlan_type != 0 && dvm_ena) {
+ if (lkup_exts->n_val_words < ICE_MAX_CHAIN_WORDS) {
+ u8 word = lkup_exts->n_val_words++;
+
+ lkup_exts->fv_words[word].prot_id = ICE_META_DATA_ID_HW;
+ lkup_exts->fv_words[word].off = ICE_VLAN_FLAG_MDID_OFF;
+ lkup_exts->field_mask[word] =
+ ICE_PKT_FLAGS_0_TO_15_VLAN_FLAGS_MASK;
+ } else {
+ return ICE_ERR_MAX_LIMIT;
+ }
+ }
+
return ICE_SUCCESS;
}
@@ -7898,7 +7918,7 @@ ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
/* Create any special protocol/offset pairs, such as looking at tunnel
* bits by extracting metadata
*/
- status = ice_add_special_words(rinfo, lkup_exts);
+ status = ice_add_special_words(rinfo, lkup_exts, ice_is_dvm_ena(hw));
if (status)
goto err_free_lkup_exts;
@@ -8745,6 +8765,7 @@ ice_find_adv_rule_entry(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
}
if (rinfo->sw_act.flag == list_itr->rule_info.sw_act.flag &&
rinfo->tun_type == list_itr->rule_info.tun_type &&
+ rinfo->vlan_type == list_itr->rule_info.vlan_type &&
lkups_matched)
return list_itr;
}
@@ -9240,6 +9261,7 @@ ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
} else {
adv_fltr->lkups = NULL;
}
+
if (!adv_fltr->lkups && !prof_rule) {
status = ICE_ERR_NO_MEMORY;
goto err_ice_add_adv_rule;
@@ -9410,7 +9432,7 @@ ice_rem_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
/* Create any special protocol/offset pairs, such as looking at tunnel
* bits by extracting metadata
*/
- status = ice_add_special_words(rinfo, &lkup_exts);
+ status = ice_add_special_words(rinfo, &lkup_exts, ice_is_dvm_ena(hw));
if (status)
return status;
@@ -300,6 +300,7 @@ struct ice_adv_rule_info {
struct ice_sw_act_ctrl sw_act;
u32 priority;
u8 rx; /* true means LOOKUP_RX otherwise LOOKUP_TX */
+ u8 add_dir_lkup;
u16 fltr_rule_id;
u16 lg_id;
u16 vlan_type;