[2/3] ethdev: retrieve VLAN filter configuration
Checks
Commit Message
From: Long Wu <long.wu@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.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@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(+)
Comments
On Fri, 11 Apr 2025 16:10:04 +0800
Chaoyong He <chaoyong.he@corigine.com> wrote:
>
> +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));
Could just be a structure assignment which would preserve type safety.
> +
> + rte_ethdev_trace_vlan_filter_conf_get(port_id, vf_conf);
> +
> + return 0;
> +}
> +
Not sure if adding new accessor function is really needed.
Unfortunately, all of dev->data is exposed in DPDK API already.
@@ -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
-------------
@@ -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),
@@ -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)
@@ -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,
@@ -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.
*