From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from stargate.chelsio.com (stargate.chelsio.com [12.32.117.8]) by dpdk.org (Postfix) with ESMTP id D52995F20 for ; Mon, 27 Aug 2018 14:53:02 +0200 (CEST) Received: from localhost (scalar.blr.asicdesigners.com [10.193.185.94]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id w7RCqxou027073; Mon, 27 Aug 2018 05:53:00 -0700 From: Rahul Lakkireddy To: dev@dpdk.org Cc: shaguna@chelsio.com, indranil@chelsio.com, nirranjan@chelsio.com Date: Mon, 27 Aug 2018 18:22:32 +0530 Message-Id: <0122a9eac9e37bcf293ae71506e4b0eb11fa4030.1535292771.git.rahul.lakkireddy@chelsio.com> X-Mailer: git-send-email 2.5.3 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH 4/4] net/cxgbe: add flow operations to match based on destination MAC address 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: , X-List-Received-Date: Mon, 27 Aug 2018 12:53:03 -0000 From: Shagun Agrawal Add flow operations to match packets based on destination MAC address. Allocate and program hardware MPS table with the destination MAC address to be matched against. The returned MPS index is then used while offloading flows to LETCAM (maskfull) and HASH (maskless) filter regions. Also update existing mac_addr_set() to use the new MPS table API. Signed-off-by: Shagun Agrawal Signed-off-by: Rahul Lakkireddy --- doc/guides/rel_notes/release_18_11.rst | 1 + drivers/net/cxgbe/base/common.h | 1 + drivers/net/cxgbe/base/t4_hw.c | 2 ++ drivers/net/cxgbe/cxgbe_ethdev.c | 4 +-- drivers/net/cxgbe/cxgbe_filter.c | 9 +++-- drivers/net/cxgbe/cxgbe_filter.h | 1 + drivers/net/cxgbe/cxgbe_flow.c | 66 ++++++++++++++++++++++++++++++++-- drivers/net/cxgbe/cxgbe_flow.h | 1 + drivers/net/cxgbe/cxgbe_main.c | 6 ++-- 9 files changed, 80 insertions(+), 11 deletions(-) diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst index db99518f4..f7bef95e1 100644 --- a/doc/guides/rel_notes/release_18_11.rst +++ b/doc/guides/rel_notes/release_18_11.rst @@ -58,6 +58,7 @@ New Features Flow API support has been enhanced for CXGBE Poll Mode Driver to offload: + * Match items: destination MAC address. * Action items: push/pop/rewrite vlan header. diff --git a/drivers/net/cxgbe/base/common.h b/drivers/net/cxgbe/base/common.h index 9f5756850..d9f74d995 100644 --- a/drivers/net/cxgbe/base/common.h +++ b/drivers/net/cxgbe/base/common.h @@ -157,6 +157,7 @@ struct tp_params { int port_shift; int protocol_shift; int ethertype_shift; + int macmatch_shift; u64 hash_filter_mask; }; diff --git a/drivers/net/cxgbe/base/t4_hw.c b/drivers/net/cxgbe/base/t4_hw.c index d60894115..701e0b1fe 100644 --- a/drivers/net/cxgbe/base/t4_hw.c +++ b/drivers/net/cxgbe/base/t4_hw.c @@ -5251,6 +5251,8 @@ int t4_init_tp_params(struct adapter *adap) F_PROTOCOL); adap->params.tp.ethertype_shift = t4_filter_field_shift(adap, F_ETHERTYPE); + adap->params.tp.macmatch_shift = t4_filter_field_shift(adap, + F_MACMATCH); /* * If TP_INGRESS_CONFIG.VNID == 0, then TP_VLAN_PRI_MAP.VNIC_ID diff --git a/drivers/net/cxgbe/cxgbe_ethdev.c b/drivers/net/cxgbe/cxgbe_ethdev.c index 4dcad7a23..f253c2023 100644 --- a/drivers/net/cxgbe/cxgbe_ethdev.c +++ b/drivers/net/cxgbe/cxgbe_ethdev.c @@ -1075,11 +1075,9 @@ static int cxgbe_get_regs(struct rte_eth_dev *eth_dev, int cxgbe_mac_addr_set(struct rte_eth_dev *dev, struct ether_addr *addr) { struct port_info *pi = (struct port_info *)(dev->data->dev_private); - struct adapter *adapter = pi->adapter; int ret; - ret = t4_change_mac(adapter, adapter->mbox, pi->viid, - pi->xact_addr_filt, (u8 *)addr, true, true); + ret = cxgbe_mpstcam_modify(pi, (int)pi->xact_addr_filt, (u8 *)addr); if (ret < 0) { dev_err(adapter, "failed to set mac addr; err = %d\n", ret); diff --git a/drivers/net/cxgbe/cxgbe_filter.c b/drivers/net/cxgbe/cxgbe_filter.c index 4d3f3ebee..dcb1dd03e 100644 --- a/drivers/net/cxgbe/cxgbe_filter.c +++ b/drivers/net/cxgbe/cxgbe_filter.c @@ -66,7 +66,8 @@ int validate_filter(struct adapter *adapter, struct ch_filter_specification *fs) #define U(_mask, _field) \ (!(fconf & (_mask)) && S(_field)) - if (U(F_PORT, iport) || U(F_ETHERTYPE, ethtype) || U(F_PROTOCOL, proto)) + if (U(F_PORT, iport) || U(F_ETHERTYPE, ethtype) || + U(F_PROTOCOL, proto) || U(F_MACMATCH, macidx)) return -EOPNOTSUPP; #undef S @@ -268,6 +269,8 @@ static u64 hash_filter_ntuple(const struct filter_entry *f) if (tp->ethertype_shift >= 0 && f->fs.mask.ethtype) ntuple |= (u64)(f->fs.val.ethtype) << tp->ethertype_shift; + if (tp->macmatch_shift >= 0 && f->fs.mask.macidx) + ntuple |= (u64)(f->fs.val.macidx) << tp->macmatch_shift; if (ntuple != tp->hash_filter_mask) return 0; @@ -744,7 +747,9 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx) V_FW_FILTER_WR_RX_RPL_IQ(adapter->sge.fw_evtq.abs_id )); fwr->maci_to_matchtypem = - cpu_to_be32(V_FW_FILTER_WR_PORT(f->fs.val.iport) | + cpu_to_be32(V_FW_FILTER_WR_MACI(f->fs.val.macidx) | + V_FW_FILTER_WR_MACIM(f->fs.mask.macidx) | + V_FW_FILTER_WR_PORT(f->fs.val.iport) | V_FW_FILTER_WR_PORTM(f->fs.mask.iport)); fwr->ptcl = f->fs.val.proto; fwr->ptclm = f->fs.mask.proto; diff --git a/drivers/net/cxgbe/cxgbe_filter.h b/drivers/net/cxgbe/cxgbe_filter.h index c7d9366a6..83d647de6 100644 --- a/drivers/net/cxgbe/cxgbe_filter.h +++ b/drivers/net/cxgbe/cxgbe_filter.h @@ -77,6 +77,7 @@ struct ch_filter_tuple { * Filter specification */ struct ch_filter_specification { + void *private; /* Administrative fields for filter. */ uint32_t hitcnts:1; /* count filter hits in TCB */ uint32_t prio:1; /* filter has priority over active/server */ diff --git a/drivers/net/cxgbe/cxgbe_flow.c b/drivers/net/cxgbe/cxgbe_flow.c index 89fc68cf0..add4f0f95 100644 --- a/drivers/net/cxgbe/cxgbe_flow.c +++ b/drivers/net/cxgbe/cxgbe_flow.c @@ -95,6 +95,8 @@ cxgbe_fill_filter_region(struct adapter *adap, ntuple_mask |= (u64)fs->mask.ethtype << tp->ethertype_shift; if (tp->port_shift >= 0) ntuple_mask |= (u64)fs->mask.iport << tp->port_shift; + if (tp->macmatch_shift >= 0) + ntuple_mask |= (u64)fs->mask.macidx << tp->macmatch_shift; if (ntuple_mask != hash_filter_mask) return; @@ -102,6 +104,46 @@ cxgbe_fill_filter_region(struct adapter *adap, fs->cap = 1; /* use hash region */ } +static int +ch_rte_parsetype_eth(const void *dmask, const struct rte_flow_item *item, + struct ch_filter_specification *fs, + struct rte_flow_error *e) +{ + const struct rte_flow_item_eth *spec = item->spec; + const struct rte_flow_item_eth *umask = item->mask; + const struct rte_flow_item_eth *mask; + + /* If user has not given any mask, then use chelsio supported mask. */ + mask = umask ? umask : (const struct rte_flow_item_eth *)dmask; + + /* we don't support SRC_MAC filtering*/ + if (!is_zero_ether_addr(&mask->src)) + return rte_flow_error_set(e, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, + item, + "src mac filtering not supported"); + + if (!is_zero_ether_addr(&mask->dst)) { + const u8 *addr = (const u8 *)&spec->dst.addr_bytes[0]; + const u8 *m = (const u8 *)&mask->dst.addr_bytes[0]; + struct rte_flow *flow = (struct rte_flow *)fs->private; + struct port_info *pi = (struct port_info *) + (flow->dev->data->dev_private); + int idx; + + idx = cxgbe_mpstcam_alloc(pi, addr, m); + if (idx <= 0) + return rte_flow_error_set(e, idx, + RTE_FLOW_ERROR_TYPE_ITEM, + NULL, "unable to allocate mac" + " entry in h/w"); + CXGBE_FILL_FS(idx, 0x1ff, macidx); + } + + CXGBE_FILL_FS(be16_to_cpu(spec->type), + be16_to_cpu(mask->type), ethtype); + return 0; +} + static int ch_rte_parsetype_port(const void *dmask, const struct rte_flow_item *item, struct ch_filter_specification *fs, @@ -440,7 +482,16 @@ cxgbe_rtef_parse_actions(struct rte_flow *flow, } struct chrte_fparse parseitem[] = { - [RTE_FLOW_ITEM_TYPE_PHY_PORT] = { + [RTE_FLOW_ITEM_TYPE_ETH] = { + .fptr = ch_rte_parsetype_eth, + .dmask = &(const struct rte_flow_item_eth){ + .dst.addr_bytes = "\xff\xff\xff\xff\xff\xff", + .src.addr_bytes = "\x00\x00\x00\x00\x00\x00", + .type = 0xffff, + } + }, + + [RTE_FLOW_ITEM_TYPE_PHY_PORT] = { .fptr = ch_rte_parsetype_port, .dmask = &(const struct rte_flow_item_phy_port){ .index = 0x7, @@ -527,7 +578,6 @@ cxgbe_flow_parse(struct rte_flow *flow, struct rte_flow_error *e) { int ret; - /* parse user request into ch_filter_specification */ ret = cxgbe_rtef_parse_attr(flow, attr, e); if (ret) @@ -606,6 +656,7 @@ cxgbe_flow_create(struct rte_eth_dev *dev, flow->item_parser = parseitem; flow->dev = dev; + flow->fs.private = (void *)flow; if (cxgbe_flow_parse(flow, attr, item, action, e)) { t4_os_free(flow); @@ -660,6 +711,17 @@ static int __cxgbe_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow) return ctx.result; } + fs = &flow->fs; + if (fs->mask.macidx) { + struct port_info *pi = (struct port_info *) + (dev->data->dev_private); + int ret; + + ret = cxgbe_mpstcam_remove(pi, fs->val.macidx); + if (!ret) + return ret; + } + return 0; } diff --git a/drivers/net/cxgbe/cxgbe_flow.h b/drivers/net/cxgbe/cxgbe_flow.h index 0f7504745..718bf3d05 100644 --- a/drivers/net/cxgbe/cxgbe_flow.h +++ b/drivers/net/cxgbe/cxgbe_flow.h @@ -7,6 +7,7 @@ #include #include "cxgbe_filter.h" +#include "mps_tcam.h" #include "cxgbe.h" #define CXGBE_FLOW_POLL_US 10 diff --git a/drivers/net/cxgbe/cxgbe_main.c b/drivers/net/cxgbe/cxgbe_main.c index 20d2de442..9c40f51b2 100644 --- a/drivers/net/cxgbe/cxgbe_main.c +++ b/drivers/net/cxgbe/cxgbe_main.c @@ -1342,10 +1342,8 @@ int link_start(struct port_info *pi) ret = t4_set_rxmode(adapter, adapter->mbox, pi->viid, mtu, -1, -1, -1, 1, true); if (ret == 0) { - ret = t4_change_mac(adapter, adapter->mbox, pi->viid, - pi->xact_addr_filt, - (u8 *)&pi->eth_dev->data->mac_addrs[0], - true, true); + ret = cxgbe_mpstcam_modify(pi, (int)pi->xact_addr_filt, + (u8 *)&pi->eth_dev->data->mac_addrs[0]); if (ret >= 0) { pi->xact_addr_filt = ret; ret = 0; -- 2.14.1