return pos < size ? pos : -1;
}
+/**
+ * Clear a filter and release any of its resources that we own. This also
+ * clears the filter's "pending" status.
+ */
+static void clear_filter(struct filter_entry *f)
+{
+ if (f->clipt)
+ cxgbe_clip_release(f->dev, f->clipt);
+
+ /* The zeroing of the filter rule below clears the filter valid,
+ * pending, locked flags etc. so it's all we need for
+ * this operation.
+ */
+ memset(f, 0, sizeof(*f));
+}
+
/**
* Construct hash filter ntuple.
*/
f = t4_os_alloc(sizeof(*f));
if (!f)
- goto out_err;
+ return -ENOMEM;
f->fs = *fs;
f->ctx = ctx;
mbuf = rte_pktmbuf_alloc(ctrlq->mb_pool);
if (!mbuf) {
ret = -ENOMEM;
- goto free_clip;
+ goto free_atid;
}
mbuf->data_len = size;
t4_mgmt_tx(ctrlq, mbuf);
return 0;
-free_clip:
- cxgbe_clip_release(f->dev, f->clipt);
free_atid:
cxgbe_free_atid(t, atid);
out_err:
+ clear_filter(f);
t4_os_free(f);
return ret;
}
-/**
- * Clear a filter and release any of its resources that we own. This also
- * clears the filter's "pending" status.
- */
-static void clear_filter(struct filter_entry *f)
-{
- if (f->clipt)
- cxgbe_clip_release(f->dev, f->clipt);
-
- /*
- * The zeroing of the filter rule below clears the filter valid,
- * pending, locked flags etc. so it's all we need for
- * this operation.
- */
- memset(f, 0, sizeof(*f));
-}
-
/**
* t4_mk_filtdelwr - create a delete filter WR
* @adap: adapter context
return ret;
}
- /*
- * Allocate a clip table entry only if we have non-zero IPv6 address
- */
- if (chip_ver > CHELSIO_T5 && fs->type &&
- memcmp(fs->val.lip, bitoff, sizeof(bitoff))) {
- f->clipt = cxgbe_clip_alloc(dev, (u32 *)&fs->val.lip);
- if (!f->clipt)
- goto free_tid;
- }
-
/*
* Convert the filter specification into our internal format.
* We copy the PF/VF specification into the Outer VLAN field
f->fs.iq = iq;
f->dev = dev;
+ /* 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;
+ }
+ }
+
iconf = adapter->params.tp.ingress_config;
/* Either PFVF or OVLAN can be active, but not both
}
cxgbe_free_atid(t, ftid);
+ clear_filter(f);
t4_os_free(f);
}
}
ctx = f->ctx;
- f->ctx = NULL;
-
- f->valid = 0;
-
- if (f->clipt)
- cxgbe_clip_release(f->dev, f->clipt);
+ clear_filter(f);
cxgbe_remove_tid(t, 0, tid, 0);
t4_os_free(f);