From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 77864A0567; Wed, 11 Mar 2020 10:17:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 745871C05C; Wed, 11 Mar 2020 10:16:54 +0100 (CET) Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by dpdk.org (Postfix) with ESMTP id D29021C05C for ; Wed, 11 Mar 2020 10:16:52 +0100 (CET) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id 02B9GoWx014336; Wed, 11 Mar 2020 02:16:51 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Cc: nirranjan@chelsio.com, kaara.satwik@chelsio.com Date: Wed, 11 Mar 2020 14:35:47 +0530 Message-Id: <8588b54e1962e4c92f8f31543308cfe9d8942ace.1583906144.git.kaara.satwik@chelsio.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 5/9] net/cxgbe: add rte_flow support for overwriting destination MAC X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Karra Satwik Add support for overwriting destination MAC addresses. The new MAC address is written into a free entry in the L2T table and the corresponding L2T index is used by hardware to overwrite the destination MAC address of the packets hitting the flow Signed-off-by: Karra Satwik Signed-off-by: Rahul Lakkireddy --- drivers/net/cxgbe/base/t4_tcb.h | 2 ++ drivers/net/cxgbe/cxgbe_filter.c | 8 ++++++-- drivers/net/cxgbe/cxgbe_filter.h | 1 + drivers/net/cxgbe/cxgbe_flow.c | 14 ++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/cxgbe/base/t4_tcb.h b/drivers/net/cxgbe/base/t4_tcb.h index 3c590e053..834169ab4 100644 --- a/drivers/net/cxgbe/base/t4_tcb.h +++ b/drivers/net/cxgbe/base/t4_tcb.h @@ -32,6 +32,8 @@ #define M_TCB_T_RTSEQ_RECENT 0xffffffffULL #define V_TCB_T_RTSEQ_RECENT(x) ((x) << S_TCB_T_RTSEQ_RECENT) +#define S_TF_CCTRL_ECE 60 + #define S_TF_CCTRL_RFR 62 #endif /* _T4_TCB_DEFS_H */ diff --git a/drivers/net/cxgbe/cxgbe_filter.c b/drivers/net/cxgbe/cxgbe_filter.c index 9c10520b2..b009217f8 100644 --- a/drivers/net/cxgbe/cxgbe_filter.c +++ b/drivers/net/cxgbe/cxgbe_filter.c @@ -593,7 +593,7 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, * rewriting then we need to allocate a Layer 2 Table (L2T) entry for * the filter. */ - if (f->fs.newvlan == VLAN_INSERT || + if (f->fs.newdmac || f->fs.newvlan == VLAN_INSERT || f->fs.newvlan == VLAN_REWRITE) { /* allocate L2T entry for new filter */ f->l2t = cxgbe_l2t_alloc_switching(dev, f->fs.vlan, @@ -749,10 +749,11 @@ static int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx) * rewriting then we need to allocate a Layer 2 Table (L2T) entry for * the filter. */ - if (f->fs.newvlan) { + if (f->fs.newvlan || f->fs.newdmac) { /* allocate L2T entry for new filter */ f->l2t = cxgbe_l2t_alloc_switching(f->dev, f->fs.vlan, f->fs.eport, f->fs.dmac); + if (!f->l2t) return -ENOMEM; } @@ -787,6 +788,7 @@ static int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx) cpu_to_be32(V_FW_FILTER_WR_DROP(f->fs.action == FILTER_DROP) | V_FW_FILTER_WR_DIRSTEER(f->fs.dirsteer) | V_FW_FILTER_WR_LPBK(f->fs.action == FILTER_SWITCH) | + V_FW_FILTER_WR_DMAC(f->fs.newdmac) | V_FW_FILTER_WR_INSVLAN (f->fs.newvlan == VLAN_INSERT || f->fs.newvlan == VLAN_REWRITE) | @@ -1137,6 +1139,8 @@ void cxgbe_hash_filter_rpl(struct adapter *adap, V_TCB_TIMESTAMP(0ULL) | V_TCB_T_RTT_TS_RECENT_AGE(0ULL), 1); + if (f->fs.newdmac) + set_tcb_tflag(adap, tid, S_TF_CCTRL_ECE, 1, 1); if (f->fs.newvlan == VLAN_INSERT || f->fs.newvlan == VLAN_REWRITE) set_tcb_tflag(adap, tid, S_TF_CCTRL_RFR, 1, 1); diff --git a/drivers/net/cxgbe/cxgbe_filter.h b/drivers/net/cxgbe/cxgbe_filter.h index 6b1bf25e2..7a1e72ded 100644 --- a/drivers/net/cxgbe/cxgbe_filter.h +++ b/drivers/net/cxgbe/cxgbe_filter.h @@ -100,6 +100,7 @@ struct ch_filter_specification { uint32_t iq:10; /* ingress queue */ uint32_t eport:2; /* egress port to switch packet out */ + uint32_t newdmac:1; /* rewrite destination MAC address */ uint32_t swapmac:1; /* swap SMAC/DMAC for loopback packet */ uint32_t newvlan:2; /* rewrite VLAN Tag */ uint8_t dmac[RTE_ETHER_ADDR_LEN]; /* new destination MAC address */ diff --git a/drivers/net/cxgbe/cxgbe_flow.c b/drivers/net/cxgbe/cxgbe_flow.c index 3e27a3f68..b009005c5 100644 --- a/drivers/net/cxgbe/cxgbe_flow.c +++ b/drivers/net/cxgbe/cxgbe_flow.c @@ -647,6 +647,7 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a, const struct rte_flow_action_set_ipv6 *ipv6; const struct rte_flow_action_set_tp *tp_port; const struct rte_flow_action_phy_port *port; + const struct rte_flow_action_set_mac *mac; int item_index; u16 tmp_vlan; @@ -794,6 +795,18 @@ ch_rte_parse_atype_switch(const struct rte_flow_action *a, "found"); fs->swapmac = 1; break; + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: + item_index = cxgbe_get_flow_item_index(items, + RTE_FLOW_ITEM_TYPE_ETH); + if (item_index < 0) + return rte_flow_error_set(e, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, a, + "No RTE_FLOW_ITEM_TYPE_ETH found"); + mac = (const struct rte_flow_action_set_mac *)a->conf; + + fs->newdmac = 1; + memcpy(fs->dmac, mac->mac_addr, sizeof(fs->dmac)); + break; default: /* We are not supposed to come here */ return rte_flow_error_set(e, EINVAL, @@ -870,6 +883,7 @@ cxgbe_rtef_parse_actions(struct rte_flow *flow, goto action_switch; case RTE_FLOW_ACTION_TYPE_SET_TP_SRC: case RTE_FLOW_ACTION_TYPE_SET_TP_DST: + case RTE_FLOW_ACTION_TYPE_SET_MAC_DST: action_switch: /* We allow multiple switch actions, but switch is * not compatible with either queue or drop -- 2.25.0