[PATCH net-next 10/13] net: fec: fec_enet_rx_queue(): replace open coded cast by skb_vlan_eth_hdr()

Marc Kleine-Budde posted 13 patches 1 month, 1 week ago
[PATCH net-next 10/13] net: fec: fec_enet_rx_queue(): replace open coded cast by skb_vlan_eth_hdr()
Posted by Marc Kleine-Budde 1 month, 1 week ago
In order to clean up the VLAN handling, replace an open coded cast
from skb->data to the vlan header with skb_vlan_eth_hdr().

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/ethernet/freescale/fec_main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index eb26e869c026225194f4df66db145494408bfe8a..fd7a78ec5fa8ac0f7d141779938a4690594dbef1 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1819,8 +1819,7 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
 		    fep->bufdesc_ex &&
 		    (ebdp->cbd_esc & cpu_to_fec32(BD_ENET_RX_VLAN))) {
 			/* Push and remove the vlan tag */
-			struct vlan_hdr *vlan_header =
-					(struct vlan_hdr *) (data + ETH_HLEN);
+			struct vlan_ethhdr *vlan_header = skb_vlan_eth_hdr(skb);
 			vlan_tag = ntohs(vlan_header->h_vlan_TCI);
 
 			vlan_packet_rcvd = true;

-- 
2.45.2
Re: [PATCH net-next 10/13] net: fec: fec_enet_rx_queue(): replace open coded cast by skb_vlan_eth_hdr()
Posted by Frank Li 1 month, 1 week ago
On Wed, Oct 16, 2024 at 11:51:58PM +0200, Marc Kleine-Budde wrote:
> In order to clean up the VLAN handling, replace an open coded cast
> from skb->data to the vlan header with skb_vlan_eth_hdr().

Replace manual VLAN header calculation with skb_vlan_eth_hdr()

Use the provided helper function skb_vlan_eth_hdr() to replace manual VLAN
header calculation for better readability and maintainability.

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> ---
>  drivers/net/ethernet/freescale/fec_main.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
> index eb26e869c026225194f4df66db145494408bfe8a..fd7a78ec5fa8ac0f7d141779938a4690594dbef1 100644
> --- a/drivers/net/ethernet/freescale/fec_main.c
> +++ b/drivers/net/ethernet/freescale/fec_main.c
> @@ -1819,8 +1819,7 @@ fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget)
>  		    fep->bufdesc_ex &&
>  		    (ebdp->cbd_esc & cpu_to_fec32(BD_ENET_RX_VLAN))) {
>  			/* Push and remove the vlan tag */
> -			struct vlan_hdr *vlan_header =
> -					(struct vlan_hdr *) (data + ETH_HLEN);
> +			struct vlan_ethhdr *vlan_header = skb_vlan_eth_hdr(skb);
>  			vlan_tag = ntohs(vlan_header->h_vlan_TCI);
>
>  			vlan_packet_rcvd = true;
>
> --
> 2.45.2
>
>
Re: [PATCH net-next 10/13] net: fec: fec_enet_rx_queue(): replace open coded cast by skb_vlan_eth_hdr()
Posted by Marc Kleine-Budde 1 month, 1 week ago
On 16.10.2024 22:44:18, Frank Li wrote:
> On Wed, Oct 16, 2024 at 11:51:58PM +0200, Marc Kleine-Budde wrote:
> > In order to clean up the VLAN handling, replace an open coded cast
> > from skb->data to the vlan header with skb_vlan_eth_hdr().
> 
> Replace manual VLAN header calculation with skb_vlan_eth_hdr()
> 
> Use the provided helper function skb_vlan_eth_hdr() to replace manual VLAN
> header calculation for better readability and maintainability.

Fixed,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |