Skip to content

Commit 9113302

Browse files
JanJSokolowskidavem330
authored andcommitted
ice: Fix undersized tx_flags variable
As not all ICE_TX_FLAGS_* fit in current 16-bit limited tx_flags field that was introduced in the Fixes commit, VLAN-related information would be discarded completely. As such, creating a vlan and trying to run ping through would result in no traffic passing. Fix that by refactoring tx_flags variable into flags only and a separate variable that holds VLAN ID. As there is some space left, type variable can fit between those two. Pahole reports no size change to ice_tx_buf struct. Fixes: aa1d3fa ("ice: Robustify cleaning/completing XDP Tx buffers") Signed-off-by: Jan Sokolowski <[email protected]> Reviewed-by: Alexander Lobakin <[email protected]> Signed-off-by: Tony Nguyen <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 47af429 commit 9113302

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

drivers/net/ethernet/intel/ice/ice_dcb_lib.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,10 +932,9 @@ ice_tx_prepare_vlan_flags_dcb(struct ice_tx_ring *tx_ring,
932932
if ((first->tx_flags & ICE_TX_FLAGS_HW_VLAN ||
933933
first->tx_flags & ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN) ||
934934
skb->priority != TC_PRIO_CONTROL) {
935-
first->tx_flags &= ~ICE_TX_FLAGS_VLAN_PR_M;
935+
first->vid &= ~VLAN_PRIO_MASK;
936936
/* Mask the lower 3 bits to set the 802.1p priority */
937-
first->tx_flags |= (skb->priority & 0x7) <<
938-
ICE_TX_FLAGS_VLAN_PR_S;
937+
first->vid |= (skb->priority << VLAN_PRIO_SHIFT) & VLAN_PRIO_MASK;
939938
/* if this is not already set it means a VLAN 0 + priority needs
940939
* to be offloaded
941940
*/

drivers/net/ethernet/intel/ice/ice_txrx.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,8 +1664,7 @@ ice_tx_map(struct ice_tx_ring *tx_ring, struct ice_tx_buf *first,
16641664

16651665
if (first->tx_flags & ICE_TX_FLAGS_HW_VLAN) {
16661666
td_cmd |= (u64)ICE_TX_DESC_CMD_IL2TAG1;
1667-
td_tag = (first->tx_flags & ICE_TX_FLAGS_VLAN_M) >>
1668-
ICE_TX_FLAGS_VLAN_S;
1667+
td_tag = first->vid;
16691668
}
16701669

16711670
dma = dma_map_single(tx_ring->dev, skb->data, size, DMA_TO_DEVICE);
@@ -1998,7 +1997,7 @@ ice_tx_prepare_vlan_flags(struct ice_tx_ring *tx_ring, struct ice_tx_buf *first)
19981997
* VLAN offloads exclusively so we only care about the VLAN ID here
19991998
*/
20001999
if (skb_vlan_tag_present(skb)) {
2001-
first->tx_flags |= skb_vlan_tag_get(skb) << ICE_TX_FLAGS_VLAN_S;
2000+
first->vid = skb_vlan_tag_get(skb);
20022001
if (tx_ring->flags & ICE_TX_FLAGS_RING_VLAN_L2TAG2)
20032002
first->tx_flags |= ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN;
20042003
else
@@ -2388,8 +2387,7 @@ ice_xmit_frame_ring(struct sk_buff *skb, struct ice_tx_ring *tx_ring)
23882387
offload.cd_qw1 |= (u64)(ICE_TX_DESC_DTYPE_CTX |
23892388
(ICE_TX_CTX_DESC_IL2TAG2 <<
23902389
ICE_TXD_CTX_QW1_CMD_S));
2391-
offload.cd_l2tag2 = (first->tx_flags & ICE_TX_FLAGS_VLAN_M) >>
2392-
ICE_TX_FLAGS_VLAN_S;
2390+
offload.cd_l2tag2 = first->vid;
23932391
}
23942392

23952393
/* set up TSO offload */

drivers/net/ethernet/intel/ice/ice_txrx.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,6 @@ static inline int ice_skb_pad(void)
127127
#define ICE_TX_FLAGS_IPV6 BIT(6)
128128
#define ICE_TX_FLAGS_TUNNEL BIT(7)
129129
#define ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN BIT(8)
130-
#define ICE_TX_FLAGS_VLAN_M 0xffff0000
131-
#define ICE_TX_FLAGS_VLAN_PR_M 0xe0000000
132-
#define ICE_TX_FLAGS_VLAN_PR_S 29
133-
#define ICE_TX_FLAGS_VLAN_S 16
134130

135131
#define ICE_XDP_PASS 0
136132
#define ICE_XDP_CONSUMED BIT(0)
@@ -182,8 +178,9 @@ struct ice_tx_buf {
182178
unsigned int gso_segs;
183179
unsigned int nr_frags; /* used for mbuf XDP */
184180
};
185-
u32 type:16; /* &ice_tx_buf_type */
186-
u32 tx_flags:16;
181+
u32 tx_flags:12;
182+
u32 type:4; /* &ice_tx_buf_type */
183+
u32 vid:16;
187184
DEFINE_DMA_UNMAP_LEN(len);
188185
DEFINE_DMA_UNMAP_ADDR(dma);
189186
};

0 commit comments

Comments
 (0)