[v3] net/ice: use the copy API to do MAC assignment
diff mbox series

Message ID 20200103025845.12609-1-haiyue.wang@intel.com
State Superseded
Delegated to: xiaolong ye
Headers show
Series
  • [v3] net/ice: use the copy API to do MAC assignment
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/checkpatch success coding style OK

Commit Message

Haiyue Wang Jan. 3, 2020, 2:58 a.m. UTC
Use the API rte_ether_addr_copy to do MAC assignment, instead of
calling rte_memcpy function directly.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
---
v3: Update the commit message

v2: Update the commit title and message, use the rte_ether_addr_copy API
    instead of just changing the length definition to make code style clean.

 drivers/net/ice/ice_ethdev.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Yang, Qiming Jan. 6, 2020, 2:45 a.m. UTC | #1
> -----Original Message-----
> From: Wang, Haiyue
> Sent: Friday, January 3, 2020 10:59 AM
> To: dev@dpdk.org; stephen@networkplumber.org; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Yang, Qiming <qiming.yang@intel.com>; Ye,
> Xiaolong <xiaolong.ye@intel.com>
> Cc: Wang, Haiyue <haiyue.wang@intel.com>
> Subject: [PATCH v3] net/ice: use the copy API to do MAC assignment
> 
> Use the API rte_ether_addr_copy to do MAC assignment, instead of calling
> rte_memcpy function directly.
> 
> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> ---
> v3: Update the commit message
> 
> v2: Update the commit title and message, use the rte_ether_addr_copy API
>     instead of just changing the length definition to make code style clean.
> 
>  drivers/net/ice/ice_ethdev.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index
> 2cbd82c94..d104df26f 100644
> --- a/drivers/net/ice/ice_ethdev.c
> +++ b/drivers/net/ice/ice_ethdev.c
> @@ -873,7 +873,7 @@ ice_add_mac_filter(struct ice_vsi *vsi, struct
> rte_ether_addr *mac_addr)
>  		ret = -ENOMEM;
>  		goto DONE;
>  	}
> -	rte_memcpy(&f->mac_info.mac_addr, mac_addr, ETH_ADDR_LEN);
> +	rte_ether_addr_copy(mac_addr, &f->mac_info.mac_addr);
>  	TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
>  	vsi->mac_num++;
> 
> @@ -1660,16 +1660,16 @@ ice_setup_vsi(struct ice_pf *pf, enum
> ice_vsi_type type)
> 
>  	if (type == ICE_VSI_PF) {
>  		/* MAC configuration */
> -		rte_memcpy(pf->dev_addr.addr_bytes,
> -			   hw->port_info->mac.perm_addr,
> -			   ETH_ADDR_LEN);
> +		rte_ether_addr_copy((struct rte_ether_addr *)
> +					hw->port_info->mac.perm_addr,
> +				    &pf->dev_addr);
> 
> -		rte_memcpy(&mac_addr, &pf->dev_addr,
> RTE_ETHER_ADDR_LEN);
> +		rte_ether_addr_copy(&pf->dev_addr, &mac_addr);
>  		ret = ice_add_mac_filter(vsi, &mac_addr);
>  		if (ret != ICE_SUCCESS)
>  			PMD_INIT_LOG(ERR, "Failed to add dflt MAC filter");
> 
> -		rte_memcpy(&mac_addr, &broadcast,
> RTE_ETHER_ADDR_LEN);
> +		rte_ether_addr_copy(&broadcast, &mac_addr);
>  		ret = ice_add_mac_filter(vsi, &mac_addr);
>  		if (ret != ICE_SUCCESS)
>  			PMD_INIT_LOG(ERR, "Failed to add MAC filter"); @@
> -3267,7 +3267,7 @@ static int ice_macaddr_set(struct rte_eth_dev *dev,
>  		PMD_DRV_LOG(ERR, "Failed to add mac filter");
>  		return -EIO;
>  	}
> -	memcpy(&pf->dev_addr, mac_addr, ETH_ADDR_LEN);
> +	rte_ether_addr_copy(mac_addr, &pf->dev_addr);
> 
>  	flags = ICE_AQC_MAN_MAC_UPDATE_LAA_WOL;
>  	ret = ice_aq_manage_mac_write(hw, mac_addr->addr_bytes, flags,
> NULL);
> --
> 2.17.1

Acked-by: Qiming Yang <qiming.yang@intel.com>
Ye Xiaolong Jan. 13, 2020, 8:05 a.m. UTC | #2
Hi, haiyue

On 01/03, Haiyue Wang wrote:
>Use the API rte_ether_addr_copy to do MAC assignment, instead of
>calling rte_memcpy function directly.

Please add Fix tags and cc stable.

Thanks,
Xiaolong
>
>Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
>---
>v3: Update the commit message
>
>v2: Update the commit title and message, use the rte_ether_addr_copy API
>    instead of just changing the length definition to make code style clean.
>
> drivers/net/ice/ice_ethdev.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
>diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
>index 2cbd82c94..d104df26f 100644
>--- a/drivers/net/ice/ice_ethdev.c
>+++ b/drivers/net/ice/ice_ethdev.c
>@@ -873,7 +873,7 @@ ice_add_mac_filter(struct ice_vsi *vsi, struct rte_ether_addr *mac_addr)
> 		ret = -ENOMEM;
> 		goto DONE;
> 	}
>-	rte_memcpy(&f->mac_info.mac_addr, mac_addr, ETH_ADDR_LEN);
>+	rte_ether_addr_copy(mac_addr, &f->mac_info.mac_addr);
> 	TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
> 	vsi->mac_num++;
> 
>@@ -1660,16 +1660,16 @@ ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
> 
> 	if (type == ICE_VSI_PF) {
> 		/* MAC configuration */
>-		rte_memcpy(pf->dev_addr.addr_bytes,
>-			   hw->port_info->mac.perm_addr,
>-			   ETH_ADDR_LEN);
>+		rte_ether_addr_copy((struct rte_ether_addr *)
>+					hw->port_info->mac.perm_addr,
>+				    &pf->dev_addr);
> 
>-		rte_memcpy(&mac_addr, &pf->dev_addr, RTE_ETHER_ADDR_LEN);
>+		rte_ether_addr_copy(&pf->dev_addr, &mac_addr);
> 		ret = ice_add_mac_filter(vsi, &mac_addr);
> 		if (ret != ICE_SUCCESS)
> 			PMD_INIT_LOG(ERR, "Failed to add dflt MAC filter");
> 
>-		rte_memcpy(&mac_addr, &broadcast, RTE_ETHER_ADDR_LEN);
>+		rte_ether_addr_copy(&broadcast, &mac_addr);
> 		ret = ice_add_mac_filter(vsi, &mac_addr);
> 		if (ret != ICE_SUCCESS)
> 			PMD_INIT_LOG(ERR, "Failed to add MAC filter");
>@@ -3267,7 +3267,7 @@ static int ice_macaddr_set(struct rte_eth_dev *dev,
> 		PMD_DRV_LOG(ERR, "Failed to add mac filter");
> 		return -EIO;
> 	}
>-	memcpy(&pf->dev_addr, mac_addr, ETH_ADDR_LEN);
>+	rte_ether_addr_copy(mac_addr, &pf->dev_addr);
> 
> 	flags = ICE_AQC_MAN_MAC_UPDATE_LAA_WOL;
> 	ret = ice_aq_manage_mac_write(hw, mac_addr->addr_bytes, flags, NULL);
>-- 
>2.17.1
>
Haiyue Wang Jan. 13, 2020, 8:29 a.m. UTC | #3
> -----Original Message-----
> From: Ye, Xiaolong <xiaolong.ye@intel.com>
> Sent: Monday, January 13, 2020 16:06
> To: Wang, Haiyue <haiyue.wang@intel.com>
> Cc: dev@dpdk.org; stephen@networkplumber.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Yang, Qiming
> <qiming.yang@intel.com>
> Subject: Re: [PATCH v3] net/ice: use the copy API to do MAC assignment
> 
> Hi, haiyue
> 
> On 01/03, Haiyue Wang wrote:
> >Use the API rte_ether_addr_copy to do MAC assignment, instead of
> >calling rte_memcpy function directly.
> 
> Please add Fix tags and cc stable.
> 

Done in v4.

> Thanks,
> Xiaolong
> >
> >Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> >---
> >v3: Update the commit message
> >
> >v2: Update the commit title and message, use the rte_ether_addr_copy API
> >    instead of just changing the length definition to make code style clean.
> >
> > drivers/net/ice/ice_ethdev.c | 14 +++++++-------
> > 1 file changed, 7 insertions(+), 7 deletions(-)
> >
> >diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
> >index 2cbd82c94..d104df26f 100644
> >--- a/drivers/net/ice/ice_ethdev.c
> >+++ b/drivers/net/ice/ice_ethdev.c
> >@@ -873,7 +873,7 @@ ice_add_mac_filter(struct ice_vsi *vsi, struct rte_ether_addr *mac_addr)
> > 		ret = -ENOMEM;
> > 		goto DONE;
> > 	}
> >-	rte_memcpy(&f->mac_info.mac_addr, mac_addr, ETH_ADDR_LEN);
> >+	rte_ether_addr_copy(mac_addr, &f->mac_info.mac_addr);
> > 	TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
> > 	vsi->mac_num++;
> >
> >@@ -1660,16 +1660,16 @@ ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
> >
> > 	if (type == ICE_VSI_PF) {
> > 		/* MAC configuration */
> >-		rte_memcpy(pf->dev_addr.addr_bytes,
> >-			   hw->port_info->mac.perm_addr,
> >-			   ETH_ADDR_LEN);
> >+		rte_ether_addr_copy((struct rte_ether_addr *)
> >+					hw->port_info->mac.perm_addr,
> >+				    &pf->dev_addr);
> >
> >-		rte_memcpy(&mac_addr, &pf->dev_addr, RTE_ETHER_ADDR_LEN);
> >+		rte_ether_addr_copy(&pf->dev_addr, &mac_addr);
> > 		ret = ice_add_mac_filter(vsi, &mac_addr);
> > 		if (ret != ICE_SUCCESS)
> > 			PMD_INIT_LOG(ERR, "Failed to add dflt MAC filter");
> >
> >-		rte_memcpy(&mac_addr, &broadcast, RTE_ETHER_ADDR_LEN);
> >+		rte_ether_addr_copy(&broadcast, &mac_addr);
> > 		ret = ice_add_mac_filter(vsi, &mac_addr);
> > 		if (ret != ICE_SUCCESS)
> > 			PMD_INIT_LOG(ERR, "Failed to add MAC filter");
> >@@ -3267,7 +3267,7 @@ static int ice_macaddr_set(struct rte_eth_dev *dev,
> > 		PMD_DRV_LOG(ERR, "Failed to add mac filter");
> > 		return -EIO;
> > 	}
> >-	memcpy(&pf->dev_addr, mac_addr, ETH_ADDR_LEN);
> >+	rte_ether_addr_copy(mac_addr, &pf->dev_addr);
> >
> > 	flags = ICE_AQC_MAN_MAC_UPDATE_LAA_WOL;
> > 	ret = ice_aq_manage_mac_write(hw, mac_addr->addr_bytes, flags, NULL);
> >--
> >2.17.1
> >

Patch
diff mbox series

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 2cbd82c94..d104df26f 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -873,7 +873,7 @@  ice_add_mac_filter(struct ice_vsi *vsi, struct rte_ether_addr *mac_addr)
 		ret = -ENOMEM;
 		goto DONE;
 	}
