Following similar approach to rte_flow and rte_tm for modularity reasons.

Signed-off-by: Cristian Dumitrescu <cristian.dumitre...@intel.com>
---
 lib/librte_ether/rte_ethdev.c          | 12 ++++++++++++
 lib/librte_ether/rte_ethdev.h          | 20 ++++++++++++++++++++
 lib/librte_ether/rte_ether_version.map |  6 ++++++
 3 files changed, 38 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 83898a8..eb35ef0 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3021,6 +3021,18 @@ rte_eth_dev_filter_ctrl(uint8_t port_id, enum 
rte_filter_type filter_type,
        return (*dev->dev_ops->filter_ctrl)(dev, filter_type, filter_op, arg);
 }
 
+int
+rte_eth_dev_mtr_ops_get(uint8_t port_id, void *ops)
+{
+       struct rte_eth_dev *dev;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+       dev = &rte_eth_devices[port_id];
+       RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mtr_ops_get, -ENOTSUP);
+       return (*dev->dev_ops->mtr_ops_get)(dev, ops);
+}
+
 void *
 rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
                rte_rx_callback_fn fn, void *user_param)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 0f38b45..e3a1169 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1441,6 +1441,9 @@ typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
                                 void *arg);
 /**< @internal Take operations to assigned filter type on an Ethernet device */
 
+typedef int (*eth_mtr_ops_get_t)(struct rte_eth_dev *dev, void *ops);
+/**< @internal Get Trafffic Metering and Policing (MTR) operations */
+
 typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
                                 struct rte_eth_dcb_info *dcb_info);
 /**< @internal Get dcb information on an Ethernet device */
@@ -1573,6 +1576,9 @@ struct eth_dev_ops {
        /**< Get extended device statistic values by ID. */
        eth_xstats_get_names_by_id_t xstats_get_names_by_id;
        /**< Get name of extended device statistics by ID. */
+
+       eth_mtr_ops_get_t mtr_ops_get;
+       /**< Get Traffic Metering and Policing (MTR) operations. */
 };
 
 /**
@@ -4105,6 +4111,20 @@ int rte_eth_dev_filter_ctrl(uint8_t port_id, enum 
rte_filter_type filter_type,
                        enum rte_filter_op filter_op, void *arg);
 
 /**
+ * Take Traffic Metering and Policing (MTR) operations on an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param arg
+ *   Pointer to MTR operations.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ *   - (-ENODEV) if *port_id* invalid.
+ */
+int rte_eth_dev_mtr_ops_get(uint8_t port_id, void *ops);
+
+/**
  * Get DCB information on an Ethernet device.
  *
  * @param port_id
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index d6726bb..9783aa1 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -156,3 +156,9 @@ DPDK_17.05 {
        rte_eth_xstats_get_names_by_id;
 
 } DPDK_17.02;
+
+DPDK_17.08 {
+    global:
+
+       rte_eth_dev_mtr_ops_get;
+} DPDK_17.05;
-- 
2.7.4

Reply via email to