Skip to content

Commit 00266b3

Browse files
committed
Merge branch 'dsa-skb_mac_header'
Vladimir Oltean says: ==================== Remove skb_mac_header() dependency in DSA xmit path Eric started working on removing skb_mac_header() assumptions from the networking xmit path, and I offered to help for DSA: https://lore.kernel.org/netdev/20230321164519.1286357-1-edumazet@google.com/ The majority of this patch set is a straightforward replacement of skb_mac_header() with skb->data (hidden either behind skb_eth_hdr(), or behind skb_vlan_eth_hdr()). The only patch which is more "interesting" is 9/9. Another potential caller of __skb_vlan_pop() on xmit (and therefore also of skb_mac_header()) is tcf_vlan_act(), but I haven't had the time to investigate that (enough to submit changes other than what's here). v1->v2: - 09/09: document the vlan_tci argument of vlan_remove_tag() in the kdoc v1 at: https://lore.kernel.org/netdev/20230322233823.1806736-1-vladimir.oltean@nxp.com/ Cc: Madalin Bucur <madalin.bucur@nxp.com> ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 4d2bd25 + 0bcf2e4 commit 00266b3

19 files changed

Lines changed: 66 additions & 51 deletions

File tree

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,8 +1935,7 @@ u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb,
19351935

19361936
/* Skip VLAN tag if present */
19371937
if (ether_type == ETH_P_8021Q) {
1938-
struct vlan_ethhdr *vhdr =
1939-
(struct vlan_ethhdr *)skb->data;
1938+
struct vlan_ethhdr *vhdr = skb_vlan_eth_hdr(skb);
19401939

19411940
ether_type = ntohs(vhdr->h_vlan_encapsulated_proto);
19421941
}

