@@ -4578,6 +4578,15 @@ static const struct ice_prot_ext_tbl_entry ice_prot_ext[ICE_PROTOCOL_LAST] = {
4578
4578
ICE_PROTOCOL_ENTRY (ICE_L2TPV3 , 0 , 2 , 4 , 6 , 8 , 10 ),
4579
4579
ICE_PROTOCOL_ENTRY (ICE_VLAN_EX , 2 , 0 ),
4580
4580
ICE_PROTOCOL_ENTRY (ICE_VLAN_IN , 2 , 0 ),
4581
+ ICE_PROTOCOL_ENTRY (ICE_HW_METADATA ,
4582
+ ICE_SOURCE_PORT_MDID_OFFSET ,
4583
+ ICE_PTYPE_MDID_OFFSET ,
4584
+ ICE_PACKET_LENGTH_MDID_OFFSET ,
4585
+ ICE_SOURCE_VSI_MDID_OFFSET ,
4586
+ ICE_PKT_VLAN_MDID_OFFSET ,
4587
+ ICE_PKT_TUNNEL_MDID_OFFSET ,
4588
+ ICE_PKT_TCP_MDID_OFFSET ,
4589
+ ICE_PKT_ERROR_MDID_OFFSET ),
4581
4590
};
4582
4591
4583
4592
static struct ice_protocol_entry ice_prot_id_tbl [ICE_PROTOCOL_LAST ] = {
@@ -4602,6 +4611,7 @@ static struct ice_protocol_entry ice_prot_id_tbl[ICE_PROTOCOL_LAST] = {
4602
4611
{ ICE_L2TPV3 , ICE_L2TPV3_HW },
4603
4612
{ ICE_VLAN_EX , ICE_VLAN_OF_HW },
4604
4613
{ ICE_VLAN_IN , ICE_VLAN_OL_HW },
4614
+ { ICE_HW_METADATA , ICE_META_DATA_ID_HW },
4605
4615
};
4606
4616
4607
4617
/**
@@ -5260,72 +5270,6 @@ ice_create_recipe_group(struct ice_hw *hw, struct ice_sw_recipe *rm,
5260
5270
return status ;
5261
5271
}
5262
5272
5263
- /**
5264
- * ice_tun_type_match_word - determine if tun type needs a match mask
5265
- * @tun_type: tunnel type
5266
- * @mask: mask to be used for the tunnel
5267
- */
5268
- static bool ice_tun_type_match_word (enum ice_sw_tunnel_type tun_type , u16 * mask )
5269
- {
5270
- switch (tun_type ) {
5271
- case ICE_SW_TUN_GENEVE :
5272
- case ICE_SW_TUN_VXLAN :
5273
- case ICE_SW_TUN_NVGRE :
5274
- case ICE_SW_TUN_GTPU :
5275
- case ICE_SW_TUN_GTPC :
5276
- * mask = ICE_PKT_TUNNEL_MASK ;
5277
- return true;
5278
-
5279
- default :
5280
- * mask = 0 ;
5281
- return false;
5282
- }
5283
- }
5284
-
5285
- /**
5286
- * ice_add_special_words - Add words that are not protocols, such as metadata
5287
- * @rinfo: other information regarding the rule e.g. priority and action info
5288
- * @lkup_exts: lookup word structure
5289
- * @dvm_ena: is double VLAN mode enabled
5290
- */
5291
- static int
5292
- ice_add_special_words (struct ice_adv_rule_info * rinfo ,
5293
- struct ice_prot_lkup_ext * lkup_exts , bool dvm_ena )
5294
- {
5295
- u16 mask ;
5296
-
5297
- /* If this is a tunneled packet, then add recipe index to match the
5298
- * tunnel bit in the packet metadata flags.
5299
- */
5300
- if (ice_tun_type_match_word (rinfo -> tun_type , & mask )) {
5301
- if (lkup_exts -> n_val_words < ICE_MAX_CHAIN_WORDS ) {
5302
- u8 word = lkup_exts -> n_val_words ++ ;
5303
-
5304
- lkup_exts -> fv_words [word ].prot_id = ICE_META_DATA_ID_HW ;
5305
- lkup_exts -> fv_words [word ].off =
5306
- ICE_PKT_TUNNEL_MDID_OFFSET ;
5307
- lkup_exts -> field_mask [word ] = mask ;
5308
- } else {
5309
- return - ENOSPC ;
5310
- }
5311
- }
5312
-
5313
- if (rinfo -> vlan_type != 0 && dvm_ena ) {
5314
- if (lkup_exts -> n_val_words < ICE_MAX_CHAIN_WORDS ) {
5315
- u8 word = lkup_exts -> n_val_words ++ ;
5316
-
5317
- lkup_exts -> fv_words [word ].prot_id = ICE_META_DATA_ID_HW ;
5318
- lkup_exts -> fv_words [word ].off =
5319
- ICE_PKT_VLAN_MDID_OFFSET ;
5320
- lkup_exts -> field_mask [word ] = ICE_PKT_VLAN_MASK ;
5321
- } else {
5322
- return - ENOSPC ;
5323
- }
5324
- }
5325
-
5326
- return 0 ;
5327
- }
5328
-
5329
5273
/* ice_get_compat_fv_bitmap - Get compatible field vector bitmap for rule
5330
5274
* @hw: pointer to hardware structure
5331
5275
* @rinfo: other information regarding the rule e.g. priority and action info
@@ -5439,13 +5383,6 @@ ice_add_adv_recipe(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
5439
5383
if (status )
5440
5384
goto err_unroll ;
5441
5385
5442
- /* Create any special protocol/offset pairs, such as looking at tunnel
5443
- * bits by extracting metadata
5444
- */
5445
- status = ice_add_special_words (rinfo , lkup_exts , ice_is_dvm_ena (hw ));
5446
- if (status )
5447
- goto err_unroll ;
5448
-
5449
5386
/* Group match words into recipes using preferred recipe grouping
5450
5387
* criteria.
5451
5388
*/
@@ -5731,6 +5668,10 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
5731
5668
* was already checked when search for the dummy packet
5732
5669
*/
5733
5670
type = lkups [i ].type ;
5671
+ /* metadata isn't present in the packet */
5672
+ if (type == ICE_HW_METADATA )
5673
+ continue ;
5674
+
5734
5675
for (j = 0 ; offsets [j ].type != ICE_PROTOCOL_LAST ; j ++ ) {
5735
5676
if (type == offsets [j ].type ) {
5736
5677
offset = offsets [j ].offset ;
@@ -5866,16 +5807,21 @@ ice_fill_adv_packet_tun(struct ice_hw *hw, enum ice_sw_tunnel_type tun_type,
5866
5807
5867
5808
/**
5868
5809
* ice_fill_adv_packet_vlan - fill dummy packet with VLAN tag type
5810
+ * @hw: pointer to hw structure
5869
5811
* @vlan_type: VLAN tag type
5870
5812
* @pkt: dummy packet to fill in
5871
5813
* @offsets: offset info for the dummy packet
5872
5814
*/
5873
5815
static int
5874
- ice_fill_adv_packet_vlan (u16 vlan_type , u8 * pkt ,
5816
+ ice_fill_adv_packet_vlan (struct ice_hw * hw , u16 vlan_type , u8 * pkt ,
5875
5817
const struct ice_dummy_pkt_offsets * offsets )
5876
5818
{
5877
5819
u16 i ;
5878
5820
5821
+ /* Check if there is something to do */
5822
+ if (!vlan_type || !ice_is_dvm_ena (hw ))
5823
+ return 0 ;
5824
+
5879
5825
/* Find VLAN header and insert VLAN TPID */
5880
5826
for (i = 0 ; offsets [i ].type != ICE_PROTOCOL_LAST ; i ++ ) {
5881
5827
if (offsets [i ].type == ICE_VLAN_OFOS ||
@@ -5894,6 +5840,15 @@ ice_fill_adv_packet_vlan(u16 vlan_type, u8 *pkt,
5894
5840
return - EIO ;
5895
5841
}
5896
5842
5843
+ static bool ice_rules_equal (const struct ice_adv_rule_info * first ,
5844
+ const struct ice_adv_rule_info * second )
5845
+ {
5846
+ return first -> sw_act .flag == second -> sw_act .flag &&
5847
+ first -> tun_type == second -> tun_type &&
5848
+ first -> vlan_type == second -> vlan_type &&
5849
+ first -> src_vsi == second -> src_vsi ;
5850
+ }
5851
+
5897
5852
/**
5898
5853
* ice_find_adv_rule_entry - Search a rule entry
5899
5854
* @hw: pointer to the hardware structure
@@ -5927,9 +5882,7 @@ ice_find_adv_rule_entry(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
5927
5882
lkups_matched = false;
5928
5883
break ;
5929
5884
}
5930
- if (rinfo -> sw_act .flag == list_itr -> rule_info .sw_act .flag &&
5931
- rinfo -> tun_type == list_itr -> rule_info .tun_type &&
5932
- rinfo -> vlan_type == list_itr -> rule_info .vlan_type &&
5885
+ if (ice_rules_equal (rinfo , & list_itr -> rule_info ) &&
5933
5886
lkups_matched )
5934
5887
return list_itr ;
5935
5888
}
@@ -6045,6 +5998,20 @@ ice_adv_add_update_vsi_list(struct ice_hw *hw,
6045
5998
return status ;
6046
5999
}
6047
6000
6001
+ void ice_rule_add_tunnel_metadata (struct ice_adv_lkup_elem * lkup )
6002
+ {
6003
+ lkup -> type = ICE_HW_METADATA ;
6004
+ lkup -> m_u .metadata .flags [ICE_PKT_FLAGS_TUNNEL ] =
6005
+ cpu_to_be16 (ICE_PKT_TUNNEL_MASK );
6006
+ }
6007
+
6008
+ void ice_rule_add_vlan_metadata (struct ice_adv_lkup_elem * lkup )
6009
+ {
6010
+ lkup -> type = ICE_HW_METADATA ;
6011
+ lkup -> m_u .metadata .flags [ICE_PKT_FLAGS_VLAN ] =
6012
+ cpu_to_be16 (ICE_PKT_VLAN_MASK );
6013
+ }
6014
+
6048
6015
/**
6049
6016
* ice_add_adv_rule - helper function to create an advanced switch rule
6050
6017
* @hw: pointer to the hardware structure
@@ -6126,7 +6093,11 @@ ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
6126
6093
if (rinfo -> sw_act .fltr_act == ICE_FWD_TO_VSI )
6127
6094
rinfo -> sw_act .fwd_id .hw_vsi_id =
6128
6095
ice_get_hw_vsi_num (hw , vsi_handle );
6129
- rinfo -> sw_act .src = ice_get_hw_vsi_num (hw , vsi_handle );
6096
+
6097
+ if (rinfo -> src_vsi )
6098
+ rinfo -> sw_act .src = ice_get_hw_vsi_num (hw , rinfo -> src_vsi );
6099
+ else
6100
+ rinfo -> sw_act .src = ice_get_hw_vsi_num (hw , vsi_handle );
6130
6101
6131
6102
status = ice_add_adv_recipe (hw , lkups , lkups_cnt , rinfo , & rid );
6132
6103
if (status )
@@ -6217,22 +6188,16 @@ ice_add_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
6217
6188
if (status )
6218
6189
goto err_ice_add_adv_rule ;
6219
6190
6220
- if (rinfo -> tun_type != ICE_NON_TUN &&
6221
- rinfo -> tun_type != ICE_SW_TUN_AND_NON_TUN ) {
6222
- status = ice_fill_adv_packet_tun (hw , rinfo -> tun_type ,
6223
- s_rule -> hdr_data ,
6224
- profile -> offsets );
6225
- if (status )
6226
- goto err_ice_add_adv_rule ;
6227
- }
6191
+ status = ice_fill_adv_packet_tun (hw , rinfo -> tun_type , s_rule -> hdr_data ,
6192
+ profile -> offsets );
6193
+ if (status )
6194
+ goto err_ice_add_adv_rule ;
6228
6195
6229
- if (rinfo -> vlan_type != 0 && ice_is_dvm_ena (hw )) {
6230
- status = ice_fill_adv_packet_vlan (rinfo -> vlan_type ,
6231
- s_rule -> hdr_data ,
6232
- profile -> offsets );
6233
- if (status )
6234
- goto err_ice_add_adv_rule ;
6235
- }
6196
+ status = ice_fill_adv_packet_vlan (hw , rinfo -> vlan_type ,
6197
+ s_rule -> hdr_data ,
6198
+ profile -> offsets );
6199
+ if (status )
6200
+ goto err_ice_add_adv_rule ;
6236
6201
6237
6202
status = ice_aq_sw_rules (hw , (struct ice_aqc_sw_rules * )s_rule ,
6238
6203
rule_buf_sz , 1 , ice_aqc_opc_add_sw_rules ,
@@ -6475,13 +6440,6 @@ ice_rem_adv_rule(struct ice_hw *hw, struct ice_adv_lkup_elem *lkups,
6475
6440
return - EIO ;
6476
6441
}
6477
6442
6478
- /* Create any special protocol/offset pairs, such as looking at tunnel
6479
- * bits by extracting metadata
6480
- */
6481
- status = ice_add_special_words (rinfo , & lkup_exts , ice_is_dvm_ena (hw ));
6482
- if (status )
6483
- return status ;
6484
-
6485
6443
rid = ice_find_recp (hw , & lkup_exts , rinfo -> tun_type );
6486
6444
/* If did not find a recipe that match the existing criteria */
6487
6445
if (rid == ICE_MAX_NUM_RECIPES )
0 commit comments