net/softnic: delete meter profile
authorJasvinder Singh <jasvinder.singh@intel.com>
Wed, 26 Sep 2018 13:08:47 +0000 (14:08 +0100)
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>
Fri, 12 Oct 2018 15:59:10 +0000 (17:59 +0200)
Implement meter profile delete function.

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
drivers/net/softnic/rte_eth_softnic_meter.c

index 1222866..f3205bd 100644 (file)
@@ -131,11 +131,44 @@ pmd_mtr_meter_profile_add(struct rte_eth_dev *dev,
        return 0;
 }
 
+/* MTR meter profile delete */
+static int
+pmd_mtr_meter_profile_delete(struct rte_eth_dev *dev,
+       uint32_t meter_profile_id,
+       struct rte_mtr_error *error)
+{
+       struct pmd_internals *p = dev->data->dev_private;
+       struct softnic_mtr_meter_profile *mp;
+
+       /* Meter profile must exist */
+       mp = softnic_mtr_meter_profile_find(p, meter_profile_id);
+       if (mp == NULL)
+               return -rte_mtr_error_set(error,
+                       EINVAL,
+                       RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
+                       NULL,
+                       "Meter profile id invalid");
+
+       /* Check unused */
+       if (mp->n_users)
+               return -rte_mtr_error_set(error,
+                       EBUSY,
+                       RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
+                       NULL,
+                       "Meter profile in use");
+
+       /* Remove from list */
+       TAILQ_REMOVE(&p->mtr.meter_profiles, mp, node);
+       free(mp);
+
+       return 0;
+}
+
 const struct rte_mtr_ops pmd_mtr_ops = {
        .capabilities_get = NULL,
 
        .meter_profile_add = pmd_mtr_meter_profile_add,
-       .meter_profile_delete = NULL,
+       .meter_profile_delete = pmd_mtr_meter_profile_delete,
 
        .create = NULL,
        .destroy = NULL,