From: Long Wu <long...@corigine.com>

Added an API `rte_eth_dev_get_vlan_filter_conf()` to retrieve
the VLAN filter configuration of an Ethernet device.

Signed-off-by: Long Wu <long...@corigine.com>
Reviewed-by: Chaoyong He <chaoyong...@corigine.com>
---
 doc/guides/rel_notes/release_25_07.rst |  5 +++++
 lib/ethdev/ethdev_trace.h              |  8 ++++++++
 lib/ethdev/ethdev_trace_points.c       |  3 +++
 lib/ethdev/rte_ethdev.c                | 24 ++++++++++++++++++++++++
 lib/ethdev/rte_ethdev.h                | 19 +++++++++++++++++++
 5 files changed, 59 insertions(+)

diff --git a/doc/guides/rel_notes/release_25_07.rst 
b/doc/guides/rel_notes/release_25_07.rst
index 093b85d206..81d4c36f77 100644
--- a/doc/guides/rel_notes/release_25_07.rst
+++ b/doc/guides/rel_notes/release_25_07.rst
@@ -55,6 +55,11 @@ New Features
      Also, make sure to start the actual text at the margin.
      =======================================================
 
+* **Added an API to retrieve VLAN filter configuration.**
+
+  Added an API ``rte_eth_dev_get_vlan_filter_conf`` to retrieve the VLAN filter
+  configuration of an Ethernet device.
+
 
 Removed Items
 -------------
diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h
index c65b78590a..ecea305c66 100644
--- a/lib/ethdev/ethdev_trace.h
+++ b/lib/ethdev/ethdev_trace.h
@@ -639,6 +639,14 @@ RTE_TRACE_POINT(
        rte_trace_point_emit_int(ret);
 )
 
+RTE_TRACE_POINT(
+       rte_ethdev_trace_vlan_filter_conf_get,
+       RTE_TRACE_POINT_ARGS(uint16_t port_id,
+                       struct rte_vlan_filter_conf *vf_conf),
+       rte_trace_point_emit_u16(port_id);
+       rte_trace_point_emit_ptr(vf_conf);
+)
+
 RTE_TRACE_POINT(
        rte_ethdev_trace_set_vlan_strip_on_queue,
        RTE_TRACE_POINT_ARGS(uint16_t port_id, uint16_t rx_queue_id, int on),
diff --git a/lib/ethdev/ethdev_trace_points.c b/lib/ethdev/ethdev_trace_points.c
index 071c508327..913a99f8c0 100644
--- a/lib/ethdev/ethdev_trace_points.c
+++ b/lib/ethdev/ethdev_trace_points.c
@@ -266,6 +266,9 @@ RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_set_mtu,
 RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_vlan_filter,
        lib.ethdev.vlan_filter)
 
+RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_vlan_filter_conf_get,
+       lib.ethdev.vlan_filter_conf_get)
+
 RTE_TRACE_POINT_REGISTER(rte_ethdev_trace_set_vlan_strip_on_queue,
        lib.ethdev.set_vlan_strip_on_queue)
 
diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index d4197322a0..a2c05594ff 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -4433,6 +4433,30 @@ rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t 
vlan_id, int on)
        return ret;
 }
 
+RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_eth_dev_get_vlan_filter_conf, 25.07)
+int
+rte_eth_dev_get_vlan_filter_conf(uint16_t port_id,
+               struct rte_vlan_filter_conf *vf_conf)
+{
+       struct rte_eth_dev *dev;
+
+       RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+       dev = &rte_eth_devices[port_id];
+
+       if (vf_conf == NULL) {
+               RTE_ETHDEV_LOG_LINE(ERR,
+                       "Cannot get ethdev port %u vlan filter configuration to 
NULL",
+                       port_id);
+               return -EINVAL;
+       }
+
+       memcpy(vf_conf, &dev->data->vlan_filter_conf, sizeof(struct 
rte_vlan_filter_conf));
+
+       rte_ethdev_trace_vlan_filter_conf_get(port_id, vf_conf);
+
+       return 0;
+}
+
 RTE_EXPORT_SYMBOL(rte_eth_dev_set_vlan_strip_on_queue)
 int
 rte_eth_dev_set_vlan_strip_on_queue(uint16_t port_id, uint16_t rx_queue_id,
diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
index ea7f8c4a1a..190fd4d3a7 100644
--- a/lib/ethdev/rte_ethdev.h
+++ b/lib/ethdev/rte_ethdev.h
@@ -3709,6 +3709,25 @@ int rte_eth_dev_set_mtu(uint16_t port_id, uint16_t mtu);
  */
 int rte_eth_dev_vlan_filter(uint16_t port_id, uint16_t vlan_id, int on);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * Retrieve the VLAN filter configuration of an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param vf_conf
+ *   Location for Ethernet device VLAN filter configuration to be filled in.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port_id* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+__rte_experimental
+int rte_eth_dev_get_vlan_filter_conf(uint16_t port_id,
+               struct rte_vlan_filter_conf *vf_conf);
+
 /**
  * Enable/Disable hardware VLAN Strip by a Rx queue of an Ethernet device.
  *
-- 
2.43.5

Reply via email to