@@ -265,6 +265,8 @@ static int validate_filter(struct net_device *dev,
265265 fs -> mask .pfvf_vld ) ||
266266 unsupported (fconf , VNIC_ID_F , fs -> val .ovlan_vld ,
267267 fs -> mask .ovlan_vld ) ||
268+ unsupported (fconf , VNIC_ID_F , fs -> val .encap_vld ,
269+ fs -> mask .encap_vld ) ||
268270 unsupported (fconf , VLAN_F , fs -> val .ivlan_vld , fs -> mask .ivlan_vld ))
269271 return - EOPNOTSUPP ;
270272
@@ -275,8 +277,12 @@ static int validate_filter(struct net_device *dev,
275277 * carries that overlap, we need to translate any PF/VF
276278 * specification into that internal format below.
277279 */
278- if (is_field_set (fs -> val .pfvf_vld , fs -> mask .pfvf_vld ) &&
279- is_field_set (fs -> val .ovlan_vld , fs -> mask .ovlan_vld ))
280+ if ((is_field_set (fs -> val .pfvf_vld , fs -> mask .pfvf_vld ) &&
281+ is_field_set (fs -> val .ovlan_vld , fs -> mask .ovlan_vld )) ||
282+ (is_field_set (fs -> val .pfvf_vld , fs -> mask .pfvf_vld ) &&
283+ is_field_set (fs -> val .encap_vld , fs -> mask .encap_vld )) ||
284+ (is_field_set (fs -> val .ovlan_vld , fs -> mask .ovlan_vld ) &&
285+ is_field_set (fs -> val .encap_vld , fs -> mask .encap_vld )))
280286 return - EOPNOTSUPP ;
281287 if (unsupported (iconf , VNIC_F , fs -> val .pfvf_vld , fs -> mask .pfvf_vld ) ||
282288 (is_field_set (fs -> val .ovlan_vld , fs -> mask .ovlan_vld ) &&
@@ -306,6 +312,9 @@ static int validate_filter(struct net_device *dev,
306312 fs -> newvlan == VLAN_REWRITE ))
307313 return - EOPNOTSUPP ;
308314
315+ if (fs -> val .encap_vld &&
316+ CHELSIO_CHIP_VERSION (adapter -> params .chip ) < CHELSIO_T6 )
317+ return - EOPNOTSUPP ;
309318 return 0 ;
310319}
311320
@@ -705,6 +714,8 @@ int delete_filter(struct adapter *adapter, unsigned int fidx)
705714 */
706715void clear_filter (struct adapter * adap , struct filter_entry * f )
707716{
717+ struct port_info * pi = netdev_priv (f -> dev );
718+
708719 /* If the new or old filter have loopback rewriteing rules then we'll
709720 * need to free any existing L2T, SMT, CLIP entries of filter
710721 * rule.
@@ -715,6 +726,12 @@ void clear_filter(struct adapter *adap, struct filter_entry *f)
715726 if (f -> smt )
716727 cxgb4_smt_release (f -> smt );
717728
729+ if (f -> fs .val .encap_vld && f -> fs .val .ovlan_vld )
730+ if (atomic_dec_and_test (& adap -> mps_encap [f -> fs .val .ovlan &
731+ 0x1ff ].refcnt ))
732+ t4_free_encap_mac_filt (adap , pi -> viid ,
733+ f -> fs .val .ovlan & 0x1ff , 0 );
734+
718735 if ((f -> fs .hash || is_t6 (adap -> params .chip )) && f -> fs .type )
719736 cxgb4_clip_release (f -> dev , (const u32 * )& f -> fs .val .lip , 1 );
720737
@@ -840,6 +857,10 @@ bool is_filter_exact_match(struct adapter *adap,
840857 if (!is_hashfilter (adap ))
841858 return false;
842859
860+ /* Keep tunnel VNI match disabled for hash-filters for now */
861+ if (fs -> mask .encap_vld )
862+ return false;
863+
843864 if (fs -> type ) {
844865 if (is_inaddr_any (fs -> val .fip , AF_INET6 ) ||
845866 !is_addr_all_mask (fs -> mask .fip , AF_INET6 ))
@@ -961,8 +982,12 @@ static u64 hash_filter_ntuple(struct ch_filter_specification *fs,
961982 ntuple |= (u64 )(fs -> val .tos ) << tp -> tos_shift ;
962983
963984 if (tp -> vnic_shift >= 0 ) {
964- if ((adap -> params .tp .ingress_config & VNIC_F ) &&
965- fs -> mask .pfvf_vld )
985+ if ((adap -> params .tp .ingress_config & USE_ENC_IDX_F ) &&
986+ fs -> mask .encap_vld )
987+ ntuple |= (u64 )((fs -> val .encap_vld << 16 ) |
988+ (fs -> val .ovlan )) << tp -> vnic_shift ;
989+ else if ((adap -> params .tp .ingress_config & VNIC_F ) &&
990+ fs -> mask .pfvf_vld )
966991 ntuple |= (u64 )((fs -> val .pfvf_vld << 16 ) |
967992 (fs -> val .pf << 13 ) |
968993 (fs -> val .vf )) << tp -> vnic_shift ;
@@ -1076,6 +1101,7 @@ static int cxgb4_set_hash_filter(struct net_device *dev,
10761101 struct filter_ctx * ctx )
10771102{
10781103 struct adapter * adapter = netdev2adap (dev );
1104+ struct port_info * pi = netdev_priv (dev );
10791105 struct tid_info * t = & adapter -> tids ;
10801106 struct filter_entry * f ;
10811107 struct sk_buff * skb ;
@@ -1142,13 +1168,34 @@ static int cxgb4_set_hash_filter(struct net_device *dev,
11421168 f -> fs .mask .ovlan = (fs -> mask .pf << 13 ) | fs -> mask .vf ;
11431169 f -> fs .val .ovlan_vld = fs -> val .pfvf_vld ;
11441170 f -> fs .mask .ovlan_vld = fs -> mask .pfvf_vld ;
1171+ } else if (iconf & USE_ENC_IDX_F ) {
1172+ if (f -> fs .val .encap_vld ) {
1173+ struct port_info * pi = netdev_priv (f -> dev );
1174+ u8 match_all_mac [] = { 0 , 0 , 0 , 0 , 0 , 0 };
1175+
1176+ /* allocate MPS TCAM entry */
1177+ ret = t4_alloc_encap_mac_filt (adapter , pi -> viid ,
1178+ match_all_mac ,
1179+ match_all_mac ,
1180+ f -> fs .val .vni ,
1181+ f -> fs .mask .vni ,
1182+ 0 , 1 , 1 );
1183+ if (ret < 0 )
1184+ goto free_atid ;
1185+
1186+ atomic_inc (& adapter -> mps_encap [ret ].refcnt );
1187+ f -> fs .val .ovlan = ret ;
1188+ f -> fs .mask .ovlan = 0xffff ;
1189+ f -> fs .val .ovlan_vld = 1 ;
1190+ f -> fs .mask .ovlan_vld = 1 ;
1191+ }
11451192 }
11461193
11471194 size = sizeof (struct cpl_t6_act_open_req );
11481195 if (f -> fs .type ) {
11491196 ret = cxgb4_clip_get (f -> dev , (const u32 * )& f -> fs .val .lip , 1 );
11501197 if (ret )
1151- goto free_atid ;
1198+ goto free_mps ;
11521199
11531200 skb = alloc_skb (size , GFP_KERNEL );
11541201 if (!skb ) {
@@ -1163,7 +1210,7 @@ static int cxgb4_set_hash_filter(struct net_device *dev,
11631210 skb = alloc_skb (size , GFP_KERNEL );
11641211 if (!skb ) {
11651212 ret = - ENOMEM ;
1166- goto free_atid ;
1213+ goto free_mps ;
11671214 }
11681215
11691216 mk_act_open_req (f , skb ,
@@ -1179,6 +1226,10 @@ static int cxgb4_set_hash_filter(struct net_device *dev,
11791226free_clip :
11801227 cxgb4_clip_release (f -> dev , (const u32 * )& f -> fs .val .lip , 1 );
11811228
1229+ free_mps :
1230+ if (f -> fs .val .encap_vld && f -> fs .val .ovlan_vld )
1231+ t4_free_encap_mac_filt (adapter , pi -> viid , f -> fs .val .ovlan , 1 );
1232+
11821233free_atid :
11831234 cxgb4_free_atid (t , atid );
11841235
@@ -1360,6 +1411,27 @@ int __cxgb4_set_filter(struct net_device *dev, int filter_id,
13601411 f -> fs .mask .ovlan = (fs -> mask .pf << 13 ) | fs -> mask .vf ;
13611412 f -> fs .val .ovlan_vld = fs -> val .pfvf_vld ;
13621413 f -> fs .mask .ovlan_vld = fs -> mask .pfvf_vld ;
1414+ } else if (iconf & USE_ENC_IDX_F ) {
1415+ if (f -> fs .val .encap_vld ) {
1416+ struct port_info * pi = netdev_priv (f -> dev );
1417+ u8 match_all_mac [] = { 0 , 0 , 0 , 0 , 0 , 0 };
1418+
1419+ /* allocate MPS TCAM entry */
1420+ ret = t4_alloc_encap_mac_filt (adapter , pi -> viid ,
1421+ match_all_mac ,
1422+ match_all_mac ,
1423+ f -> fs .val .vni ,
1424+ f -> fs .mask .vni ,
1425+ 0 , 1 , 1 );
1426+ if (ret < 0 )
1427+ goto free_clip ;
1428+
1429+ atomic_inc (& adapter -> mps_encap [ret ].refcnt );
1430+ f -> fs .val .ovlan = ret ;
1431+ f -> fs .mask .ovlan = 0x1ff ;
1432+ f -> fs .val .ovlan_vld = 1 ;
1433+ f -> fs .mask .ovlan_vld = 1 ;
1434+ }
13631435 }
13641436
13651437 /* Attempt to set the filter. If we don't succeed, we clear
@@ -1376,6 +1448,13 @@ int __cxgb4_set_filter(struct net_device *dev, int filter_id,
13761448 }
13771449
13781450 return ret ;
1451+
1452+ free_clip :
1453+ if (is_t6 (adapter -> params .chip ) && f -> fs .type )
1454+ cxgb4_clip_release (f -> dev , (const u32 * )& f -> fs .val .lip , 1 );
1455+ cxgb4_clear_ftid (& adapter -> tids , filter_id ,
1456+ fs -> type ? PF_INET6 : PF_INET , chip_ver );
1457+ return ret ;
13791458}
13801459
13811460static int cxgb4_del_hash_filter (struct net_device * dev , int filter_id ,
0 commit comments