net/cxgbe: support flow API for destination MAC rewrite
authorKarra Satwik <kaara.satwik@chelsio.com>
Wed, 11 Mar 2020 09:05:47 +0000 (14:35 +0530)
committerFerruh Yigit <ferruh.yigit@intel.com>
Wed, 18 Mar 2020 14:29:39 +0000 (15:29 +0100)
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 <kaara.satwik@chelsio.com>
Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
drivers/net/cxgbe/base/t4_tcb.h
drivers/net/cxgbe/cxgbe_filter.c
drivers/net/cxgbe/cxgbe_filter.h
drivers/net/cxgbe/cxgbe_flow.c

index 3c590e0..834169a 100644 (file)
@@ -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 */
index 9c10520..b009217 100644 (file)
@@ -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);
index 6b1bf25..7a1e72d 100644 (file)
@@ -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 */
index 10fc6fc..d731fdc 100644 (file)
@@ -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