|
@@ -2139,6 +2139,67 @@ static int i40e_maybe_stop_tx(struct i40e_ring *tx_ring, int size)
|
|
return __i40e_maybe_stop_tx(tx_ring, size);
|
|
return __i40e_maybe_stop_tx(tx_ring, size);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ * i40e_chk_linearize - Check if there are more than 8 fragments per packet
|
|
|
|
+ * @skb: send buffer
|
|
|
|
+ * @tx_flags: collected send information
|
|
|
|
+ * @hdr_len: size of the packet header
|
|
|
|
+ *
|
|
|
|
+ * Note: Our HW can't scatter-gather more than 8 fragments to build
|
|
|
|
+ * a packet on the wire and so we need to figure out the cases where we
|
|
|
|
+ * need to linearize the skb.
|
|
|
|
+ **/
|
|
|
|
+static bool i40e_chk_linearize(struct sk_buff *skb, u32 tx_flags,
|
|
|
|
+ const u8 hdr_len)
|
|
|
|
+{
|
|
|
|
+ struct skb_frag_struct *frag;
|
|
|
|
+ bool linearize = false;
|
|
|
|
+ unsigned int size = 0;
|
|
|
|
+ u16 num_frags;
|
|
|
|
+ u16 gso_segs;
|
|
|
|
+
|
|
|
|
+ num_frags = skb_shinfo(skb)->nr_frags;
|
|
|
|
+ gso_segs = skb_shinfo(skb)->gso_segs;
|
|
|
|
+
|
|
|
|
+ if (tx_flags & (I40E_TX_FLAGS_TSO | I40E_TX_FLAGS_FSO)) {
|
|
|
|
+ u16 j = 1;
|
|
|
|
+
|
|
|
|
+ if (num_frags < (I40E_MAX_BUFFER_TXD))
|
|
|
|
+ goto linearize_chk_done;
|
|
|
|
+ /* try the simple math, if we have too many frags per segment */
|
|
|
|
+ if (DIV_ROUND_UP((num_frags + gso_segs), gso_segs) >
|
|
|
|
+ I40E_MAX_BUFFER_TXD) {
|
|
|
|
+ linearize = true;
|
|
|
|
+ goto linearize_chk_done;
|
|
|
|
+ }
|
|
|
|
+ frag = &skb_shinfo(skb)->frags[0];
|
|
|
|
+ size = hdr_len;
|
|
|
|
+ /* we might still have more fragments per segment */
|
|
|
|
+ do {
|
|
|
|
+ size += skb_frag_size(frag);
|
|
|
|
+ frag++; j++;
|
|
|
|
+ if (j == I40E_MAX_BUFFER_TXD) {
|
|
|
|
+ if (size < skb_shinfo(skb)->gso_size) {
|
|
|
|
+ linearize = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ j = 1;
|
|
|
|
+ size -= skb_shinfo(skb)->gso_size;
|
|
|
|
+ if (size)
|
|
|
|
+ j++;
|
|
|
|
+ size += hdr_len;
|
|
|
|
+ }
|
|
|
|
+ num_frags--;
|
|
|
|
+ } while (num_frags);
|
|
|
|
+ } else {
|
|
|
|
+ if (num_frags >= I40E_MAX_BUFFER_TXD)
|
|
|
|
+ linearize = true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+linearize_chk_done:
|
|
|
|
+ return linearize;
|
|
|
|
+}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* i40e_tx_map - Build the Tx descriptor
|
|
* i40e_tx_map - Build the Tx descriptor
|
|
* @tx_ring: ring to send buffer on
|
|
* @tx_ring: ring to send buffer on
|
|
@@ -2396,6 +2457,10 @@ static netdev_tx_t i40e_xmit_frame_ring(struct sk_buff *skb,
|
|
if (tsyn)
|
|
if (tsyn)
|
|
tx_flags |= I40E_TX_FLAGS_TSYN;
|
|
tx_flags |= I40E_TX_FLAGS_TSYN;
|
|
|
|
|
|
|
|
+ if (i40e_chk_linearize(skb, tx_flags, hdr_len))
|
|
|
|
+ if (skb_linearize(skb))
|
|
|
|
+ goto out_drop;
|
|
|
|
+
|
|
skb_tx_timestamp(skb);
|
|
skb_tx_timestamp(skb);
|
|
|
|
|
|
/* always enable CRC insertion offload */
|
|
/* always enable CRC insertion offload */
|