cxgb4: enable more tc flower offload matches and actions
Subsystems (3)
cover cxgb4: enable more tc flower offload matches and actions
This patch series enable more matches and actions for TC Flower Offload support on Chelsio adapters.
Patch 1 enables matching on IP TOS.
Patch 2 enables matching on VLAN TCI.
Patch 3 adds support for action PASS.
Patch 4 adds support for ETH-DMAC rewrite via TC-PEDIT action. Also, adds a check to assert that vlan/eth-dmac rewrite actions are valid only in combination with action egress redirect.
Patch 5 introduces SMT ops for adding/removing entries from SMAC Table in HW in preparation for patch 6.
Patch 6 adds support for ETH-SMAC rewrite via TC-PEDIT action.
Patch 7 introduces fw_filter2_wr to support L3/L4 header rewrites in preparation for patch 8.
Patch 8 adds support for rewrite on L3/L4 header fields via TC-PEDIT action. Supported fields for rewrite are:
IPv4 src/dst address, IPv6 src/dst address, TCP/UDP sport/dport.
Thanks,
Rahul
Kumar Sanghvi (8):
cxgb4: add tc flower match support for TOS
cxgb4: add tc flower match support for vlan
cxgb4: add tc flower support for action PASS
cxgb4: add tc flower support for ETH-DMAC rewrite
cxgb4: introduce SMT ops to prepare for SMAC rewrite support
cxgb4: add tc flower support for ETH-SMAC rewrite
cxgb4: introduce fw_filter2_wr to prepare for L3/L4 rewrite support
cxgb4: add tc flower support for L3/L4 rewrite
drivers/net/ethernet/chelsio/cxgb4/Makefile | 2 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 17 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 126 ++++++- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 22 ++ .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 385 ++++++++++++++++++++- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h | 54 +++ drivers/net/ethernet/chelsio/cxgb4/smt.c | 247 +++++++++++++ drivers/net/ethernet/chelsio/cxgb4/smt.h | 76 ++++ drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 44 ++- drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h | 47 +++ drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 75 +++- 11 files changed, 1068 insertions(+), 27 deletions(-) create mode 100644 drivers/net/ethernet/chelsio/cxgb4/smt.c create mode 100644 drivers/net/ethernet/chelsio/cxgb4/smt.h create mode 100644 drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h
Signature · 1 line
2.14.1
PATCH 1/8 cxgb4: add tc flower match support for TOS
From: Kumar Sanghvi <[email protected]>
Add support for matching on IP TOS. Also check on ethtype value to be either IPv4 or IPv6.
--- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 51 +++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +50 -1
@@ -147,6 +147,19 @@ static void cxgb4_process_flow_match(struct net_device *dev, fs->mask.fport =cpu_to_be16 (mask->src); } +if (dissector_uses_key (cls->dissector,FLOW_DISSECTOR_KEY_IP )) { +struct flow_dissector_key_ip *key, *mask; + + key =skb_flow_dissector_target (cls->dissector, +FLOW_DISSECTOR_KEY_IP , + cls->key); + mask =skb_flow_dissector_target (cls->dissector, +FLOW_DISSECTOR_KEY_IP , + cls->mask); + fs->val.tos = key->tos; + fs->mask.tos = mask->tos; + } +/* Match only packets coming from the ingress port where this * filter will be created. */
@@ -157,16 +170,52 @@ static void cxgb4_process_flow_match(struct net_device *dev,static int cxgb4_validate_flow_match (struct net_device *dev,struct tc_cls_flower_offload *cls) { +u16 ethtype_mask =0 ; +u16 ethtype_key =0 ; +if (cls->dissector->used_keys & ~(BIT (FLOW_DISSECTOR_KEY_CONTROL ) |BIT (FLOW_DISSECTOR_KEY_BASIC ) |BIT (FLOW_DISSECTOR_KEY_IPV4_ADDRS ) |BIT (FLOW_DISSECTOR_KEY_IPV6_ADDRS ) | -BIT (FLOW_DISSECTOR_KEY_PORTS ))) { +BIT (FLOW_DISSECTOR_KEY_PORTS ) | +BIT (FLOW_DISSECTOR_KEY_IP ))) {netdev_warn (dev,"Unsupported key used: 0x%x\n" , cls->dissector->used_keys);return -EOPNOTSUPP ; } + +if (dissector_uses_key (cls->dissector,FLOW_DISSECTOR_KEY_BASIC )) { +struct flow_dissector_key_basic *key = +skb_flow_dissector_target (cls->dissector, +FLOW_DISSECTOR_KEY_BASIC , + cls->key); +struct flow_dissector_key_basic *mask = +skb_flow_dissector_target (cls->dissector, +FLOW_DISSECTOR_KEY_BASIC , + cls->mask); + ethtype_key =ntohs (key->n_proto); + ethtype_mask =ntohs (mask->n_proto); + } + +if (dissector_uses_key (cls->dissector,FLOW_DISSECTOR_KEY_IP )) { +u16 eth_ip_type = ethtype_key & ethtype_mask; +struct flow_dissector_key_ip *mask; + +if (eth_ip_type !=ETH_P_IP && eth_ip_type !=ETH_P_IPV6 ) { +netdev_err (dev,"IP Key supported only with IPv4/v6" ); +return -EINVAL ; + } + + mask =skb_flow_dissector_target (cls->dissector, +FLOW_DISSECTOR_KEY_IP , + cls->mask); +if (mask->ttl) { +netdev_warn (dev,"ttl match unsupported for offload" ); +return -EOPNOTSUPP ; + } + } +return 0 ; }
Signature · 1 line
2.14.1
PATCH 2/8 cxgb4: add tc flower match support for vlan
In reply to Rahul LakkireddyFrom: Kumar Sanghvi <[email protected]>
Add support for matching on vlan tci. Construct vlan tci match param based on vlan-id and vlan-pcp values supplied by tc.
--- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +35 -0
@@ -160,6 +160,40 @@ static void cxgb4_process_flow_match(struct net_device *dev, fs->mask.tos = mask->tos; } +if (dissector_uses_key (cls->dissector,FLOW_DISSECTOR_KEY_VLAN )) { +struct flow_dissector_key_vlan *key, *mask; +u16 vlan_tci, vlan_tci_mask; + + key =skb_flow_dissector_target (cls->dissector, +FLOW_DISSECTOR_KEY_VLAN , + cls->key); + mask =skb_flow_dissector_target (cls->dissector, +FLOW_DISSECTOR_KEY_VLAN , + cls->mask); + vlan_tci = key->vlan_id | (key->vlan_priority << +VLAN_PRIO_SHIFT ); + vlan_tci_mask = mask->vlan_id | (mask->vlan_priority << +VLAN_PRIO_SHIFT ); + fs->val.ivlan =cpu_to_be16 (vlan_tci); + fs->mask.ivlan =cpu_to_be16 (vlan_tci_mask); + +/* Chelsio adapters use ivlan_vld bit to match vlan packets +* as 802.1Q. Also, when vlan tag is present in packets, +* ethtype match is used then to match on ethtype of inner +* header ie. the header following the vlan header. +* So, set the ivlan_vld based on ethtype info supplied by +* TC for vlan packets if its 802.1Q. And then reset the +* ethtype value else, hw will try to match the supplied +* ethtype value with ethtype of inner header. +*/ +if (fs->val.ethtype ==ETH_P_8021Q ) { + fs->val.ivlan_vld =1 ; + fs->mask.ivlan_vld =1 ; + fs->val.ethtype =0 ; + fs->mask.ethtype =0 ; + } + } +/* Match only packets coming from the ingress port where this * filter will be created. */
@@ -179,6 +213,7 @@ static int cxgb4_validate_flow_match(struct net_device *dev, BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) | BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) | BIT(FLOW_DISSECTOR_KEY_PORTS) | + BIT(FLOW_DISSECTOR_KEY_VLAN) | BIT(FLOW_DISSECTOR_KEY_IP))) {netdev_warn (dev,"Unsupported key used: 0x%x\n" , cls->dissector->used_keys);
Signature · 1 line
2.14.1
PATCH 3/8 cxgb4: add tc flower support for action PASS
In reply to Rahul LakkireddyFrom: Kumar Sanghvi <[email protected]>
Add support for tc flower action PASS.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +6 -2
@@ -263,7 +263,9 @@ static void cxgb4_process_flow_actions(struct net_device *in,tcf_exts_to_list (cls->exts, &actions);list_for_each_entry (a, &actions, list) { -if (is_tcf_gact_shot (a)) { +if (is_tcf_gact_ok (a)) { + fs->action =FILTER_PASS ; + }else if (is_tcf_gact_shot (a)) { fs->action =FILTER_DROP ; }else if (is_tcf_mirred_egress_redirect (a)) {int ifindex =tcf_mirred_ifindex (a);
@@ -306,7 +308,9 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,tcf_exts_to_list (cls->exts, &actions);list_for_each_entry (a, &actions, list) { -if (is_tcf_gact_shot (a)) { +if (is_tcf_gact_ok (a)) { +/* Do nothing */ + }else if (is_tcf_gact_shot (a)) {/* Do nothing */ }else if (is_tcf_mirred_egress_redirect (a)) {struct adapter *adap =netdev2adap (dev);
Signature · 1 line
2.14.1
PATCH 4/8 cxgb4: add tc flower support for ETH-DMAC rewrite
In reply to Rahul LakkireddyFrom: Kumar Sanghvi <[email protected]>
Add support for ETH-DMAC Rewrite via TC-PEDIT action. Also, add check to assert that vlan/eth-dmac rewrite actions are valid only in combination with action egress redirect.
--- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 108 ++++++++++++++++++++- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h | 19 ++++ 2 files changed, 126 insertions(+), 1 deletion(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +107 -1
@@ -32,8 +32,9 @@* SOFTWARE. */ -#include <net/tc_act/tc_gact.h> #include <net/tc_act/tc_mirred.h> +#include <net/tc_act/tc_pedit.h> +#include <net/tc_act/tc_gact.h> #include <net/tc_act/tc_vlan.h> #include "cxgb4.h"
@@ -41,6 +42,11 @@#define STATS_CHECK_PERIOD (HZ / 2) +struct ch_tc_pedit_fields pedits[] = { +PEDIT_FIELDS (ETH_ ,DMAC_31_0 ,4 , dmac,0 ), +PEDIT_FIELDS (ETH_ ,DMAC_47_32 ,2 , dmac,4 ), +}; +static struct ch_tc_flower_entry *allocate_flower_entry (void ) {struct ch_tc_flower_entry *new =kzalloc (sizeof (*new),GFP_KERNEL );
@@ -254,6 +260,41 @@ static int cxgb4_validate_flow_match(struct net_device *dev,return 0 ; } +static void offload_pedit (struct ch_filter_specification *fs,u32 val,u32 mask, +u8 field) +{ +u32 set_val = val & ~mask; +u32 offset; +u8 size; +int i; + +for (i =0 ; i <ARRAY_SIZE (pedits); i++) { +if (pedits[i].field == field) { + offset = pedits[i].offset; + size = pedits[i].size; +break ; + } + } +memcpy ((u8 *)fs + offset, &set_val, size); +} + +static void process_pedit_field (struct ch_filter_specification *fs,u32 val, +u32 mask,u32 offset,u8 htype) +{ +switch (htype) { +case TCA_PEDIT_KEY_EX_HDR_TYPE_ETH : +switch (offset) { +case PEDIT_ETH_DMAC_31_0 : + fs->newdmac =1 ; +offload_pedit (fs, val, mask,ETH_DMAC_31_0 ); +break ; +case PEDIT_ETH_DMAC_47_32_SMAC_15_0 : +if (~mask &PEDIT_ETH_DMAC_MASK ) +offload_pedit (fs, val, mask,ETH_DMAC_47_32 ); + } + } +} +static void cxgb4_process_flow_actions (struct net_device *in,struct tc_cls_flower_offload *cls,struct ch_filter_specification *fs)
@@ -296,6 +337,21 @@ static void cxgb4_process_flow_actions(struct net_device *in,default :break ; } + }else if (is_tcf_pedit (a)) { +u32 mask, val, offset; +int nkeys, i; +u8 htype; + + nkeys =tcf_pedit_nkeys (a); +for (i =0 ; i < nkeys; i++) { + htype =tcf_pedit_htype (a, i); + mask =tcf_pedit_mask (a, i); + val =tcf_pedit_val (a, i); + offset =tcf_pedit_offset (a, i); + +process_pedit_field (fs, val, mask, offset, + htype); + } } } }
@@ -304,6 +360,9 @@ static int cxgb4_validate_flow_actions(struct net_device *dev, struct tc_cls_flower_offload *cls) {const struct tc_action *a; +bool act_redir = false; +bool act_pedit = false; +bool act_vlan = false;LIST_HEAD (actions);tcf_exts_to_list (cls->exts, &actions);
@@ -335,6 +394,7 @@ static int cxgb4_validate_flow_actions(struct net_device *dev, __func__);return -EINVAL ; } + act_redir = true; }else if (is_tcf_vlan (a)) {u16 proto =be16_to_cpu (tcf_vlan_push_proto (a));u32 vlan_action =tcf_vlan_action (a);
@@ -355,11 +415,57 @@ static int cxgb4_validate_flow_actions(struct net_device *dev, __func__);return -EOPNOTSUPP ; } + act_vlan = true; + }else if (is_tcf_pedit (a)) { +u32 mask, val, offset; +u8 cmd, htype; +int nkeys, i; + + nkeys =tcf_pedit_nkeys (a); +for (i =0 ; i < nkeys; i++) { + htype =tcf_pedit_htype (a, i); + cmd =tcf_pedit_cmd (a, i); + mask =tcf_pedit_mask (a, i); + val =tcf_pedit_val (a, i); + offset =tcf_pedit_offset (a, i); + +if (cmd !=TCA_PEDIT_KEY_EX_CMD_SET ) { +netdev_err (dev,"%s: Unsupported pedit cmd\n" , + __func__); +return -EOPNOTSUPP ; + } + +switch (htype) { +case TCA_PEDIT_KEY_EX_HDR_TYPE_ETH : +switch (offset) { +case PEDIT_ETH_DMAC_31_0 : +case PEDIT_ETH_DMAC_47_32_SMAC_15_0 : +break ; +default : +netdev_err (dev,"%s: Unsupported pedit field\n" , + __func__); +return -EOPNOTSUPP ; + } +break ; +default : +netdev_err (dev,"%s: Unsupported pedit type\n" , + __func__); +return -EOPNOTSUPP ; + } + } + act_pedit = true; }else {netdev_err (dev,"%s: Unsupported action\n" , __func__);return -EOPNOTSUPP ; } } + +if ((act_pedit || act_vlan) && !act_redir) { +netdev_err (dev,"%s: pedit/vlan rewrite invalid without egress redirect\n" , + __func__); +return -EINVAL ; + } +return 0 ; }
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h +19 -0
@@ -54,6 +54,25 @@ struct ch_tc_flower_entry {u32 filter_id; }; +enum { +ETH_DMAC_31_0 ,/* dmac bits 0.. 31 */ +ETH_DMAC_47_32 ,/* dmac bits 32..47 */ +}; + +struct ch_tc_pedit_fields { +u8 field; +u8 size; +u32 offset; +}; + +#define PEDIT_FIELDS (type, field, size, fs_field, offset) \ + { type## field, size, \ + offsetof(struct ch_filter_specification, fs_field) + (offset) } + +#define PEDIT_ETH_DMAC_MASK 0xffff +#define PEDIT_ETH_DMAC_31_0 0x0 +#define PEDIT_ETH_DMAC_47_32_SMAC_15_0 0x4 +int cxgb4_tc_flower_replace (struct net_device *dev,struct tc_cls_flower_offload *cls); int cxgb4_tc_flower_destroy(struct net_device *dev,
Signature · 1 line
2.14.1
PATCH 5/8 cxgb4: introduce SMT ops to prepare for SMAC rewrite support
In reply to Rahul LakkireddyFrom: Kumar Sanghvi <[email protected]>
Introduce SMT operations for allocating/removing entries from SMAC table. Make TCAM filters use the SMT ops whenever SMAC rewrite is required.
--- drivers/net/ethernet/chelsio/cxgb4/Makefile | 2 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 3 +- drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 107 ++++++++-- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 12 ++ drivers/net/ethernet/chelsio/cxgb4/smt.c | 247 ++++++++++++++++++++++ drivers/net/ethernet/chelsio/cxgb4/smt.h | 76 +++++++ drivers/net/ethernet/chelsio/cxgb4/t4_msg.h | 44 +++- drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h | 47 ++++ 8 files changed, 519 insertions(+), 19 deletions(-) create mode 100644 drivers/net/ethernet/chelsio/cxgb4/smt.c create mode 100644 drivers/net/ethernet/chelsio/cxgb4/smt.h create mode 100644 drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h
drivers/net/ethernet/chelsio/cxgb4/Makefile +1 -1
@@ -4,7 +4,7 @@ obj-$(CONFIG_CHELSIO_T4) += cxgb4.o -cxgb4-objs := cxgb4_main.o l2t.o t4_hw.o sge.o clip_tbl.o cxgb4_ethtool.o \ +cxgb4-objs := cxgb4_main.o l2t.o smt.o t4_hw.o sge.o clip_tbl.o cxgb4_ethtool.o \ cxgb4_uld.o sched.o cxgb4_filter.o cxgb4_tc_u32.o \ cxgb4_ptp.o cxgb4_tc_flower.o cxgb4_cudbg.o \ cudbg_common.o cudbg_lib.o
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +2 -1
@@ -858,6 +858,7 @@ struct adapter {unsigned int clipt_start;unsigned int clipt_end;struct clip_tbl *clipt; +struct smt_data *smt;struct cxgb4_uld_info *uld;void *uld_handle[CXGB4_ULD_MAX ];unsigned int num_uld;
@@ -1098,9 +1099,9 @@ struct filter_entry { u32 locked:1; /* filter is administratively locked */ u32 pending:1; /* filter action is pending firmware reply */ - u32 smtidx:8; /* Source MAC Table index for smac */struct filter_ctx *ctx;/* Caller's completion hook */ struct l2t_entry *l2t;/* Layer Two Table entry for dmac */ +struct smt_entry *smt;/* Source Mac Table entry for smac */ struct net_device *dev;/* Associated net device */ u32 tid;/* This will store the actual tid */
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +92 -15
151 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +12 -0
@@ -77,6 +77,7 @@#include "cxgb4_debugfs.h" #include "clip_tbl.h" #include "l2t.h" +#include "smt.h" #include "sched.h" #include "cxgb4_tc_u32.h" #include "cxgb4_tc_flower.h"
@@ -563,6 +564,10 @@ static int fwevtq_handler(struct sge_rspq *q, const __be64 *rsp,const struct cpl_l2t_write_rpl *p = (void *)rsp;do_l2t_write_rpl (q->adap, p); + }else if (opcode ==CPL_SMT_WRITE_RPL ) { +const struct cpl_smt_write_rpl *p = (void *)rsp; + +do_smt_write_rpl (q->adap, p); }else if (opcode ==CPL_SET_TCB_RPL ) {const struct cpl_set_tcb_rpl *p = (void *)rsp;
@@ -4641,6 +4646,7 @@ static void free_some_resources(struct adapter *adapter) {unsigned int i; +kvfree (adapter->smt);kvfree (adapter->l2t);t4_cleanup_sched (adapter);kvfree (adapter->tids.tid_tab);
@@ -5067,6 +5073,12 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)*/ cfg_queues (adapter); + adapter->smt =t4_init_smt (); +if (!adapter->smt) { +/* We tolerate a lack of SMT, giving up some functionality */ +dev_warn (&pdev->dev,"could not allocate SMT, continuing\n" ); + } + adapter->l2t =t4_init_l2t (adapter->l2t_start, adapter->l2t_end);if (!adapter->l2t) {/* We tolerate a lack of L2T, giving up some functionality */
drivers/net/ethernet/chelsio/cxgb4/smt.c new file +247 -0
247 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/smt.h new file +76 -0
76 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/t4_msg.h +42 -2
68 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH 6/8 cxgb4: add tc flower support for ETH-SMAC rewrite
In reply to Rahul LakkireddyFrom: Kumar Sanghvi <[email protected]>
Adds support for ETH-SMAC rewrite via TC-PEDIT action.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 10 ++++++++++ drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h | 3 +++ 2 files changed, 13 insertions(+)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +10 -0
@@ -45,6 +45,8 @@struct ch_tc_pedit_fields pedits[] = {PEDIT_FIELDS (ETH_ ,DMAC_31_0 ,4 , dmac,0 ),PEDIT_FIELDS (ETH_ ,DMAC_47_32 ,2 , dmac,4 ), +PEDIT_FIELDS (ETH_ ,SMAC_15_0 ,2 , smac,0 ), +PEDIT_FIELDS (ETH_ ,SMAC_47_16 ,4 , smac,2 ), };static struct ch_tc_flower_entry *allocate_flower_entry (void )
@@ -291,6 +293,13 @@ static void process_pedit_field(struct ch_filter_specification *fs, u32 val,case PEDIT_ETH_DMAC_47_32_SMAC_15_0 :if (~mask &PEDIT_ETH_DMAC_MASK )offload_pedit (fs, val, mask,ETH_DMAC_47_32 ); +else +offload_pedit (fs, val >>16 , mask >>16 , +ETH_SMAC_15_0 ); +break ; +case PEDIT_ETH_SMAC_47_16 : + fs->newsmac =1 ; +offload_pedit (fs, val, mask,ETH_SMAC_47_16 ); } } }
@@ -440,6 +449,7 @@ static int cxgb4_validate_flow_actions(struct net_device *dev,switch (offset) {case PEDIT_ETH_DMAC_31_0 :case PEDIT_ETH_DMAC_47_32_SMAC_15_0 : +case PEDIT_ETH_SMAC_47_16 :break ;default : netdev_err(dev, "%s: Unsupported pedit field\n",
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h +3 -0
@@ -57,6 +57,8 @@ struct ch_tc_flower_entry {enum {ETH_DMAC_31_0 ,/* dmac bits 0.. 31 */ ETH_DMAC_47_32 ,/* dmac bits 32..47 */ +ETH_SMAC_15_0 ,/* smac bits 0.. 15 */ +ETH_SMAC_47_16 ,/* smac bits 16..47 */ };struct ch_tc_pedit_fields {
@@ -72,6 +74,7 @@ struct ch_tc_pedit_fields {#define PEDIT_ETH_DMAC_MASK 0xffff#define PEDIT_ETH_DMAC_31_0 0x0#define PEDIT_ETH_DMAC_47_32_SMAC_15_0 0x4 +#define PEDIT_ETH_SMAC_47_16 0x8int cxgb4_tc_flower_replace (struct net_device *dev,struct tc_cls_flower_offload *cls);
Signature · 1 line
2.14.1
PATCH 7/8 cxgb4: introduce fw_filter2_wr to prepare for L3/L4 rewrite support
In reply to Rahul LakkireddyFrom: Kumar Sanghvi <[email protected]>
Update driver to use new fw_filter2_wr in order to support rewrite of L3/L4 header fields via filters. Query FW_PARAMS_PARAM_DEV_FILTER2_WR to check whether FW supports this new wr.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 10 +++ drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 19 +++++- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 10 +++ drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h | 75 ++++++++++++++++++++++- 4 files changed, 111 insertions(+), 3 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +10 -0
@@ -367,6 +367,7 @@ struct adapter_params {unsigned int max_ird_adapter;/* Max read depth per adapter */ bool fr_nsmr_tpte_wr_support;/* FW support for FR_NSMR_TPTE_WR */ u8 fw_caps_support;/* 32-bit Port Capabilities */ +bool filter2_wr_support;/* FW support for FILTER2_WR */ /* MPS Buffer Group Map[per Port]. Bit i is set if buffer group i is * used by the Port
@@ -1064,10 +1065,19 @@ struct ch_filter_specification { uint32_t newdmac:1; /* rewrite destination MAC address */ uint32_t newsmac:1; /* rewrite source MAC address */ uint32_t newvlan:2; /* rewrite VLAN Tag */ + uint32_t nat_mode:3; /* specify NAT operation mode */uint8_t dmac[ETH_ALEN ];/* new destination MAC address */ uint8_t smac[ETH_ALEN ];/* new source MAC address */ uint16_t vlan;/* VLAN Tag to insert */ +u8 nat_lip[16 ];/* local IP to use after NAT'ing */ +u8 nat_fip[16 ];/* foreign IP to use after NAT'ing */ +u16 nat_lport;/* local port to use after NAT'ing */ +u16 nat_fport;/* foreign port to use after NAT'ing */ + +/* reservation for future additions */ +u8 rsvd[24 ]; +/* Filter rule value/mask pairs. */ struct ch_filter_tuple val;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +17 -2
@@ -313,7 +313,7 @@ static int del_filter_wr(struct adapter *adapter, int fidx)int set_filter_wr (struct adapter *adapter,int fidx) {struct filter_entry *f = &adapter->tids.ftid_tab[fidx]; -struct fw_filter_wr *fwr; +struct fw_filter2_wr *fwr;struct sk_buff *skb; skb =alloc_skb (sizeof (*fwr),GFP_KERNEL );
@@ -359,7 +359,10 @@ int set_filter_wr(struct adapter *adapter, int fidx)* filter specification structure but for now it's easiest to simply * put this fairly direct code in line ... */ - fwr->op_pkd =htonl (FW_WR_OP_V (FW_FILTER_WR )); +if (adapter->params.filter2_wr_support) + fwr->op_pkd =htonl (FW_WR_OP_V (FW_FILTER2_WR )); +else + fwr->op_pkd =htonl (FW_WR_OP_V (FW_FILTER_WR )); fwr->len16_pkd =htonl (FW_WR_LEN16_V (sizeof (*fwr) /16 )); fwr->tid_to_iq = htonl(FW_FILTER_WR_TID_V(f->tid) |
@@ -421,6 +424,18 @@ int set_filter_wr(struct adapter *adapter, int fidx) fwr->fp =htons (f->fs.val.fport); fwr->fpm =htons (f->fs.mask.fport); +if (adapter->params.filter2_wr_support) { + fwr->natmode_to_ulp_type = +FW_FILTER2_WR_ULP_TYPE_V (f->fs.nat_mode ? +ULP_MODE_TCPDDP : +ULP_MODE_NONE ) | +FW_FILTER2_WR_NATMODE_V (f->fs.nat_mode); +memcpy (fwr->newlip, f->fs.nat_lip,sizeof (fwr->newlip)); +memcpy (fwr->newfip, f->fs.nat_fip,sizeof (fwr->newfip)); + fwr->newlport =htons (f->fs.nat_lport); + fwr->newfport =htons (f->fs.nat_fport); + } +/* Mark the filter as "pending" and ship off the Filter Work Request. * When we get the Work Request Reply we'll clear the pending status. */
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +10 -0
@@ -3910,6 +3910,16 @@ static int adap_init0(struct adapter *adap) 1, params, val); adap->params.fr_nsmr_tpte_wr_support = (ret ==0 && val[0 ] !=0 ); +/* See if FW supports FW_FILTER2 work request */ +if (is_t4 (adap->params.chip)) { + adap->params.filter2_wr_support =0 ; + }else { + params[0 ] =FW_PARAM_DEV (FILTER2_WR ); + ret =t4_query_params (adap, adap->mbox, adap->pf,0 , +1 , params, val); + adap->params.filter2_wr_support = (ret ==0 && val[0 ] !=0 ); + } +/* * Get device capabilities so we can determine what resources we need * to manage.
drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h +74 -1
99 lines not on this page · raw message
Signature · 1 line
2.14.1
PATCH 8/8 cxgb4: add tc flower support for L3/L4 rewrite
In reply to Rahul LakkireddyFrom: Kumar Sanghvi <[email protected]>
Adds support to rewrite L3/L4 fields via TC-PEDIT action. Supported fields for rewrite are:
IPv4 src/dst address, IPv6 src/dst address, TCP/UDP sport/dport.
Also, process match fields first and then process the action items.
Refactor pedit action validation to separate function to avoid excessive code indentation.
--- drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 4 + .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c | 245 +++++++++++++++++---- .../net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h | 32 +++ 3 files changed, 244 insertions(+), 37 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4.h +4 -0
@@ -1097,6 +1097,10 @@ enum { VLAN_REWRITE }; +enum { +NAT_MODE_ALL =7 ,/* NAT on entire 4-tuple */ +}; +/* Host shadow copy of ingress filter entry. This is in host native format * and doesn't match the ordering or bit order, etc. of the hardware of the * firmware command. The use of bit-field structure elements is purely to
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c +208 -37
295 lines not on this page · raw message
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h +32 -0
@@ -59,6 +59,25 @@ enum {ETH_DMAC_47_32 ,/* dmac bits 32..47 */ ETH_SMAC_15_0 ,/* smac bits 0.. 15 */ ETH_SMAC_47_16 ,/* smac bits 16..47 */ + +IP4_SRC ,/* 32-bit IPv4 src */ +IP4_DST ,/* 32-bit IPv4 dst */ + +IP6_SRC_31_0 ,/* src bits 0.. 31 */ +IP6_SRC_63_32 ,/* src bits 63.. 32 */ +IP6_SRC_95_64 ,/* src bits 95.. 64 */ +IP6_SRC_127_96 ,/* src bits 127..96 */ + +IP6_DST_31_0 ,/* dst bits 0.. 31 */ +IP6_DST_63_32 ,/* dst bits 63.. 32 */ +IP6_DST_95_64 ,/* dst bits 95.. 64 */ +IP6_DST_127_96 ,/* dst bits 127..96 */ + +TCP_SPORT ,/* 16-bit TCP sport */ +TCP_DPORT ,/* 16-bit TCP dport */ + +UDP_SPORT ,/* 16-bit UDP sport */ + UDP_DPORT, /* 16-bit UDP dport */ }; struct ch_tc_pedit_fields {
@@ -72,9 +91,22 @@ struct ch_tc_pedit_fields { offsetof(struct ch_filter_specification, fs_field) + (offset) }#define PEDIT_ETH_DMAC_MASK 0xffff +#define PEDIT_TCP_UDP_SPORT_MASK 0xffff#define PEDIT_ETH_DMAC_31_0 0x0#define PEDIT_ETH_DMAC_47_32_SMAC_15_0 0x4#define PEDIT_ETH_SMAC_47_16 0x8 +#define PEDIT_IP4_SRC 0xC +#define PEDIT_IP4_DST 0x10 +#define PEDIT_IP6_SRC_31_0 0x8 +#define PEDIT_IP6_SRC_63_32 0xC +#define PEDIT_IP6_SRC_95_64 0x10 +#define PEDIT_IP6_SRC_127_96 0x14 +#define PEDIT_IP6_DST_31_0 0x18 +#define PEDIT_IP6_DST_63_32 0x1C +#define PEDIT_IP6_DST_95_64 0x20 +#define PEDIT_IP6_DST_127_96 0x24 +#define PEDIT_TCP_SPORT_DPORT 0x0 +#define PEDIT_UDP_SPORT_DPORT 0x0int cxgb4_tc_flower_replace (struct net_device *dev,struct tc_cls_flower_offload *cls);
Signature · 1 line
2.14.1
David Miller
maintainerFrom: Rahul Lakkireddy <[email protected]>
Date: Wed, 18 Oct 2017 20:49:06 +0530
Quoted 2 lines
This patch series enable more matches and actions for TC Flower Offload support on Chelsio adapters.
Series applied, thank you.