Re: [lng-odp] [API-NEXT PATCHv2 1/4] api: classification: add pmr create api

2016-02-02 Thread Bala Manoharan
Regards,
Bala


On 2 February 2016 at 14:53, Savolainen, Petri (Nokia - FI/Espoo)
 wrote:
>
>
>> -Original Message-
>> From: EXT Balasubramanian Manoharan [mailto:bala.manoha...@linaro.org]
>> Sent: Monday, February 01, 2016 2:56 PM
>> To: lng-odp@lists.linaro.org
>> Cc: Savolainen, Petri (Nokia - FI/Espoo); Balasubramanian Manoharan
>> Subject: [API-NEXT PATCHv2 1/4] api: classification: add pmr create api
>>
>> Packet match rule creation is modified to include source and destination
>> class of service. Removes the ability to add any class of service directly
>> with pktio. If a PMR needs to be applied at the pktio level the same
>> should be applied to default class of service.
>>
>> Packet match rule destroy function is updated to removes the link between
>> the source and destination class of service.
>>
>> odp_pmr_match_set_t handle is removed and pmr create function is modified
>> to take number of terms and composite rule is created by providing more
>> than one term.
>>
>> Signed-off-by: Balasubramanian Manoharan 
>> ---
>> v2: removes pmr match set
>>
>>  include/odp/api/classification.h | 142 ++
>> -
>>  1 file changed, 35 insertions(+), 107 deletions(-)
>>
>> diff --git a/include/odp/api/classification.h
>> b/include/odp/api/classification.h
>> index f46912e..263ea7c 100644
>> --- a/include/odp/api/classification.h
>> +++ b/include/odp/api/classification.h
>> @@ -50,16 +50,11 @@ extern "C" {
>>  /**
>>   * @def ODP_PMR_INVAL
>>   * Invalid odp_pmr_t value.
>> - * This value is returned from odp_pmr_create()
>> + * This value is returned from odp_cls_pmr_create()
>>   * function on failure.
>>   */
>>
>>  /**
>> - * @def ODP_PMR_SET_INVAL
>> - * Invalid odp_pmr_set_t value.
>> - */
>> -
>> -/**
>>   * class of service packet drop policies
>>   */
>>  typedef enum {
>> @@ -286,50 +281,54 @@ typedef struct odp_pmr_match_t {
>>  } odp_pmr_match_t;
>>
>>  /**
>> - * Create a packet match rule with mask and value
>> + * Create a packet match rule between source and destination class of
>> service.
>> + * This packet matching rule is applied on all packets arriving at the
>> source
>> + * class of service and packets satisfying this PMR are sent to the
>> destination
>> + * class of service.
>> + * A composite PMR rule is created when the number of terms in the match
>> rule
>> + * is more than one. The composite rule is considered as matching only if
>> + * the packet satisfies all the terms in Packet Match Rule.
>> + * The underlying platform may not support all or any specific
>> combination
>> + * of value match rules, and the application should take care
>> + * of inspecting the return value when installing such rules, and perform
>> + * appropriate fallback action.
>>   *
>> - * @param[in]match   packet matching rule definition
>> + * @param[in]num_terms   Number of terms in the match rule.
>> + * @param[in]terms   Array of odp_pmr_match_t entries, one 
>> entry
>> per
>> + *   term desired.
>> + * @param[in]src_cos source CoS handle
>> + * @param[in]dst_cos destination CoS handle
>>   *
>> - * @return   Handle of the matching rule
>> - * @retval   ODP_PMR_INVAL on failure
>> + * @retval   Hanlde to the Packet Match Rule.
>
> Typo  ^^
>
> Use @return instead of @retval, when the value is not predefined (a valid 
> handle).

Okay.
>
>
>> + * @retval   ODP_PMR_INVAL on failure
>>   */
>> -odp_pmr_t odp_pmr_create(const odp_pmr_match_t *match);
>> +odp_pmr_t odp_cls_pmr_create(int num_terms, const odp_pmr_match_t *terms,
>> +  odp_cos_t src_cos, odp_cos_t dst_cos);
>
>
> To match similar function prototypes in other APIs (e.g. xxx_multi()):
> - first the table as an array
> - then number of elements in the array
>
> odp_pmr_t odp_cls_pmr_create(const odp_pmr_match_t terms[], int num_terms, 
> odp_cos_t src_cos, odp_cos_t dst_cos);
>
>
> For example, it's easier to understand what "1" (or num) stands for when 
> defined like this ...
>
> odp_cls_pmr_create(terms, 1, src_cos, dst_cos);
>
> ... instead of this.
>
> odp_cls_pmr_create(1, terms, src_cos, dst_cos);

Agreed.
>
>
>
>
>
>>
>>  /**
>> - * Invalidate a packet match rule and vacate its resources
>> + * Function to destroy a packet match rule
>> + * Destroying a PMR removes the link between the source and destination
>> + * class of service and this PMR will no longer be applied for packets
>> arriving
>> + * at the source class of service. All the resource associated with the
>> PMR
>> + * be release but the class of service will remain intact.
>> + * Depending on the implementation details, destroying a composite rule
>> + * may not guarantee the availability of hardware resources to create the
>> + * same or essentially similar rule.
>>   *
>>   * @param[in]pmr_id  Identifier of the PMR to be destroyed

Re: [lng-odp] [API-NEXT PATCHv2 1/4] api: classification: add pmr create api

2016-02-02 Thread Savolainen, Petri (Nokia - FI/Espoo)


> -Original Message-
> From: EXT Balasubramanian Manoharan [mailto:bala.manoha...@linaro.org]
> Sent: Monday, February 01, 2016 2:56 PM
> To: lng-odp@lists.linaro.org
> Cc: Savolainen, Petri (Nokia - FI/Espoo); Balasubramanian Manoharan
> Subject: [API-NEXT PATCHv2 1/4] api: classification: add pmr create api
> 
> Packet match rule creation is modified to include source and destination
> class of service. Removes the ability to add any class of service directly
> with pktio. If a PMR needs to be applied at the pktio level the same
> should be applied to default class of service.
> 
> Packet match rule destroy function is updated to removes the link between
> the source and destination class of service.
> 
> odp_pmr_match_set_t handle is removed and pmr create function is modified
> to take number of terms and composite rule is created by providing more
> than one term.
> 
> Signed-off-by: Balasubramanian Manoharan 
> ---
> v2: removes pmr match set
> 
>  include/odp/api/classification.h | 142 ++
> -
>  1 file changed, 35 insertions(+), 107 deletions(-)
> 
> diff --git a/include/odp/api/classification.h
> b/include/odp/api/classification.h
> index f46912e..263ea7c 100644
> --- a/include/odp/api/classification.h
> +++ b/include/odp/api/classification.h
> @@ -50,16 +50,11 @@ extern "C" {
>  /**
>   * @def ODP_PMR_INVAL
>   * Invalid odp_pmr_t value.
> - * This value is returned from odp_pmr_create()
> + * This value is returned from odp_cls_pmr_create()
>   * function on failure.
>   */
> 
>  /**
> - * @def ODP_PMR_SET_INVAL
> - * Invalid odp_pmr_set_t value.
> - */
> -
> -/**
>   * class of service packet drop policies
>   */
>  typedef enum {
> @@ -286,50 +281,54 @@ typedef struct odp_pmr_match_t {
>  } odp_pmr_match_t;
> 
>  /**
> - * Create a packet match rule with mask and value
> + * Create a packet match rule between source and destination class of
> service.
> + * This packet matching rule is applied on all packets arriving at the
> source
> + * class of service and packets satisfying this PMR are sent to the
> destination
> + * class of service.
> + * A composite PMR rule is created when the number of terms in the match
> rule
> + * is more than one. The composite rule is considered as matching only if
> + * the packet satisfies all the terms in Packet Match Rule.
> + * The underlying platform may not support all or any specific
> combination
> + * of value match rules, and the application should take care
> + * of inspecting the return value when installing such rules, and perform
> + * appropriate fallback action.
>   *
> - * @param[in]match   packet matching rule definition
> + * @param[in]num_terms   Number of terms in the match rule.
> + * @param[in]terms   Array of odp_pmr_match_t entries, one 
> entry
> per
> + *   term desired.
> + * @param[in]src_cos source CoS handle
> + * @param[in]dst_cos destination CoS handle
>   *
> - * @return   Handle of the matching rule
> - * @retval   ODP_PMR_INVAL on failure
> + * @retval   Hanlde to the Packet Match Rule.

Typo  ^^

Use @return instead of @retval, when the value is not predefined (a valid 
handle).


> + * @retval   ODP_PMR_INVAL on failure
>   */
> -odp_pmr_t odp_pmr_create(const odp_pmr_match_t *match);
> +odp_pmr_t odp_cls_pmr_create(int num_terms, const odp_pmr_match_t *terms,
> +  odp_cos_t src_cos, odp_cos_t dst_cos);


To match similar function prototypes in other APIs (e.g. xxx_multi()):
- first the table as an array
- then number of elements in the array

odp_pmr_t odp_cls_pmr_create(const odp_pmr_match_t terms[], int num_terms, 
odp_cos_t src_cos, odp_cos_t dst_cos);


For example, it's easier to understand what "1" (or num) stands for when 
defined like this ...

odp_cls_pmr_create(terms, 1, src_cos, dst_cos);

... instead of this.

odp_cls_pmr_create(1, terms, src_cos, dst_cos);





> 
>  /**
> - * Invalidate a packet match rule and vacate its resources
> + * Function to destroy a packet match rule
> + * Destroying a PMR removes the link between the source and destination
> + * class of service and this PMR will no longer be applied for packets
> arriving
> + * at the source class of service. All the resource associated with the
> PMR
> + * be release but the class of service will remain intact.
> + * Depending on the implementation details, destroying a composite rule
> + * may not guarantee the availability of hardware resources to create the
> + * same or essentially similar rule.
>   *
>   * @param[in]pmr_id  Identifier of the PMR to be destroyed
>   *
>   * @retval   0 on success
>   * @retval   <0 on failure
>   */
> -int odp_pmr_destroy(odp_pmr_t pmr_id);
> +int odp_cls_pmr_destroy(odp_pmr_t pmr_id);
> 
> -/**
> - * Apply a PMR to a pktio to assign a CoS.
> - *
> - * @

[lng-odp] [API-NEXT PATCHv2 1/4] api: classification: add pmr create api

2016-02-01 Thread Balasubramanian Manoharan
Packet match rule creation is modified to include source and destination
class of service. Removes the ability to add any class of service directly
with pktio. If a PMR needs to be applied at the pktio level the same
should be applied to default class of service.

Packet match rule destroy function is updated to removes the link between
the source and destination class of service.

odp_pmr_match_set_t handle is removed and pmr create function is modified
to take number of terms and composite rule is created by providing more
than one term.

Signed-off-by: Balasubramanian Manoharan 
---
v2: removes pmr match set

 include/odp/api/classification.h | 142 ++-
 1 file changed, 35 insertions(+), 107 deletions(-)

diff --git a/include/odp/api/classification.h b/include/odp/api/classification.h
index f46912e..263ea7c 100644
--- a/include/odp/api/classification.h
+++ b/include/odp/api/classification.h
@@ -50,16 +50,11 @@ extern "C" {
 /**
  * @def ODP_PMR_INVAL
  * Invalid odp_pmr_t value.
- * This value is returned from odp_pmr_create()
+ * This value is returned from odp_cls_pmr_create()
  * function on failure.
  */
 
 /**
- * @def ODP_PMR_SET_INVAL
- * Invalid odp_pmr_set_t value.
- */
-
-/**
  * class of service packet drop policies
  */
 typedef enum {
@@ -286,50 +281,54 @@ typedef struct odp_pmr_match_t {
 } odp_pmr_match_t;
 
 /**
- * Create a packet match rule with mask and value
+ * Create a packet match rule between source and destination class of service.
+ * This packet matching rule is applied on all packets arriving at the source
+ * class of service and packets satisfying this PMR are sent to the destination
+ * class of service.
+ * A composite PMR rule is created when the number of terms in the match rule
+ * is more than one. The composite rule is considered as matching only if
+ * the packet satisfies all the terms in Packet Match Rule.
+ * The underlying platform may not support all or any specific combination
+ * of value match rules, and the application should take care
+ * of inspecting the return value when installing such rules, and perform
+ * appropriate fallback action.
  *
- * @param[in]  match   packet matching rule definition
+ * @param[in]  num_terms   Number of terms in the match rule.
+ * @param[in]  terms   Array of odp_pmr_match_t entries, one entry per
+ * term desired.
+ * @param[in]  src_cos source CoS handle
+ * @param[in]  dst_cos destination CoS handle
  *
- * @return Handle of the matching rule
- * @retval ODP_PMR_INVAL on failure
+ * @retval Hanlde to the Packet Match Rule.
+ * @retval ODP_PMR_INVAL on failure
  */
-odp_pmr_t odp_pmr_create(const odp_pmr_match_t *match);
+odp_pmr_t odp_cls_pmr_create(int num_terms, const odp_pmr_match_t *terms,
+odp_cos_t src_cos, odp_cos_t dst_cos);
 
 /**
- * Invalidate a packet match rule and vacate its resources
+ * Function to destroy a packet match rule
+ * Destroying a PMR removes the link between the source and destination
+ * class of service and this PMR will no longer be applied for packets arriving
+ * at the source class of service. All the resource associated with the PMR
+ * be release but the class of service will remain intact.
+ * Depending on the implementation details, destroying a composite rule
+ * may not guarantee the availability of hardware resources to create the
+ * same or essentially similar rule.
  *
  * @param[in]  pmr_id  Identifier of the PMR to be destroyed
  *
  * @retval 0 on success
  * @retval <0 on failure
  */
-int odp_pmr_destroy(odp_pmr_t pmr_id);
+int odp_cls_pmr_destroy(odp_pmr_t pmr_id);
 
-/**
- * Apply a PMR to a pktio to assign a CoS.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_pktio   pktio to which this PMR is to be applied
- * @param[in]  dst_cos CoS to be assigned by this PMR
+/* Return the maximum number of packet matching terms supported for
+ * a Packet match rule.
  *
- * @retval 0 on success
- * @retval <0 on failure
+ * @param[out] Maximum number of packet matching terms per
+ * PMR rule.
  */
-int odp_pktio_pmr_cos(odp_pmr_t pmr_id,
- odp_pktio_t src_pktio, odp_cos_t dst_cos);
-
-/**
- * Cascade a PMR to refine packets from one CoS to another.
- *
- * @param[in]  pmr_id  PMR to be activated
- * @param[in]  src_cos CoS to be filtered
- * @param[in]  dst_cos CoS to be assigned to packets filtered
- * from src_cos that match pmr_id.
- *
- * @retval 0 on success
- * @retval <0 on failure
- */
-int odp_cos_pmr_cos(odp_pmr_t pmr_id, odp_cos_t src_cos, odp_cos_t dst_cos);
+int odp_cls_pmr_num_terms(void);
 
 /**
  * Inquire about matching terms supported by the classifier
@@ -346,64 +345,6 @@ unsigned long lo