DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH 3/4] net/tap: do not use opaque parameter in convert
Date: Mon, 28 Oct 2024 09:32:11 -0700	[thread overview]
Message-ID: <20241028163324.193338-4-stephen@networkplumber.org> (raw)
In-Reply-To: <20241028163324.193338-1-stephen@networkplumber.org>

The function to convert from internal representation to
netlink was using a void pointer when both caller and callee
were using same structure.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/tap/tap_flow.c | 47 +++++++++++++-------------------------
 1 file changed, 16 insertions(+), 31 deletions(-)

diff --git a/drivers/net/tap/tap_flow.c b/drivers/net/tap/tap_flow.c
index 6564583174..c0e44bb1a7 100644
--- a/drivers/net/tap/tap_flow.c
+++ b/drivers/net/tap/tap_flow.c
@@ -74,12 +74,12 @@ struct action_data {
 	};
 };
 
-static int tap_flow_create_eth(const struct rte_flow_item *item, void *data);
-static int tap_flow_create_vlan(const struct rte_flow_item *item, void *data);
-static int tap_flow_create_ipv4(const struct rte_flow_item *item, void *data);
-static int tap_flow_create_ipv6(const struct rte_flow_item *item, void *data);
-static int tap_flow_create_udp(const struct rte_flow_item *item, void *data);
-static int tap_flow_create_tcp(const struct rte_flow_item *item, void *data);
+static int tap_flow_create_eth(const struct rte_flow_item *item, struct convert_data *info);
+static int tap_flow_create_vlan(const struct rte_flow_item *item, struct convert_data *info);
+static int tap_flow_create_ipv4(const struct rte_flow_item *item, struct convert_data *info);
+static int tap_flow_create_ipv6(const struct rte_flow_item *item, struct convert_data *info);
+static int tap_flow_create_udp(const struct rte_flow_item *item, struct convert_data *info);
+static int tap_flow_create_tcp(const struct rte_flow_item *item, struct convert_data *info);
 static int
 tap_flow_validate(struct rte_eth_dev *dev,
 		  const struct rte_flow_attr *attr,
@@ -139,19 +139,10 @@ struct tap_flow_items {
 	 * along with the item.
 	 */
 	const void *default_mask;
-	/**
-	 * Conversion function from rte_flow to netlink attributes.
-	 *
-	 * @param item
-	 *   rte_flow item to convert.
-	 * @param data
-	 *   Internal structure to store the conversion.
-	 *
-	 * @return
-	 *   0 on success, negative value otherwise.
-	 */
-	int (*convert)(const struct rte_flow_item *item, void *data);
-	/** List of possible following items.  */
+	/* Conversion function from rte_flow to netlink attributes. */
+	int (*convert)(const struct rte_flow_item *item, struct convert_data *info);
+
+	/* List of possible following items.  */
 	const enum rte_flow_item_type *const items;
 };
 
@@ -417,9 +408,8 @@ static struct remote_rule implicit_rte_flows[TAP_REMOTE_MAX_IDX] = {
  *   0 if checks are alright, -1 otherwise.
  */
 static int
-tap_flow_create_eth(const struct rte_flow_item *item, void *data)
+tap_flow_create_eth(const struct rte_flow_item *item, struct convert_data *info)
 {
-	struct convert_data *info = (struct convert_data *)data;
 	const struct rte_flow_item_eth *spec = item->spec;
 	const struct rte_flow_item_eth *mask = item->mask;
 	struct rte_flow *flow = info->flow;
@@ -471,9 +461,8 @@ tap_flow_create_eth(const struct rte_flow_item *item, void *data)
  *   0 if checks are alright, -1 otherwise.
  */
 static int
-tap_flow_create_vlan(const struct rte_flow_item *item, void *data)
+tap_flow_create_vlan(const struct rte_flow_item *item, struct convert_data *info)
 {
-	struct convert_data *info = (struct convert_data *)data;
 	const struct rte_flow_item_vlan *spec = item->spec;
 	const struct rte_flow_item_vlan *mask = item->mask;
 	struct rte_flow *flow = info->flow;
@@ -531,9 +520,8 @@ tap_flow_create_vlan(const struct rte_flow_item *item, void *data)
  *   0 if checks are alright, -1 otherwise.
  */
 static int
-tap_flow_create_ipv4(const struct rte_flow_item *item, void *data)
+tap_flow_create_ipv4(const struct rte_flow_item *item, struct convert_data *info)
 {
-	struct convert_data *info = (struct convert_data *)data;
 	const struct rte_flow_item_ipv4 *spec = item->spec;
 	const struct rte_flow_item_ipv4 *mask = item->mask;
 	struct rte_flow *flow = info->flow;
@@ -586,9 +574,8 @@ tap_flow_create_ipv4(const struct rte_flow_item *item, void *data)
  *   0 if checks are alright, -1 otherwise.
  */
 static int
-tap_flow_create_ipv6(const struct rte_flow_item *item, void *data)
+tap_flow_create_ipv6(const struct rte_flow_item *item, struct convert_data *info)
 {
-	struct convert_data *info = (struct convert_data *)data;
 	const struct rte_flow_item_ipv6 *spec = item->spec;
 	const struct rte_flow_item_ipv6 *mask = item->mask;
 	struct rte_flow *flow = info->flow;
@@ -642,9 +629,8 @@ tap_flow_create_ipv6(const struct rte_flow_item *item, void *data)
  *   0 if checks are alright, -1 otherwise.
  */
 static int
-tap_flow_create_udp(const struct rte_flow_item *item, void *data)
+tap_flow_create_udp(const struct rte_flow_item *item, struct convert_data *info)
 {
-	struct convert_data *info = (struct convert_data *)data;
 	const struct rte_flow_item_udp *spec = item->spec;
 	const struct rte_flow_item_udp *mask = item->mask;
 	struct rte_flow *flow = info->flow;
@@ -688,9 +674,8 @@ tap_flow_create_udp(const struct rte_flow_item *item, void *data)
  *   0 if checks are alright, -1 otherwise.
  */
 static int
-tap_flow_create_tcp(const struct rte_flow_item *item, void *data)
+tap_flow_create_tcp(const struct rte_flow_item *item, struct convert_data *info)
 {
-	struct convert_data *info = (struct convert_data *)data;
 	const struct rte_flow_item_tcp *spec = item->spec;
 	const struct rte_flow_item_tcp *mask = item->mask;
 	struct rte_flow *flow = info->flow;
-- 
2.45.2


  parent reply	other threads:[~2024-10-28 16:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-28 16:32 [PATCH 0/4] net/tap: minor cleanups Stephen Hemminger
2024-10-28 16:32 ` [PATCH 1/4] net/tap: replace rte_memcpy Stephen Hemminger
2024-10-28 16:32 ` [PATCH 2/4] net/tap: rename struct nlmsg to tap_nlmsg Stephen Hemminger
2024-10-28 16:32 ` Stephen Hemminger [this message]
2024-10-28 16:32 ` [PATCH 4/4] net/tap: do not use rte_malloc for process private data Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241028163324.193338-4-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).