+ /* Allocate MPS TCAM entry to match Destination MAC. */
+ if (f->fs.mask.macidx) {
+ int idx;
+
+ idx = cxgbe_mpstcam_alloc(pi, f->fs.val.dmac, f->fs.mask.dmac);
+ if (idx <= 0) {
+ ret = -ENOMEM;
+ goto free_tid;
+ }
+
+ f->fs.val.macidx = idx;
+ }
+
+ /* Allocate a clip table entry only if we have non-zero IPv6 address. */
+ if (chip_ver > CHELSIO_T5 && f->fs.type &&
+ memcmp(f->fs.val.lip, bitoff, sizeof(bitoff))) {
+ f->clipt = cxgbe_clip_alloc(dev, (u32 *)&f->fs.val.lip);
+ if (!f->clipt) {
+ ret = -ENOMEM;
+ goto free_tid;
+ }
+ }
+
+ /* 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 || f->fs.newdmac) {
+ f->l2t = cxgbe_l2t_alloc_switching(f->dev, f->fs.vlan,
+ f->fs.eport, f->fs.dmac);
+ if (!f->l2t) {
+ ret = -ENOMEM;
+ goto free_tid;
+ }
+ }
+
+ /* If the new filter requires Source MAC rewriting then we need to
+ * allocate a SMT entry for the filter
+ */
+ if (f->fs.newsmac) {
+ f->smt = cxgbe_smt_alloc_switching(f->dev, f->fs.smac);
+ if (!f->smt) {
+ ret = -ENOMEM;
+ goto free_tid;
+ }
+ }
+
+ iconf = adapter->params.tp.ingress_config;
+
+ /* Either PFVF or OVLAN can be active, but not both
+ * So, if PFVF is enabled, then overwrite the OVLAN
+ * fields with PFVF fields before writing the spec
+ * to hardware.
+ */
+ if (iconf & F_VNIC) {
+ f->fs.val.ovlan = fs->val.pf << 13 | fs->val.vf;
+ f->fs.mask.ovlan = fs->mask.pf << 13 | fs->mask.vf;
+ f->fs.val.ovlan_vld = fs->val.pfvf_vld;
+ f->fs.mask.ovlan_vld = fs->mask.pfvf_vld;
+ }
+