-	rte_memcpy(&f->mac_info.mac_addr, mac_addr, ETH_ADDR_LEN);
+	rte_ether_addr_copy(mac_addr, &f->mac_info.mac_addr);
 	TAILQ_INSERT_TAIL(&vsi->mac_list, f, next);
 	vsi->mac_num++;
 
@@ -1660,16 +1660,16 @@  ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type)
 
 	if (type == ICE_VSI_PF) {
 		/* MAC configuration */
-		rte_memcpy(pf->dev_addr.addr_bytes,
-			   hw->port_info->mac.perm_addr,
-			   ETH_ADDR_LEN);
+		rte_ether_addr_copy((struct rte_ether_addr *)
+					hw->port_info->mac.perm_addr,
+				    &pf->dev_addr);
 
-		rte_memcpy(&mac_addr, &pf->dev_addr, RTE_ETHER_ADDR_LEN);
+		rte_ether_addr_copy(&pf->dev_addr, &mac_addr);
 		ret = ice_add_mac_filter(vsi, &mac_addr);
 		if (ret != ICE_SUCCESS)
 			PMD_INIT_LOG(ERR, "Failed to add dflt MAC filter");
 
-		rte_memcpy(&mac_addr, &broadcast, RTE_ETHER_ADDR_LEN);
+		rte_ether_addr_copy(&broadcast, &mac_addr);
 		ret = ice_add_mac_filter(vsi, &mac_addr);
 		if (ret != ICE_SUCCESS)
 			PMD_INIT_LOG(ERR, "Failed to add MAC filter");
@@ -3267,7 +3267,7 @@  static int ice_macaddr_set(struct rte_eth_dev *dev,
 		PMD_DRV_LOG(ERR, "Failed to add mac filter");
 		return -EIO;
 	}
-	memcpy(&pf->dev_addr, mac_addr, ETH_ADDR_LEN);
+	rte_ether_addr_copy(mac_addr, &pf->dev_addr);
 
 	flags = ICE_AQC_MAN_MAC_UPDATE_LAA_WOL;
 	ret = ice_aq_manage_mac_write(hw, mac_addr->addr_bytes, flags, NULL);