[dpdk-dev,v2,1/4] lib/ether: optimize the 'rte_eth_tunnel_filter_conf' structure

Message ID 1453966217-10510-2-git-send-email-xutao.sun@intel.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Xutao Sun Jan. 28, 2016, 7:30 a.m. UTC
  Change the fields of outer_mac and inner_mac from pointer to struct in order to keep the code's readability.

Signed-off-by: Xutao Sun <xutao.sun@intel.com>
Signed-off-by: Jijiang Liu <jijiang.liu@intel.com>
---
 app/test-pmd/cmdline.c          |  6 ++++--
 drivers/net/i40e/i40e_ethdev.c  | 12 ++++++------
 lib/librte_ether/rte_eth_ctrl.h |  4 ++--
 3 files changed, 12 insertions(+), 10 deletions(-)
  

Comments

Thomas Monjalon Jan. 28, 2016, 8:21 a.m. UTC | #1
2016-01-28 15:30, Xutao Sun:
> Change the fields of outer_mac and inner_mac from pointer to struct in order to keep the code's readability.

[...]
> -	tunnel_filter_conf.outer_mac = &res->outer_mac;
> -	tunnel_filter_conf.inner_mac = &res->inner_mac;
> +	(void)rte_memcpy(&tunnel_filter_conf.outer_mac, &res->outer_mac,
> +			ETHER_ADDR_LEN);
> +	(void)rte_memcpy(&tunnel_filter_conf.inner_mac, &res->inner_mac,
> +			ETHER_ADDR_LEN);

The (void) casting is useless here.

> --- a/lib/librte_ether/rte_eth_ctrl.h
> +++ b/lib/librte_ether/rte_eth_ctrl.h
> @@ -280,8 +280,8 @@ enum rte_tunnel_iptype {
>   * Tunneling Packet filter configuration.
>   */
>  struct rte_eth_tunnel_filter_conf {
> -	struct ether_addr *outer_mac;  /**< Outer MAC address filter. */
> -	struct ether_addr *inner_mac;  /**< Inner MAC address filter. */
> +	struct ether_addr outer_mac;  /**< Outer MAC address filter. */
> +	struct ether_addr inner_mac;  /**< Inner MAC address filter. */

It is an API change.
Please remove the deprecation notice and update the release notes
in this patch (atomically).
  
Xutao Sun Jan. 28, 2016, 9:05 a.m. UTC | #2
Hi, Thomas

> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Thursday, January 28, 2016 4:22 PM
> To: Sun, Xutao <xutao.sun@intel.com>
> Cc: dev@dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2 1/4] lib/ether: optimize the
> 'rte_eth_tunnel_filter_conf' structure
> 
> 2016-01-28 15:30, Xutao Sun:
> > Change the fields of outer_mac and inner_mac from pointer to struct in
> order to keep the code's readability.
> 
> [...]
> > -	tunnel_filter_conf.outer_mac = &res->outer_mac;
> > -	tunnel_filter_conf.inner_mac = &res->inner_mac;
> > +	(void)rte_memcpy(&tunnel_filter_conf.outer_mac, &res-
> >outer_mac,
> > +			ETHER_ADDR_LEN);
> > +	(void)rte_memcpy(&tunnel_filter_conf.inner_mac, &res-
> >inner_mac,
> > +			ETHER_ADDR_LEN);
> 
> The (void) casting is useless here.
> 
> > --- a/lib/librte_ether/rte_eth_ctrl.h
> > +++ b/lib/librte_ether/rte_eth_ctrl.h
> > @@ -280,8 +280,8 @@ enum rte_tunnel_iptype {
> >   * Tunneling Packet filter configuration.
> >   */
> >  struct rte_eth_tunnel_filter_conf {
> > -	struct ether_addr *outer_mac;  /**< Outer MAC address filter. */
> > -	struct ether_addr *inner_mac;  /**< Inner MAC address filter. */
> > +	struct ether_addr outer_mac;  /**< Outer MAC address filter. */
> > +	struct ether_addr inner_mac;  /**< Inner MAC address filter. */
> 
> It is an API change.
> Please remove the deprecation notice and update the release notes in this
> patch (atomically).

I will remove the deprecation notice and update the release notes.
Is it an ABI change instead of an API change?

Thanks,
Xutao
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 6d28c1b..6084449 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -6640,8 +6640,10 @@  cmd_tunnel_filter_parsed(void *parsed_result,
 	struct rte_eth_tunnel_filter_conf tunnel_filter_conf;
 	int ret = 0;
 
-	tunnel_filter_conf.outer_mac = &res->outer_mac;
-	tunnel_filter_conf.inner_mac = &res->inner_mac;
+	(void)rte_memcpy(&tunnel_filter_conf.outer_mac, &res->outer_mac,
+			ETHER_ADDR_LEN);
+	(void)rte_memcpy(&tunnel_filter_conf.inner_mac, &res->inner_mac,
+			ETHER_ADDR_LEN);
 	tunnel_filter_conf.inner_vlan = res->inner_vlan;
 
 	if (res->ip_value.family == AF_INET) {
diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index bf6220d..1dd1077 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -5828,10 +5828,10 @@  i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 	}
 	pfilter = cld_filter;
 
-	(void)rte_memcpy(&pfilter->outer_mac, tunnel_filter->outer_mac,
-			sizeof(struct ether_addr));
-	(void)rte_memcpy(&pfilter->inner_mac, tunnel_filter->inner_mac,
-			sizeof(struct ether_addr));
+	(void)rte_memcpy(&pfilter->outer_mac, &tunnel_filter->outer_mac,
+			ETHER_ADDR_LEN);
+	(void)rte_memcpy(&pfilter->inner_mac, &tunnel_filter->inner_mac,
+			ETHER_ADDR_LEN);
 
 	pfilter->inner_vlan = tunnel_filter->inner_vlan;
 	if (tunnel_filter->ip_type == RTE_TUNNEL_IPTYPE_IPV4) {
@@ -6131,13 +6131,13 @@  i40e_tunnel_filter_param_check(struct i40e_pf *pf,
 	}
 
 	if ((filter->filter_type & ETH_TUNNEL_FILTER_OMAC) &&
-		(is_zero_ether_addr(filter->outer_mac))) {
+		(is_zero_ether_addr(&filter->outer_mac))) {
 		PMD_DRV_LOG(ERR, "Cannot add NULL outer MAC address");
 		return -EINVAL;
 	}
 
 	if ((filter->filter_type & ETH_TUNNEL_FILTER_IMAC) &&
-		(is_zero_ether_addr(filter->inner_mac))) {
+		(is_zero_ether_addr(&filter->inner_mac))) {
 		PMD_DRV_LOG(ERR, "Cannot add NULL inner MAC address");
 		return -EINVAL;
 	}
diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index ce224ad..30cbde7 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -280,8 +280,8 @@  enum rte_tunnel_iptype {
  * Tunneling Packet filter configuration.
  */
 struct rte_eth_tunnel_filter_conf {
-	struct ether_addr *outer_mac;  /**< Outer MAC address filter. */
-	struct ether_addr *inner_mac;  /**< Inner MAC address filter. */
+	struct ether_addr outer_mac;  /**< Outer MAC address filter. */
+	struct ether_addr inner_mac;  /**< Inner MAC address filter. */
 	uint16_t inner_vlan;           /**< Inner VLAN filter. */
 	enum rte_tunnel_iptype ip_type; /**< IP address type. */
 	union {