drivers/net/ethernet/emulex/benet/be_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,7 @@ static struct sk_buff *be_lancer_xmit_workarounds(struct be_adapter *adapter,
11241124
struct be_wrb_params
11251125
*wrb_params)
11261126
{
1127-
struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data;
1127+
struct vlan_ethhdr *veh = skb_vlan_eth_hdr(skb);
11281128
unsigned int eth_hdr_len;
11291129
struct iphdr *ip;
11301130

drivers/net/ethernet/freescale/dpaa/dpaa_eth.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,13 +1482,8 @@ static int dpaa_enable_tx_csum(struct dpaa_priv *priv,
14821482
parse_result = (struct fman_prs_result *)parse_results;
14831483

14841484
/* If we're dealing with VLAN, get the real Ethernet type */
1485-
if (ethertype == ETH_P_8021Q) {
1486-
/* We can't always assume the MAC header is set correctly
1487-
* by the stack, so reset to beginning of skb->data
1488-
*/
1489-
skb_reset_mac_header(skb);
1490-
ethertype = ntohs(vlan_eth_hdr(skb)->h_vlan_encapsulated_proto);
1491-
}
1485+
if (ethertype == ETH_P_8021Q)
1486+
ethertype = ntohs(skb_vlan_eth_hdr(skb)->h_vlan_encapsulated_proto);
14921487

14931488
/* Fill in the relevant L3 parse result fields
14941489
* and read the L4 protocol type

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ static int hns3_handle_vtags(struct hns3_enet_ring *tx_ring,
15321532
if (unlikely(rc < 0))
15331533
return rc;
15341534

1535-
vhdr = (struct vlan_ethhdr *)skb->data;
1535+
vhdr = skb_vlan_eth_hdr(skb);
15361536
vhdr->h_vlan_TCI |= cpu_to_be16((skb->priority << VLAN_PRIO_SHIFT)
15371537
& VLAN_PRIO_MASK);
15381538

drivers/net/ethernet/intel/i40e/i40e_txrx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3063,7 +3063,7 @@ static inline int i40e_tx_prepare_vlan_flags(struct sk_buff *skb,
30633063
rc = skb_cow_head(skb, 0);
30643064
if (rc < 0)
30653065
return rc;
3066-
vhdr = (struct vlan_ethhdr *)skb->data;
3066+
vhdr = skb_vlan_eth_hdr(skb);
30673067
vhdr->h_vlan_TCI = htons(tx_flags >>
30683068
I40E_TX_FLAGS_VLAN_SHIFT);
30693069
} else {

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8798,7 +8798,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,
87988798

87998799
if (skb_cow_head(skb, 0))
88008800
goto out_drop;
8801-
vhdr = (struct vlan_ethhdr *)skb->data;
8801+
vhdr = skb_vlan_eth_hdr(skb);
88028802
vhdr->h_vlan_TCI = htons(tx_flags >>
88038803
IXGBE_TX_FLAGS_VLAN_SHIFT);
88048804
} else {

drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,7 @@ netxen_tso_check(struct net_device *netdev,
18541854

18551855
if (protocol == cpu_to_be16(ETH_P_8021Q)) {
18561856

1857-
vh = (struct vlan_ethhdr *)skb->data;
1857+
vh = skb_vlan_eth_hdr(skb);
18581858
protocol = vh->h_vlan_encapsulated_proto;
18591859
flags = FLAGS_VLAN_TAGGED;
18601860

drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ static void qlcnic_send_filter(struct qlcnic_adapter *adapter,
318318

319319
if (adapter->flags & QLCNIC_VLAN_FILTERING) {
320320
if (protocol == ETH_P_8021Q) {
321-
vh = (struct vlan_ethhdr *)skb->data;
321+
vh = skb_vlan_eth_hdr(skb);
322322
vlan_id = ntohs(vh->h_vlan_TCI);
323323
} else if (skb_vlan_tag_present(skb)) {
324324
vlan_id = skb_vlan_tag_get(skb);
@@ -468,7 +468,7 @@ static int qlcnic_tx_pkt(struct qlcnic_adapter *adapter,
468468
u32 producer = tx_ring->producer;
469469

470470
if (protocol == ETH_P_8021Q) {
471-
vh = (struct vlan_ethhdr *)skb->data;
471+
vh = skb_vlan_eth_hdr(skb);
472472
flags = QLCNIC_FLAGS_VLAN_TAGGED;
473473
vlan_tci = ntohs(vh->h_vlan_TCI);
474474
protocol = ntohs(vh->h_vlan_encapsulated_proto);

drivers/net/ethernet/sfc/tx_tso.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static __be16 efx_tso_check_protocol(struct sk_buff *skb)
147147
EFX_WARN_ON_ONCE_PARANOID(((struct ethhdr *)skb->data)->h_proto !=
148148
protocol);
149149
if (protocol == htons(ETH_P_8021Q)) {
150-
struct vlan_ethhdr *veh = (struct vlan_ethhdr *)skb->data;
150+
struct vlan_ethhdr *veh = skb_vlan_eth_hdr(skb);
151151

152152
protocol = veh->h_vlan_encapsulated_proto;
153153
}

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4569,13 +4569,10 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
45694569

45704570
static void stmmac_rx_vlan(struct net_device *dev, struct sk_buff *skb)
45714571
{
4572-
struct vlan_ethhdr *veth;
4573-
__be16 vlan_proto;
4572+
struct vlan_ethhdr *veth = skb_vlan_eth_hdr(skb);
4573+
__be16 vlan_proto = veth->h_vlan_proto;
45744574
u16 vlanid;
45754575

4576-
veth = (struct vlan_ethhdr *)skb->data;
4577-
vlan_proto = veth->h_vlan_proto;
4578-
45794576
if ((vlan_proto == htons(ETH_P_8021Q) &&
45804577
dev->features & NETIF_F_HW_VLAN_CTAG_RX) ||
45814578
(vlan_proto == htons(ETH_P_8021AD) &&

0 commit comments

Comments
 (0)