crypto/snow3g: add dynamic logging
[dpdk.git] / drivers / net / cxgbe / cxgbe_filter.c
index ff43488..7f0d380 100644 (file)
@@ -65,11 +65,28 @@ int validate_filter(struct adapter *adapter, struct ch_filter_specification *fs)
 #define U(_mask, _field) \
        (!(fconf & (_mask)) && S(_field))
 
-       if (U(F_ETHERTYPE, ethtype) || U(F_PROTOCOL, proto))
+       if (U(F_PORT, iport) || U(F_ETHERTYPE, ethtype) || U(F_PROTOCOL, proto))
                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 ...
+        */
+       if (fs->val.iport >= adapter->params.nports)
+               return -ERANGE;
+
        return 0;
 }
 
@@ -228,6 +245,9 @@ static u64 hash_filter_ntuple(const struct filter_entry *f)
        u64 ntuple = 0;
        u16 tcp_proto = IPPROTO_TCP; /* TCP Protocol Number */
 
+       if (tp->port_shift >= 0)
+               ntuple |= (u64)f->fs.mask.iport << tp->port_shift;
+
        if (tp->protocol_shift >= 0) {
                if (!f->fs.val.proto)
                        ntuple |= (u64)tcp_proto << tp->protocol_shift;
@@ -408,6 +428,7 @@ static void mk_act_open_req6(struct filter_entry *f, struct rte_mbuf *mbuf,
        req->opt0 = cpu_to_be64(V_DELACK(f->fs.hitcnts) |
                                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)));
@@ -416,7 +437,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));
 }
 
 /**
@@ -449,6 +471,7 @@ static void mk_act_open_req(struct filter_entry *f, struct rte_mbuf *mbuf,
        req->opt0 = cpu_to_be64(V_DELACK(f->fs.hitcnts) |
                                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)));
@@ -457,7 +480,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));
 }
 
 /**
@@ -655,7 +679,9 @@ 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_HITCNTS(f->fs.hitcnts) |
+                           V_FW_FILTER_WR_TXCHAN(f->fs.eport) |
                            V_FW_FILTER_WR_PRIO(f->fs.prio));
        fwr->ethtype = cpu_to_be16(f->fs.val.ethtype);
        fwr->ethtypem = cpu_to_be16(f->fs.mask.ethtype);
@@ -664,6 +690,9 @@ int set_filter_wr(struct rte_eth_dev *dev, unsigned int fidx)
                cpu_to_be16(V_FW_FILTER_WR_RX_CHAN(0) |
                            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) |
+                           V_FW_FILTER_WR_PORTM(f->fs.mask.iport));
        fwr->ptcl = f->fs.val.proto;
        fwr->ptclm = f->fs.mask.proto;
        rte_memcpy(fwr->lip, f->fs.val.lip, sizeof(fwr->lip));