cxgb4: add TC-MATCHALL classifier offload
Subsystems (3)
v5 cover cxgb4: add TC-MATCHALL classifier offload
This series of patches add support to offload TC-MATCHALL classifier to hardware to classify all outgoing and incoming traffic on the underlying port. Only 1 egress and 1 ingress rule each can be offloaded on the underlying port.
Patch 1 adds support for TC-MATCHALL classifier offload on the egress side. TC-POLICE is the only action that can be offloaded on the egress side and is used to rate limit all outgoing traffic to specified max rate.
Patch 2 adds logic to reject the current rule offload if its priority conflicts with existing rules in the TCAM.
Patch 3 adds support for TC-MATCHALL classifier offload on the ingress side. The same set of actions supported by existing TC-FLOWER classifier offload can be applied on all the incoming traffic.
Thanks,
Rahul
v5:
- Fixed commit message and comment to include comparison for equal priority in patch 2.
v4:
- Removed check in patch 1 to reject police offload if prio is not 1.
- Moved TC_SETUP_BLOCK code to separate function in patch 1.
- Added logic to ensure the prio passed by TC doesn't conflict with other rules in TCAM in patch 2.
- Higher index has lower priority than lower index in TCAM. So, rework cxgb4_get_free_ftid() to search free index from end of TCAM in descending order in patch 2.
- Added check to ensure the matchall rule's prio doesn't conflict with other rules in TCAM in patch 3.
- Added logic to fill default mask for VIID, if none has been provided, to prevent conflict with duplicate VIID rules in patch 3.
- Used existing variables in private structure to fill VIID info, instead of extracting the info manually in patch 3.
v3:
- Added check in patch 1 to reject police offload if prio is not 1.
- Assign block_shared variable only for TC_SETUP_BLOCK in patch 1.
v2:
- Added check to reject flow block sharing for policers in patch 1.
- Removed logic to fetch free index from end of TCAM in patch 2. Must maintain the same ordering as in kernel.
Rahul Lakkireddy (3):
cxgb4: add TC-MATCHALL classifier egress offload
cxgb4: check rule prio conflicts before offload
cxgb4: add TC-MATCHALL classifier ingress offload
drivers/net/ethernet/chelsio/cxgb4/Makefile | 3 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 11 +- .../net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 120 ++++-- .../net/ethernet/chelsio/cxgb4/cxgb4_filter.h | 1 + .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 91 ++++- .../ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 52 ++- .../ethernet/chelsio/cxgb4/cxgb4_tc_flower.h | 6 + .../chelsio/cxgb4/cxgb4_tc_matchall.c | 354 ++++++++++++++++++ .../chelsio/cxgb4/cxgb4_tc_matchall.h | 49 +++ .../ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.c | 5 +- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c | 36 +- drivers/net/ethernet/chelsio/cxgb4/sched.c | 56 ++- drivers/net/ethernet/chelsio/cxgb4/sched.h | 1 + drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 11 +- 14 files changed, 708 insertions(+), 88 deletions(-) create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.h
Signature · 1 line
2.24.0
PATCH v5 1/3 cxgb4: add TC-MATCHALL classifier egress offload
Add TC-MATCHALL classifier offload with TC-POLICE action applied for all outgoing traffic on the underlying interface. Split flow block offload to support both egress and ingress classification.
For example, to rate limit all outgoing traffic to 1 Gbps:
$ tc qdisc add dev enp2s0f4 clsact $ tc filter add dev enp2s0f4 egress matchall skip_sw \ action police rate 1Gbit burst 8Kbit
Note that skip_sw is important. Otherwise, both stack and hardware will end up doing policing. Policing can't be shared across flow blocks. Only 1 egress matchall rule can be active at a time on the underlying interface.
v5:
- No change.
v4:
- Removed check to reject police offload if prio is not 1.
- Moved TC_SETUP_BLOCK code to separate function.
v3:
- Added check to reject police offload if prio is not 1.
- Assign block_shared variable only for TC_SETUP_BLOCK.
v2:
- Added check to reject flow block sharing for policers.
--- drivers/net/ethernet/chelsio/cxgb4/Makefile | 3 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 6 + .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 84 ++++++- .../chelsio/cxgb4/cxgb4_tc_matchall.c | 213 ++++++++++++++++++ .../chelsio/cxgb4/cxgb4_tc_matchall.h | 35 +++ .../ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.c | 5 +- drivers/net/ethernet/chelsio/cxgb4/sched.c | 56 +++-- drivers/net/ethernet/chelsio/cxgb4/sched.h | 1 + drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 11 +- 9 files changed, 381 insertions(+), 33 deletions(-) create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c create mode 100644 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.h
drivers/net/ethernet/chelsio/cxgb4/Makefile +2 -1
@@ -8,7 +8,8 @@ obj-$(CONFIG_CHELSIO_T4) += cxgb4.o cxgb4-objs := cxgb4_main.o l2t.o smt.o t4_hw.o sge.o clip_tbl.o cxgb4_ethtool.o \ cxgb4_uld.o srq.o sched.o cxgb4_filter.o cxgb4_tc_u32.o \ cxgb4_ptp.o cxgb4_tc_flower.o cxgb4_cudbg.o cxgb4_mps.o \ - cudbg_common.o cudbg_lib.o cudbg_zlib.o cxgb4_tc_mqprio.o + cudbg_common.o cudbg_lib.o cudbg_zlib.o cxgb4_tc_mqprio.o \ + cxgb4_tc_matchall.o cxgb4-$(CONFIG_CHELSIO_T4_DCB) += cxgb4_dcb.o cxgb4-$(CONFIG_CHELSIO_T4_FCOE) += cxgb4_fcoe.o cxgb4-$(CONFIG_DEBUG_FS) += cxgb4_debugfs.o
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +6 -0
@@ -603,6 +603,8 @@ struct port_info {u8 vivld;u8 smt_idx;u8 rx_cchan; + +bool tc_block_shared; };struct dentry ;
@@ -1101,6 +1103,9 @@ struct adapter {/* TC MQPRIO offload */ struct cxgb4_tc_mqprio *tc_mqprio; + +/* TC MATCHALL classifier offload */ +struct cxgb4_tc_matchall *tc_matchall; };/* Support for "sched-class" command to allow a TX Scheduling Class to be
@@ -1130,6 +1135,7 @@ enum {enum {SCHED_CLASS_LEVEL_CL_RL =0 ,/* class rate limiter */ +SCHED_CLASS_LEVEL_CH_RL =2 ,/* channel rate limiter */ };enum {
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +76 -8
127 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c new file +213 -0
213 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* Copyright (C) 2019 Chelsio Communications. All rights reserved. */ + +#ifndef __CXGB4_TC_MATCHALL_H__ +#define __CXGB4_TC_MATCHALL_H__ + +#include <net/pkt_cls.h> + +enum cxgb4_matchall_state { +CXGB4_MATCHALL_STATE_DISABLED =0 , +CXGB4_MATCHALL_STATE_ENABLED , +}; + +struct cxgb4_matchall_egress_entry { +enum cxgb4_matchall_state state;/* Current MATCHALL offload state */ +u8 hwtc;/* Traffic class bound to port */ +u64 cookie;/* Used to identify the MATCHALL rule offloaded */ +}; + +struct cxgb4_tc_port_matchall { +struct cxgb4_matchall_egress_entry egress;/* Egress offload info */ +}; + +struct cxgb4_tc_matchall { +struct cxgb4_tc_port_matchall *port_matchall;/* Per port entry */ +}; + +int cxgb4_tc_matchall_replace (struct net_device *dev, +struct tc_cls_matchall_offload *cls_matchall); +int cxgb4_tc_matchall_destroy (struct net_device *dev, +struct tc_cls_matchall_offload *cls_matchall); + +int cxgb4_init_tc_matchall (struct adapter *adap); +void cxgb4_cleanup_tc_matchall (struct adapter *adap); +#endif /* __CXGB4_TC_MATCHALL_H__ */
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_mqprio.c +2 -3
@@ -11,8 +11,7 @@ static int cxgb4_mqprio_validate(struct net_device *dev,u64 min_rate =0 , max_rate =0 , max_link_rate;struct port_info *pi =netdev2pinfo (dev);struct adapter *adap =netdev2adap (dev); -u32 qcount =0 , qoffset =0 ; -u32 link_ok, speed, mtu; +u32 speed, qcount =0 , qoffset =0 ;int ret;u8 i;
@@ -35,7 +34,7 @@ static int cxgb4_mqprio_validate(struct net_device *dev,return -ERANGE ; } - ret =t4_get_link_params (pi, &link_ok, &speed, &mtu); + ret =t4_get_link_params (pi,NULL , &speed,NULL );if (ret) {netdev_err (dev,"Failed to get link speed, ret: %d\n" , ret);return -EINVAL ;
drivers/net/ethernet/chelsio/cxgb4/sched.c +39 -17
102 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/sched.h +1 -0
@@ -52,6 +52,7 @@ enum {enum sched_fw_ops {SCHED_FW_OP_ADD , +SCHED_FW_OP_DEL , };enum sched_bind_type {
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +7 -4
@@ -8777,8 +8777,8 @@ int t4_get_link_params(struct port_info *pi, unsigned int *link_okp, unsigned int *speedp, unsigned int *mtup) { unsigned int fw_caps = pi->adapter->params.fw_caps_support; -struct fw_port_cmd port_cmd;unsigned int action, link_ok, mtu; +struct fw_port_cmd port_cmd;fw_port_cap32_t linkattr;int ret;
@@ -8813,9 +8813,12 @@ int t4_get_link_params(struct port_info *pi, unsigned int *link_okp, be32_to_cpu(port_cmd.u.info32.auxlinfo32_mtu32)); } - *link_okp = link_ok; - *speedp =fwcap_to_speed (linkattr); - *mtup = mtu; +if (link_okp) + *link_okp = link_ok; +if (speedp) + *speedp =fwcap_to_speed (linkattr); +if (mtup) + *mtup = mtu;return 0 ; }
Signature · 1 line
2.24.0
PATCH v5 2/3 cxgb4: check rule prio conflicts before offload
In reply to Rahul LakkireddyOnly offload rule if it satisfies both of the following conditions:
1. The immediate previous rule has priority <= current rule's priority.
2. The immediate next rule has priority >= current rule's priority.
Also rework free entry fetch logic to search from end of TCAM, instead of beginning, because higher indices have lower priority than lower indices. This is similar to how TC auto generates priority values.
v5:
- Fixed commit message and comment to include comparison for equal priority.
v4:
- Patch added in this version.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 5 +- .../net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 114 ++++++++++++++---- .../net/ethernet/chelsio/cxgb4/cxgb4_filter.h | 1 + .../ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 31 ++++- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c | 36 +++--- 5 files changed, 143 insertions(+), 44 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +4 -1
@@ -1286,8 +1286,11 @@ struct ch_filter_specification {u16 nat_lport;/* local port to use after NAT'ing */ u16 nat_fport;/* foreign port to use after NAT'ing */ +u32 tc_prio;/* TC's filter priority index */ +u64 tc_cookie;/* Unique cookie identifying TC rules */ +/* reservation for future additions */ -u8 rsvd[24 ]; +u8 rsvd[12 ];/* Filter rule value/mask pairs. */
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +90 -24
132 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.h +1 -0
@@ -53,4 +53,5 @@ void clear_all_filters(struct adapter *adapter);void init_hash_filter (struct adapter *adap);bool is_filter_exact_match (struct adapter *adap,struct ch_filter_specification *fs); +bool cxgb4_filter_prio_in_range (struct net_device *dev,u32 idx,u32 prio);#endif /* __CXGB4_FILTER_H */
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +26 -5
@@ -636,12 +636,12 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,int cxgb4_tc_flower_replace (struct net_device *dev,struct flow_cls_offload *cls) { +struct netlink_ext_ack *extack = cls->common.extack;struct adapter *adap =netdev2adap (dev);struct ch_tc_flower_entry *ch_flower;struct ch_filter_specification *fs;struct filter_ctx ctx; -int fidx; -int ret; +int fidx, ret;if (cxgb4_validate_flow_actions (dev, cls))return -EOPNOTSUPP ;
@@ -664,14 +664,35 @@ int cxgb4_tc_flower_replace(struct net_device *dev,if (fs->hash) { fidx =0 ; }else { - fidx =cxgb4_get_free_ftid (dev, fs->type ?PF_INET6 :PF_INET ); -if (fidx <0 ) { -netdev_err (dev,"%s: No fidx for offload.\n" , __func__); +u8 inet_family; + + inet_family = fs->type ?PF_INET6 :PF_INET ; + +/* Note that TC uses prio 0 to indicate stack to +* generate automatic prio and hence doesn't pass prio +* 0 to driver. However, the hardware TCAM index +* starts from 0. Hence, the -1 here. +*/ +if (cls->common.prio <= adap->tids.nftids) + fidx = cls->common.prio -1 ; +else + fidx =cxgb4_get_free_ftid (dev, inet_family); + +/* Only insert FLOWER rule if its priority doesn't +* conflict with existing rules in the LETCAM. +*/ +if (fidx <0 || + !cxgb4_filter_prio_in_range (dev, fidx, cls->common.prio)) { +NL_SET_ERR_MSG_MOD (extack, +"No free LETCAM index available" ); ret = -ENOMEM ; goto free_entry; } } + fs->tc_prio = cls->common.prio; + fs->tc_cookie = cls->cookie; +init_completion (&ctx.completion); ret =__cxgb4_set_filter (dev, fidx, fs, &ctx);if (ret) {
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c +22 -14
@@ -36,6 +36,7 @@#include <net/tc_act/tc_mirred.h> #include "cxgb4.h" +#include "cxgb4_filter.h" #include "cxgb4_tc_u32_parse.h" #include "cxgb4_tc_u32.h"
@@ -148,6 +149,7 @@ static int fill_action_fields(struct adapter *adap,int cxgb4_config_knode (struct net_device *dev,struct tc_cls_u32_offload *cls) {const struct cxgb4_match_field *start, *link_start =NULL ; +struct netlink_ext_ack *extack = cls->common.extack;struct adapter *adapter =netdev2adap (dev);__be16 protocol = cls->common.protocol;struct ch_filter_specification fs;
@@ -164,14 +166,21 @@ int cxgb4_config_knode(struct net_device *dev, struct tc_cls_u32_offload *cls)if (protocol !=htons (ETH_P_IP ) && protocol !=htons (ETH_P_IPV6 ))return -EOPNOTSUPP ; -/* Fetch the location to insert the filter. */ - filter_id = cls->knode.handle &0xFFFFF ; +/* Note that TC uses prio 0 to indicate stack to generate +* automatic prio and hence doesn't pass prio 0 to driver. +* However, the hardware TCAM index starts from 0. Hence, the +* -1 here. +*/ + filter_id =TC_U32_NODE (cls->knode.handle) -1 ; -if (filter_id > adapter->tids.nftids) { -dev_err (adapter->pdev_dev, -"Location %d out of range for insertion. Max: %d\n" , - filter_id, adapter->tids.nftids); -return -ERANGE ; +/* Only insert U32 rule if its priority doesn't conflict with +* existing rules in the LETCAM. +*/ +if (filter_id >= adapter->tids.nftids || + !cxgb4_filter_prio_in_range (dev, filter_id, cls->common.prio)) { +NL_SET_ERR_MSG_MOD (extack, +"No free LETCAM index available" ); +return -ENOMEM ; } t = adapter->tc_u32;
@@ -190,6 +199,9 @@ int cxgb4_config_knode(struct net_device *dev, struct tc_cls_u32_offload *cls)memset (&fs,0 ,sizeof (fs)); + fs.tc_prio = cls->common.prio; + fs.tc_cookie = cls->knode.handle; +if (protocol ==htons (ETH_P_IPV6 )) { start = cxgb4_ipv6_fields; is_ipv6 = true;
@@ -350,14 +362,10 @@ int cxgb4_delete_knode(struct net_device *dev, struct tc_cls_u32_offload *cls)return -EOPNOTSUPP ;/* Fetch the location to delete the filter. */ - filter_id = cls->knode.handle &0xFFFFF ; - -if (filter_id > adapter->tids.nftids) { -dev_err (adapter->pdev_dev, -"Location %d out of range for deletion. Max: %d\n" , - filter_id, adapter->tids.nftids); + filter_id =TC_U32_NODE (cls->knode.handle) -1 ; +if (filter_id >= adapter->tids.nftids || + cls->knode.handle != adapter->tids.ftid_tab[filter_id].fs.tc_cookie)return -ERANGE ; - } t = adapter->tc_u32; handle = cls->knode.handle;
Signature · 1 line
2.24.0
PATCH v5 3/3 cxgb4: add TC-MATCHALL classifier ingress offload
In reply to Rahul LakkireddyAdd TC-MATCHALL classifier ingress offload support. The same actions supported by existing TC-FLOWER offload can be applied to all incoming traffic on the underlying interface.
Ensure the rule priority doesn't conflict with existing rules in the TCAM. Only 1 ingress matchall rule can be active at a time on the underlying interface.
v5:
- No change.
v4:
- Added check to ensure the matchall rule's prio doesn't conflict with other rules in TCAM.
- Added logic to fill default mask for VIID, if none has been provided, to prevent conflict with duplicate VIID rules.
- Used existing variables in private structure to fill VIID info, instead of extracting the info manually.
v3:
- No change.
v2:
- Removed logic to fetch free index from end of TCAM. Must maintain same ordering as in kernel.
--- .../net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 6 + .../net/ethernet/chelsio/cxgb4/cxgb4_main.c | 15 +- .../ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 21 ++- .../ethernet/chelsio/cxgb4/cxgb4_tc_flower.h | 6 + .../chelsio/cxgb4/cxgb4_tc_matchall.c | 145 +++++++++++++++++- .../chelsio/cxgb4/cxgb4_tc_matchall.h | 18 ++- 6 files changed, 192 insertions(+), 19 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +6 -0
@@ -872,6 +872,12 @@ static void fill_default_mask(struct ch_filter_specification *fs) fs->mask.tos |= ~0 ;if (fs->val.proto && !fs->mask.proto) fs->mask.proto |= ~0 ; +if (fs->val.pfvf_vld && !fs->mask.pfvf_vld) + fs->mask.pfvf_vld |= ~0 ; +if (fs->val.pf && !fs->mask.pf) + fs->mask.pf |= ~0 ; +if (fs->val.vf && !fs->mask.vf) + fs->mask.vf |= ~0 ;for (i =0 ; i <ARRAY_SIZE (fs->val.lip); i++) { lip |= fs->val.lip[i];
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +11 -4
@@ -3236,7 +3236,8 @@ static int cxgb_setup_tc_cls_u32(struct net_device *dev, }static int cxgb_setup_tc_matchall (struct net_device *dev, -struct tc_cls_matchall_offload *cls_matchall) +struct tc_cls_matchall_offload *cls_matchall, +bool ingress) {struct adapter *adap =netdev2adap (dev);
@@ -3245,9 +3246,13 @@ static int cxgb_setup_tc_matchall(struct net_device *dev,switch (cls_matchall->command) {case TC_CLSMATCHALL_REPLACE : -return cxgb4_tc_matchall_replace (dev, cls_matchall); +return cxgb4_tc_matchall_replace (dev, cls_matchall, ingress);case TC_CLSMATCHALL_DESTROY : -return cxgb4_tc_matchall_destroy (dev, cls_matchall); +return cxgb4_tc_matchall_destroy (dev, cls_matchall, ingress); +case TC_CLSMATCHALL_STATS : +if (ingress) +return cxgb4_tc_matchall_stats (dev, cls_matchall); +break ;default :break ; }
@@ -3277,6 +3282,8 @@ static int cxgb_setup_tc_block_ingress_cb(enum tc_setup_type type,return cxgb_setup_tc_cls_u32 (dev, type_data);case TC_SETUP_CLSFLOWER :return cxgb_setup_tc_flower (dev, type_data); +case TC_SETUP_CLSMATCHALL : +return cxgb_setup_tc_matchall (dev, type_data, true);default :return -EOPNOTSUPP ; }
@@ -3301,7 +3308,7 @@ static int cxgb_setup_tc_block_egress_cb(enum tc_setup_type type,switch (type) {case TC_SETUP_CLSMATCHALL : -return cxgb_setup_tc_matchall (dev, type_data); +return cxgb_setup_tc_matchall (dev, type_data, false);default :break ; }
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +10 -11
@@ -378,15 +378,14 @@ static void process_pedit_field(struct ch_filter_specification *fs, u32 val, } } -static void cxgb4_process_flow_actions (struct net_device *in, -struct flow_cls_offload *cls, -struct ch_filter_specification *fs) +void cxgb4_process_flow_actions (struct net_device *in, +struct flow_action *actions, +struct ch_filter_specification *fs) { -struct flow_rule *rule =flow_cls_offload_flow_rule (cls);struct flow_action_entry *act;int i; -flow_action_for_each (i, act, &rule->action) { +flow_action_for_each (i, act, actions) {switch (act->id) {case FLOW_ACTION_ACCEPT : fs->action =FILTER_PASS ;
@@ -544,17 +543,16 @@ static bool valid_pedit_action(struct net_device *dev,return true; } -static int cxgb4_validate_flow_actions (struct net_device *dev, -struct flow_cls_offload *cls) +int cxgb4_validate_flow_actions (struct net_device *dev, +struct flow_action *actions) { -struct flow_rule *rule =flow_cls_offload_flow_rule (cls);struct flow_action_entry *act;bool act_redir = false;bool act_pedit = false;bool act_vlan = false;int i; -flow_action_for_each (i, act, &rule->action) { +flow_action_for_each (i, act, actions) {switch (act->id) {case FLOW_ACTION_ACCEPT :case FLOW_ACTION_DROP :
@@ -636,6 +634,7 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,int cxgb4_tc_flower_replace (struct net_device *dev,struct flow_cls_offload *cls) { +struct flow_rule *rule =flow_cls_offload_flow_rule (cls);struct netlink_ext_ack *extack = cls->common.extack;struct adapter *adap =netdev2adap (dev);struct ch_tc_flower_entry *ch_flower;
@@ -643,7 +642,7 @@ int cxgb4_tc_flower_replace(struct net_device *dev,struct filter_ctx ctx;int fidx, ret; -if (cxgb4_validate_flow_actions (dev, cls)) +if (cxgb4_validate_flow_actions (dev, &rule->action))return -EOPNOTSUPP ;if (cxgb4_validate_flow_match (dev, cls))
@@ -658,7 +657,7 @@ int cxgb4_tc_flower_replace(struct net_device *dev, fs = &ch_flower->fs; fs->hitcnts =1 ;cxgb4_process_flow_match (dev, cls, fs); -cxgb4_process_flow_actions (dev, cls, fs); +cxgb4_process_flow_actions (dev, &rule->action, fs); fs->hash =is_filter_exact_match (adap, fs);if (fs->hash) {
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h +6 -0
@@ -108,6 +108,12 @@ struct ch_tc_pedit_fields {#define PEDIT_TCP_SPORT_DPORT 0x0#define PEDIT_UDP_SPORT_DPORT 0x0 +void cxgb4_process_flow_actions (struct net_device *in, +struct flow_action *actions, +struct ch_filter_specification *fs); +int cxgb4_validate_flow_actions (struct net_device *dev, +struct flow_action *actions); +int cxgb4_tc_flower_replace (struct net_device *dev,struct flow_cls_offload *cls); int cxgb4_tc_flower_destroy(struct net_device *dev,
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c +143 -2
188 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.h +16 -2
@@ -17,8 +17,18 @@ struct cxgb4_matchall_egress_entry {u64 cookie;/* Used to identify the MATCHALL rule offloaded */ }; +struct cxgb4_matchall_ingress_entry { +enum cxgb4_matchall_state state;/* Current MATCHALL offload state */ +u32 tid;/* Index to hardware filter entry */ +struct ch_filter_specification fs;/* Filter entry */ +u64 bytes;/* # of bytes hitting the filter */ +u64 packets;/* # of packets hitting the filter */ +u64 last_used;/* Last updated jiffies time */ +}; +struct cxgb4_tc_port_matchall {struct cxgb4_matchall_egress_entry egress;/* Egress offload info */ +struct cxgb4_matchall_ingress_entry ingress;/* Ingress offload info */ };struct cxgb4_tc_matchall {
@@ -26,9 +36,13 @@ struct cxgb4_tc_matchall { };int cxgb4_tc_matchall_replace (struct net_device *dev, -struct tc_cls_matchall_offload *cls_matchall); +struct tc_cls_matchall_offload *cls_matchall, +bool ingress);int cxgb4_tc_matchall_destroy (struct net_device *dev, -struct tc_cls_matchall_offload *cls_matchall); +struct tc_cls_matchall_offload *cls_matchall, +bool ingress); +int cxgb4_tc_matchall_stats (struct net_device *dev, +struct tc_cls_matchall_offload *cls_matchall);int cxgb4_init_tc_matchall (struct adapter *adap);void cxgb4_cleanup_tc_matchall (struct adapter *adap);
Signature · 1 line
2.24.0
Quoted 17 lines · Rahul Lakkireddy
This series of patches add support to offload TC-MATCHALL classifier to hardware to classify all outgoing and incoming traffic on the underlying port. Only 1 egress and 1 ingress rule each can be offloaded on the underlying port.
Patch 1 adds support for TC-MATCHALL classifier offload on the egress side. TC-POLICE is the only action that can be offloaded on the egress side and is used to rate limit all outgoing traffic to specified max rate.
Patch 2 adds logic to reject the current rule offload if its priority conflicts with existing rules in the TCAM.
Patch 3 adds support for TC-MATCHALL classifier offload on the ingress side. The same set of actions supported by existing TC-FLOWER classifier offload can be applied on all the incoming traffic.
Quoted 6 lines
Thanks,
Rahulv5:
- Fixed commit message and comment to include comparison for equal priority in patch 2.
LGTM, thanks!
David Miller
maintainerFrom: Rahul Lakkireddy <[email protected]>
Date: Wed, 20 Nov 2019 05:46:05 +0530
Quoted 10 lines
This series of patches add support to offload TC-MATCHALL classifier to hardware to classify all outgoing and incoming traffic on the underlying port. Only 1 egress and 1 ingress rule each can be offloaded on the underlying port.
Patch 1 adds support for TC-MATCHALL classifier offload on the egress side. TC-POLICE is the only action that can be offloaded on the egress side and is used to rate limit all outgoing traffic to specified max rate.
Quoted 6 lines
Patch 2 adds logic to reject the current rule offload if its priority conflicts with existing rules in the TCAM.
Patch 3 adds support for TC-MATCHALL classifier offload on the ingress side. The same set of actions supported by existing TC-FLOWER classifier offload can be applied on all the incoming traffic.
...
Series applied, thanks.