X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fcxgbe%2Fcxgbe_filter.c;h=dcb1dd03eeb8cf6d93963f60bec0a8d0ce462c0d;hb=175bedb0cc8f801be3050fa35b8d8d0971cea7cc;hp=8c5890ea8f87edeb908afc9c727740553de5ee16;hpb=6b805d23a5fa59269683962eb2375907fc86a1f8;p=dpdk.git diff --git a/drivers/net/cxgbe/cxgbe_filter.c b/drivers/net/cxgbe/cxgbe_filter.c index 8c5890ea8f..dcb1dd03ee 100644 --- a/drivers/net/cxgbe/cxgbe_filter.c +++ b/drivers/net/cxgbe/cxgbe_filter.c @@ -8,6 +8,7 @@ #include "t4_regs.h" #include "cxgbe_filter.h" #include "clip_tbl.h" +#include "l2t.h" /** * Initialize Hash Filters @@ -65,12 +66,22 @@ 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 #undef U + /* + * If the user is requesting that the filter action loop + * matching packets back out one of our ports, make sure that + * the egress port is in range. + */ + if (fs->action == FILTER_SWITCH && + fs->eport >= adapter->params.nports) + return -ERANGE; + /* * Don't allow various trivially obvious bogus out-of-range * values ... @@ -155,6 +166,16 @@ static void set_tcb_field(struct adapter *adapter, unsigned int ftid, t4_mgmt_tx(ctrlq, mbuf); } +/** + * Set one of the t_flags bits in the TCB. + */ +static void set_tcb_tflag(struct adapter *adap, unsigned int ftid, + unsigned int bit_pos, unsigned int val, int no_reply) +{ + set_tcb_field(adap, ftid, W_TCB_T_FLAGS, 1ULL << bit_pos, + (unsigned long long)val << bit_pos, no_reply); +} + /** * Build a CPL_SET_TCB_FIELD message as payload of a ULP_TX_PKT command. */ @@ -248,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; @@ -416,9 +439,13 @@ static void mk_act_open_req6(struct filter_entry *f, struct rte_mbuf *mbuf, req->local_ip_lo = local_lo; req->peer_ip_hi = peer_hi; req->peer_ip_lo = peer_lo; - req->opt0 = cpu_to_be64(V_DELACK(f->fs.hitcnts) | + req->opt0 = cpu_to_be64(V_NAGLE(f->fs.newvlan == VLAN_REMOVE || + f->fs.newvlan == VLAN_REWRITE) | + V_DELACK(f->fs.hitcnts) | + V_L2T_IDX(f->l2t ? f->l2t->idx : 0) | V_SMAC_SEL((cxgbe_port_viid(f->dev) & 0x7F) << 1) | + V_TX_CHAN(f->fs.eport) | V_ULP_MODE(ULP_MODE_NONE) | F_TCAM_BYPASS | F_NON_OFFLOAD); req->params = cpu_to_be64(V_FILTER_TUPLE(hash_filter_ntuple(f))); @@ -427,7 +454,8 @@ static void mk_act_open_req6(struct filter_entry *f, struct rte_mbuf *mbuf, F_T5_OPT_2_VALID | F_RX_CHANNEL | V_CONG_CNTRL((f->fs.action == FILTER_DROP) | - (f->fs.dirsteer << 1))); + (f->fs.dirsteer << 1)) | + V_CCTRL_ECN(f->fs.action == FILTER_SWITCH)); } /** @@ -457,9 +485,13 @@ static void mk_act_open_req(struct filter_entry *f, struct rte_mbuf *mbuf, f->fs.val.lip[2] << 16 | f->fs.val.lip[3] << 24; req->peer_ip = f->fs.val.fip[0] | f->fs.val.fip[1] << 8 | f->fs.val.fip[2] << 16 | f->fs.val.fip[3] << 24; - req->opt0 = cpu_to_be64(V_DELACK(f->fs.hitcnts) | + req->opt0 = cpu_to_be64(V_NAGLE(f->fs.newvlan == VLAN_REMOVE || + f->fs.newvlan == VLAN_REWRITE) | + V_DELACK(f->fs.hitcnts) | + V_L2T_IDX(f->l2t ? f->l2t->idx : 0) | V_SMAC_SEL((cxgbe_port_viid(f->dev) & 0x7F) << 1) | + V_TX_CHAN(f->fs.eport) | V_ULP_MODE(ULP_MODE_NONE) | F_TCAM_BYPASS | F_NON_OFFLOAD); req->params = cpu_to_be64(V_FILTER_TUPLE(hash_filter_ntuple(f))); @@ -468,7 +500,8 @@ static void mk_act_open_req(struct filter_entry *f, struct rte_mbuf *mbuf, F_T5_OPT_2_VALID | F_RX_CHANNEL | V_CONG_CNTRL((f->fs.action == FILTER_DROP) | - (f->fs.dirsteer << 1))); + (f->fs.dirsteer << 1)) | + V_CCTRL_ECN(f->fs.action == FILTER_SWITCH)); } /** @@ -505,6 +538,22 @@ static int cxgbe_set_hash_filter(struct rte_eth_dev *dev, f->dev = dev; f->fs.iq = iq; + /* + * If the new filter requires loopback Destination MAC and/or VLAN + * rewriting then we need to allocate a Layer 2 Table (L2T) entry for + * the filter. + */ + if (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, + f->fs.eport, f->fs.dmac); + if (!f->l2t) { + ret = -ENOMEM; + goto out_err; + } + } + atid = cxgbe_alloc_atid(t, f); if (atid < 0) goto out_err; @@ -640,6 +689,19 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx) unsigned int port_id = ethdev2pinfo(dev)->port_id; int ret; + /* + * If the new filter requires loopback Destination MAC and/or VLAN + * rewriting then we need to allocate a Layer 2 Table (L2T) entry for + * the filter. + */ + if (f->fs.newvlan) { + /* 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; + } + ctrlq = &adapter->sge.ctrlq[port_id]; mbuf = rte_pktmbuf_alloc(ctrlq->mb_pool); if (!mbuf) { @@ -666,8 +728,17 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx) fwr->del_filter_to_l2tix = 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_INSVLAN + (f->fs.newvlan == VLAN_INSERT || + f->fs.newvlan == VLAN_REWRITE) | + V_FW_FILTER_WR_RMVLAN + (f->fs.newvlan == VLAN_REMOVE || + f->fs.newvlan == VLAN_REWRITE) | V_FW_FILTER_WR_HITCNTS(f->fs.hitcnts) | - V_FW_FILTER_WR_PRIO(f->fs.prio)); + V_FW_FILTER_WR_TXCHAN(f->fs.eport) | + V_FW_FILTER_WR_PRIO(f->fs.prio) | + V_FW_FILTER_WR_L2TIX(f->l2t ? f->l2t->idx : 0)); fwr->ethtype = cpu_to_be16(f->fs.val.ethtype); fwr->ethtypem = cpu_to_be16(f->fs.mask.ethtype); fwr->smac_sel = 0; @@ -676,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; @@ -1031,6 +1104,9 @@ void hash_filter_rpl(struct adapter *adap, const struct cpl_act_open_rpl *rpl) V_TCB_TIMESTAMP(0ULL) | V_TCB_T_RTT_TS_RECENT_AGE(0ULL), 1); + if (f->fs.newvlan == VLAN_INSERT || + f->fs.newvlan == VLAN_REWRITE) + set_tcb_tflag(adap, tid, S_TF_CCTRL_RFR, 1, 1); break; } default: