@@ -81,19 +81,9 @@ static struct ch_tc_flower_entry *ch_flower_lookup(struct adapter *adap,
81
81
}
82
82
83
83
static void cxgb4_process_flow_match (struct net_device * dev ,
84
- struct flow_cls_offload * cls ,
84
+ struct flow_rule * rule ,
85
85
struct ch_filter_specification * fs )
86
86
{
87
- struct flow_rule * rule = flow_cls_offload_flow_rule (cls );
88
- u16 addr_type = 0 ;
89
-
90
- if (flow_rule_match_key (rule , FLOW_DISSECTOR_KEY_CONTROL )) {
91
- struct flow_match_control match ;
92
-
93
- flow_rule_match_control (rule , & match );
94
- addr_type = match .key -> addr_type ;
95
- }
96
-
97
87
if (flow_rule_match_key (rule , FLOW_DISSECTOR_KEY_BASIC )) {
98
88
struct flow_match_basic match ;
99
89
u16 ethtype_key , ethtype_mask ;
@@ -116,7 +106,7 @@ static void cxgb4_process_flow_match(struct net_device *dev,
116
106
fs -> mask .proto = match .mask -> ip_proto ;
117
107
}
118
108
119
- if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS ) {
109
+ if (flow_rule_match_key ( rule , FLOW_DISSECTOR_KEY_IPV4_ADDRS ) ) {
120
110
struct flow_match_ipv4_addrs match ;
121
111
122
112
flow_rule_match_ipv4_addrs (rule , & match );
@@ -131,7 +121,7 @@ static void cxgb4_process_flow_match(struct net_device *dev,
131
121
memcpy (& fs -> nat_fip [0 ], & match .key -> src , sizeof (match .key -> src ));
132
122
}
133
123
134
- if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS ) {
124
+ if (flow_rule_match_key ( rule , FLOW_DISSECTOR_KEY_IPV6_ADDRS ) ) {
135
125
struct flow_match_ipv6_addrs match ;
136
126
137
127
flow_rule_match_ipv6_addrs (rule , & match );
@@ -224,9 +214,8 @@ static void cxgb4_process_flow_match(struct net_device *dev,
224
214
}
225
215
226
216
static int cxgb4_validate_flow_match (struct net_device * dev ,
227
- struct flow_cls_offload * cls )
217
+ struct flow_rule * rule )
228
218
{
229
- struct flow_rule * rule = flow_cls_offload_flow_rule (cls );
230
219
struct flow_dissector * dissector = rule -> match .dissector ;
231
220
u16 ethtype_mask = 0 ;
232
221
u16 ethtype_key = 0 ;
@@ -693,33 +682,22 @@ static void cxgb4_tc_flower_hash_prio_del(struct adapter *adap, u32 tc_prio)
693
682
spin_unlock_bh (& t -> ftid_lock );
694
683
}
695
684
696
- int cxgb4_tc_flower_replace (struct net_device * dev ,
697
- struct flow_cls_offload * cls )
685
+ int cxgb4_flow_rule_replace (struct net_device * dev , struct flow_rule * rule ,
686
+ u32 tc_prio , struct netlink_ext_ack * extack ,
687
+ struct ch_filter_specification * fs , u32 * tid )
698
688
{
699
- struct flow_rule * rule = flow_cls_offload_flow_rule (cls );
700
- struct netlink_ext_ack * extack = cls -> common .extack ;
701
689
struct adapter * adap = netdev2adap (dev );
702
- struct ch_tc_flower_entry * ch_flower ;
703
- struct ch_filter_specification * fs ;
704
690
struct filter_ctx ctx ;
705
691
u8 inet_family ;
706
692
int fidx , ret ;
707
693
708
694
if (cxgb4_validate_flow_actions (dev , & rule -> action , extack ))
709
695
return - EOPNOTSUPP ;
710
696
711
- if (cxgb4_validate_flow_match (dev , cls ))
697
+ if (cxgb4_validate_flow_match (dev , rule ))
712
698
return - EOPNOTSUPP ;
713
699
714
- ch_flower = allocate_flower_entry ();
715
- if (!ch_flower ) {
716
- netdev_err (dev , "%s: ch_flower alloc failed.\n" , __func__ );
717
- return - ENOMEM ;
718
- }
719
-
720
- fs = & ch_flower -> fs ;
721
- fs -> hitcnts = 1 ;
722
- cxgb4_process_flow_match (dev , cls , fs );
700
+ cxgb4_process_flow_match (dev , rule , fs );
723
701
cxgb4_process_flow_actions (dev , & rule -> action , fs );
724
702
725
703
fs -> hash = is_filter_exact_match (adap , fs );
@@ -730,12 +708,11 @@ int cxgb4_tc_flower_replace(struct net_device *dev,
730
708
* existing rules.
731
709
*/
732
710
fidx = cxgb4_get_free_ftid (dev , inet_family , fs -> hash ,
733
- cls -> common . prio );
711
+ tc_prio );
734
712
if (fidx < 0 ) {
735
713
NL_SET_ERR_MSG_MOD (extack ,
736
714
"No free LETCAM index available" );
737
- ret = - ENOMEM ;
738
- goto free_entry ;
715
+ return - ENOMEM ;
739
716
}
740
717
741
718
if (fidx < adap -> tids .nhpftids ) {
@@ -749,42 +726,70 @@ int cxgb4_tc_flower_replace(struct net_device *dev,
749
726
if (fs -> hash )
750
727
fidx = 0 ;
751
728
752
- fs -> tc_prio = cls -> common .prio ;
753
- fs -> tc_cookie = cls -> cookie ;
729
+ fs -> tc_prio = tc_prio ;
754
730
755
731
init_completion (& ctx .completion );
756
732
ret = __cxgb4_set_filter (dev , fidx , fs , & ctx );
757
733
if (ret ) {
758
734
netdev_err (dev , "%s: filter creation err %d\n" ,
759
735
__func__ , ret );
760
- goto free_entry ;
736
+ return ret ;
761
737
}
762
738
763
739
/* Wait for reply */
764
740
ret = wait_for_completion_timeout (& ctx .completion , 10 * HZ );
765
- if (!ret ) {
766
- ret = - ETIMEDOUT ;
767
- goto free_entry ;
768
- }
741
+ if (!ret )
742
+ return - ETIMEDOUT ;
769
743
770
- ret = ctx .result ;
771
744
/* Check if hw returned error for filter creation */
745
+ if (ctx .result )
746
+ return ctx .result ;
747
+
748
+ * tid = ctx .tid ;
749
+
750
+ if (fs -> hash )
751
+ cxgb4_tc_flower_hash_prio_add (adap , tc_prio );
752
+
753
+ return 0 ;
754
+ }
755
+
756
+ int cxgb4_tc_flower_replace (struct net_device * dev ,
757
+ struct flow_cls_offload * cls )
758
+ {
759
+ struct flow_rule * rule = flow_cls_offload_flow_rule (cls );
760
+ struct netlink_ext_ack * extack = cls -> common .extack ;
761
+ struct adapter * adap = netdev2adap (dev );
762
+ struct ch_tc_flower_entry * ch_flower ;
763
+ struct ch_filter_specification * fs ;
764
+ int ret ;
765
+
766
+ ch_flower = allocate_flower_entry ();
767
+ if (!ch_flower ) {
768
+ netdev_err (dev , "%s: ch_flower alloc failed.\n" , __func__ );
769
+ return - ENOMEM ;
770
+ }
771
+
772
+ fs = & ch_flower -> fs ;
773
+ fs -> hitcnts = 1 ;
774
+ fs -> tc_cookie = cls -> cookie ;
775
+
776
+ ret = cxgb4_flow_rule_replace (dev , rule , cls -> common .prio , extack , fs ,
777
+ & ch_flower -> filter_id );
772
778
if (ret )
773
779
goto free_entry ;
774
780
775
781
ch_flower -> tc_flower_cookie = cls -> cookie ;
776
- ch_flower -> filter_id = ctx .tid ;
777
782
ret = rhashtable_insert_fast (& adap -> flower_tbl , & ch_flower -> node ,
778
783
adap -> flower_ht_params );
779
784
if (ret )
780
785
goto del_filter ;
781
786
782
- if (fs -> hash )
783
- cxgb4_tc_flower_hash_prio_add (adap , cls -> common .prio );
784
-
785
787
return 0 ;
786
788
787
789
del_filter :
790
+ if (fs -> hash )
791
+ cxgb4_tc_flower_hash_prio_del (adap , cls -> common .prio );
792
+
788
793
cxgb4_del_filter (dev , ch_flower -> filter_id , & ch_flower -> fs );
789
794
790
795
free_entry :
0 commit comments