mtr_id, dscp_table, error);
}
+/** MTR object meter VLAN table update */
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id,
+ uint32_t mtr_id,
+ enum rte_color *vlan_table,
+ struct rte_mtr_error *error)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+ return RTE_MTR_FUNC(port_id, meter_vlan_table_update)(dev,
+ mtr_id, vlan_table, error);
+}
+
+/** Set the input color protocol on MTR object */
+int
+rte_mtr_color_in_protocol_set(uint16_t port_id,
+ uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto,
+ uint32_t priority,
+ struct rte_mtr_error *error)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+ return RTE_MTR_FUNC(port_id, in_proto_set)(dev,
+ mtr_id, proto, priority, error);
+}
+
+/** Get input color protocols of MTR object */
+int
+rte_mtr_color_in_protocol_get(uint16_t port_id,
+ uint32_t mtr_id,
+ uint64_t *proto_mask,
+ struct rte_mtr_error *error)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+ return RTE_MTR_FUNC(port_id, in_proto_get)(dev,
+ mtr_id, proto_mask, error);
+}
+
+/** Get input color protocol priority of MTR object */
+int
+rte_mtr_color_in_protocol_priority_get(uint16_t port_id,
+ uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto,
+ uint32_t *priority,
+ struct rte_mtr_error *error)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+ return RTE_MTR_FUNC(port_id, in_proto_prio_get)(dev,
+ mtr_id, proto, priority, error);
+}
+
/** MTR object enabled stats update */
int
rte_mtr_stats_update(uint16_t port_id,
const struct rte_flow_action *actions[RTE_COLORS];
};
+/**
+ * Input color protocol method
+ *
+ * More than one of the method can be enabled for a given meter.
+ * Even if enabled, a method might not be applicable to each input packet,
+ * in case the associated protocol header is not present in the packet.
+ * The highest priority method that is both enabled for the meter and also
+ * applicable for the current input packet wins;
+ * if none is both enabled and applicable, the default input color is used.
+ * @see function rte_mtr_color_in_protocol_set()
+ *
+ */
+enum rte_mtr_color_in_protocol {
+ /**
+ * Enable the detection of the packet input color based on the outermost
+ * VLAN header fields DEI (1 bit) and PCP (3 bits).
+ * These fields are used as index into the VLAN table.
+ *
+ * @see struct rte_mtr_params::vlan_table
+ */
+ RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN = RTE_BIT64(0),
+ /**
+ * Enable the detection of the packet input color based on the innermost
+ * VLAN header fields DEI (1 bit) and PCP (3 bits).
+ * These fields are used as index into the VLAN table.
+ *
+ * @see struct rte_mtr_params::vlan_table
+ */
+ RTE_MTR_COLOR_IN_PROTO_INNER_VLAN = RTE_BIT64(1),
+ /**
+ * Enable the detection of the packet input color based on the outermost
+ * IP DSCP field. These fields are used as index into the DSCP table.
+ *
+ * @see struct rte_mtr_params::dscp_table
+ */
+ RTE_MTR_COLOR_IN_PROTO_OUTER_IP = RTE_BIT64(2),
+ /**
+ * Enable the detection of the packet input color based on the innermost
+ * IP DSCP field. These fields are used as index into the DSCP table.
+ *
+ * @see struct rte_mtr_params::dscp_table
+ */
+ RTE_MTR_COLOR_IN_PROTO_INNER_IP = RTE_BIT64(3),
+};
+
/**
* Parameters for each traffic metering & policing object
*
*/
int use_prev_mtr_color;
- /** Meter input color. When non-NULL: it points to a pre-allocated and
+ /** Meter input color based on IP DSCP protocol field.
+ *
+ * Valid when *input_color_proto_mask* set to any of the following
+ * RTE_MTR_COLOR_IN_PROTO_OUTER_IP,
+ * RTE_MTR_COLOR_IN_PROTO_INNER_IP
+ *
+ * When non-NULL: it points to a pre-allocated and
* pre-populated table with exactly 64 elements providing the input
* color for each value of the IPv4/IPv6 Differentiated Services Code
- * Point (DSCP) input packet field. When NULL: it is equivalent to
- * setting this parameter to an all-green populated table (i.e. table
- * with all the 64 elements set to green color). The color blind mode
- * is configured by setting *use_prev_mtr_color* to 0 and *dscp_table*
- * to either NULL or to an all-green populated table. When
- * *use_prev_mtr_color* is non-zero value or when *dscp_table* contains
- * at least one yellow or red color element, then the color aware mode
- * is configured.
+ * Point (DSCP) input packet field.
+ *
+ * When NULL: it is equivalent to setting this parameter to an all-green
+ * populated table (i.e. table with all the 64 elements set to green
+ * color). The color blind mode is configured by setting
+ * *use_prev_mtr_color* to 0 and *dscp_table* to either NULL or to an
+ * all-green populated table.
+ *
+ * When *use_prev_mtr_color* is non-zero value or when *dscp_table*
+ * contains at least one yellow or red color element, then the color
+ * aware mode is configured.
+ *
+ * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_OUTER_IP
+ * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_IP
+ * @see struct rte_mtr_params::input_color_proto_mask
*/
enum rte_color *dscp_table;
-
+ /** Meter input color based on VLAN DEI(1bit), PCP(3 bits) protocol
+ * fields.
+ *
+ * Valid when *input_color_proto_mask* set to any of the following
+ * RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN,
+ * RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
+ *
+ * When non-NULL: it points to a pre-allocated and pre-populated
+ * table with exactly 16 elements providing the input color for
+ * each value of the DEI(1bit), PCP(3 bits) input packet field.
+ *
+ * When NULL: it is equivalent to setting this parameter to an
+ * all-green populated table (i.e. table with
+ * all the 16 elements set to green color). The color blind mode
+ * is configured by setting *use_prev_mtr_color* to 0 and
+ * *vlan_table* to either NULL or to an all-green populated table.
+ *
+ * When *use_prev_mtr_color* is non-zero value
+ * or when *vlan_table* contains at least one yellow or
+ * red color element, then the color aware mode is configured.
+ *
+ * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_OUTER_VLAN
+ * @see enum rte_mtr_color_in_protocol::RTE_MTR_COLOR_IN_PROTO_INNER_VLAN
+ * @see struct rte_mtr_params::input_color_proto_mask
+ */
+ enum rte_color *vlan_table;
/** Non-zero to enable the meter, zero to disable the meter at the time
* of MTR object creation. Ignored when the meter profile indicated by
* *meter_profile_id* is set to NONE.
/** Meter policy ID. @see rte_mtr_meter_policy_add() */
uint32_t meter_policy_id;
+
+ /** Input color to be set for the input packet when none of the
+ * enabled input color methods is applicable to the input packet.
+ * Ignored when this when *input_color_proto_mask* set to zero.
+ */
+ enum rte_color default_input_color;
};
/**
* @see enum rte_mtr_stats_type
*/
uint64_t stats_mask;
+
+ /** Set of supported input color protocol.
+ * @see enum rte_mtr_color_in_protocol
+ */
+ uint64_t input_color_proto_mask;
+
+ /** When non-zero, it indicates that driver supports separate
+ * input color table for given ethdev port.
+ */
+ int separate_input_color_table_per_port;
};
/**
enum rte_color *dscp_table,
struct rte_mtr_error *error);
+/**
+ * MTR object VLAN table update
+ *
+ * @param[in] port_id
+ * The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ * MTR object ID. Needs to be valid.
+ * @param[in] vlan_table
+ * When non-NULL: it points to a pre-allocated and pre-populated table with
+ * exactly 16 elements providing the input color for each value of the
+ * each value of the DEI(1bit), PCP(3 bits) input packet field.
+ * When NULL: it is equivalent to setting this parameter to an "all-green"
+ * populated table (i.e. table with all the 16 elements set to green color).
+ * @param[out] error
+ * Error details. Filled in only on error, when not NULL.
+ * @return
+ * 0 on success, non-zero error code otherwise.
+ */
+__rte_experimental
+int
+rte_mtr_meter_vlan_table_update(uint16_t port_id, uint32_t mtr_id,
+ enum rte_color *vlan_table,
+ struct rte_mtr_error *error);
+
+/**
+ * Set the input color protocol for a given MTR object
+ *
+ * More than one of the method can be enabled for a given meter.
+ * Even if enabled, a method might not be applicable to each input packet,
+ * in case the associated protocol header is not present in the packet.
+ * The highest priority method that is both enabled for the meter and also
+ * applicable for the current input packet wins;
+ * if none is both enabled and applicable, the default input color is used.
+ *
+ * @param[in] port_id
+ * The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ * MTR object ID. Needs to be valid.
+ * @param[in] proto
+ * Input color protocol.
+ * @param[in] priority
+ * Input color protocol priority. Value zero indicates
+ * the highest priority.
+ * @param[out] error
+ * Error details. Filled in only on error, when not NULL.
+ * @return
+ * 0 on success, non-zero error code otherwise.
+ */
+__rte_experimental
+int
+rte_mtr_color_in_protocol_set(uint16_t port_id, uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto, uint32_t priority,
+ struct rte_mtr_error *error);
+
+/**
+ * Get the input color protocol for a given MTR object
+ *
+ * @param[in] port_id
+ * The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ * MTR object ID. Needs to be valid.
+ * @param[out] proto_mask
+ * Selected input color protocols as bit mask.
+ * @param[out] error
+ * Error details. Filled in only on error, when not NULL.
+ * @return
+ * 0 on success, non-zero error code otherwise.
+ *
+ */
+__rte_experimental
+int
+rte_mtr_color_in_protocol_get(uint16_t port_id, uint32_t mtr_id,
+ uint64_t *proto_mask,
+ struct rte_mtr_error *error);
+
+/**
+ * Get the priority associated with input color protocol for a given MTR object
+ *
+ * @param[in] port_id
+ * The port identifier of the Ethernet device.
+ * @param[in] mtr_id
+ * MTR object ID. Needs to be valid.
+ * @param[in] proto
+ * Input color protocol.
+ * @param[out] priority
+ * Input color protocol priority associated with proto.
+ * @param[out] error
+ * Error details. Filled in only on error, when not NULL.
+ * @return
+ * 0 on success, non-zero error code otherwise.
+ */
+__rte_experimental
+int
+rte_mtr_color_in_protocol_priority_get(uint16_t port_id, uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto, uint32_t *priority,
+ struct rte_mtr_error *error);
+
/**
* MTR object enabled statistics counters update
*
enum rte_color *dscp_table,
struct rte_mtr_error *error);
+/** @internal mtr object meter vlan table update. */
+typedef int (*rte_mtr_meter_vlan_table_update_t)(struct rte_eth_dev *dev,
+ uint32_t mtr_id,
+ enum rte_color *vlan_table,
+ struct rte_mtr_error *error);
+
+/** @internal Set the input color protocol on MTR object. */
+typedef int (*rte_mtr_meter_color_in_proto_set_t)(struct rte_eth_dev *dev,
+ uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto,
+ uint32_t priority,
+ struct rte_mtr_error *error);
+
+/** @internal Get the input color protocols of MTR object. */
+typedef int (*rte_mtr_meter_color_in_proto_get_t)(struct rte_eth_dev *dev,
+ uint32_t mtr_id,
+ uint64_t *proto_mask,
+ struct rte_mtr_error *error);
+
+/** @internal Get the input color protocol priority of MTR object. */
+typedef int (*rte_mtr_meter_color_in_proto_prio_get_t)(struct rte_eth_dev *dev,
+ uint32_t mtr_id,
+ enum rte_mtr_color_in_protocol proto,
+ uint32_t *priority,
+ struct rte_mtr_error *error);
+
/** @internal MTR object enabled stats update. */
typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev,
uint32_t mtr_id,
/** MTR object meter DSCP table update */
rte_mtr_meter_dscp_table_update_t meter_dscp_table_update;
+ /** MTR object meter VLAN table update */
+ rte_mtr_meter_vlan_table_update_t meter_vlan_table_update;
+
+ /** Set the input color protocol on MTR object. */
+ rte_mtr_meter_color_in_proto_set_t in_proto_set;
+
+ /** Get the input color protocol of MTR object. */
+ rte_mtr_meter_color_in_proto_get_t in_proto_get;
+
+ /** Get the input color protocol priority of MTR object. */
+ rte_mtr_meter_color_in_proto_prio_get_t in_proto_prio_get;
+
/** MTR object enabled stats update */
rte_mtr_stats_update_t stats_update;