提交 31f6adbb 编写于 作者: A Alexander Duyck 提交者: Jeff Kirsher

igb: Cleanup protocol handling in transmit path

This change is meant to cleanup the protocol handling in the transmit path
so that it correctly offloads software VLAN tagged frames.
Signed-off-by: NAlexander Duyck <alexander.h.duyck@intel.com>
Tested-by: NAaron Brown  <aaron.f.brown@intel.com>
Signed-off-by: NJeff Kirsher <jeffrey.t.kirsher@intel.com>
上级 e032afc8
...@@ -3987,8 +3987,8 @@ void igb_tx_ctxtdesc(struct igb_ring *tx_ring, u32 vlan_macip_lens, ...@@ -3987,8 +3987,8 @@ void igb_tx_ctxtdesc(struct igb_ring *tx_ring, u32 vlan_macip_lens,
context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx); context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx);
} }
static inline int igb_tso(struct igb_ring *tx_ring, static inline int igb_tso(struct igb_ring *tx_ring, struct sk_buff *skb,
struct sk_buff *skb, u32 tx_flags, u8 *hdr_len) u32 tx_flags, __be16 protocol, u8 *hdr_len)
{ {
int err; int err;
u32 vlan_macip_lens, type_tucmd; u32 vlan_macip_lens, type_tucmd;
...@@ -4006,7 +4006,7 @@ static inline int igb_tso(struct igb_ring *tx_ring, ...@@ -4006,7 +4006,7 @@ static inline int igb_tso(struct igb_ring *tx_ring,
/* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */
type_tucmd = E1000_ADVTXD_TUCMD_L4T_TCP; type_tucmd = E1000_ADVTXD_TUCMD_L4T_TCP;
if (skb->protocol == htons(ETH_P_IP)) { if (protocol == __constant_htons(ETH_P_IP)) {
struct iphdr *iph = ip_hdr(skb); struct iphdr *iph = ip_hdr(skb);
iph->tot_len = 0; iph->tot_len = 0;
iph->check = 0; iph->check = 0;
...@@ -4039,8 +4039,8 @@ static inline int igb_tso(struct igb_ring *tx_ring, ...@@ -4039,8 +4039,8 @@ static inline int igb_tso(struct igb_ring *tx_ring,
return 1; return 1;
} }
static inline bool igb_tx_csum(struct igb_ring *tx_ring, static inline bool igb_tx_csum(struct igb_ring *tx_ring, struct sk_buff *skb,
struct sk_buff *skb, u32 tx_flags) u32 tx_flags, __be16 protocol)
{ {
u32 vlan_macip_lens = 0; u32 vlan_macip_lens = 0;
u32 mss_l4len_idx = 0; u32 mss_l4len_idx = 0;
...@@ -4051,7 +4051,7 @@ static inline bool igb_tx_csum(struct igb_ring *tx_ring, ...@@ -4051,7 +4051,7 @@ static inline bool igb_tx_csum(struct igb_ring *tx_ring,
return false; return false;
} else { } else {
u8 l4_hdr = 0; u8 l4_hdr = 0;
switch (skb->protocol) { switch (protocol) {
case __constant_htons(ETH_P_IP): case __constant_htons(ETH_P_IP):
vlan_macip_lens |= skb_network_header_len(skb); vlan_macip_lens |= skb_network_header_len(skb);
type_tucmd |= E1000_ADVTXD_TUCMD_IPV4; type_tucmd |= E1000_ADVTXD_TUCMD_IPV4;
...@@ -4065,7 +4065,7 @@ static inline bool igb_tx_csum(struct igb_ring *tx_ring, ...@@ -4065,7 +4065,7 @@ static inline bool igb_tx_csum(struct igb_ring *tx_ring,
if (unlikely(net_ratelimit())) { if (unlikely(net_ratelimit())) {
dev_warn(tx_ring->dev, dev_warn(tx_ring->dev,
"partial checksum but proto=%x!\n", "partial checksum but proto=%x!\n",
skb->protocol); protocol);
} }
break; break;
} }
...@@ -4305,6 +4305,7 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb, ...@@ -4305,6 +4305,7 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,
struct igb_tx_buffer *first; struct igb_tx_buffer *first;
int tso, count; int tso, count;
u32 tx_flags = 0; u32 tx_flags = 0;
__be16 protocol = vlan_get_protocol(skb);
u8 hdr_len = 0; u8 hdr_len = 0;
/* need: 1 descriptor per page, /* need: 1 descriptor per page,
...@@ -4330,16 +4331,14 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb, ...@@ -4330,16 +4331,14 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,
/* record the location of the first descriptor for this packet */ /* record the location of the first descriptor for this packet */
first = &tx_ring->tx_buffer_info[tx_ring->next_to_use]; first = &tx_ring->tx_buffer_info[tx_ring->next_to_use];
tso = igb_tso(tx_ring, skb, tx_flags, &hdr_len); tso = igb_tso(tx_ring, skb, tx_flags, protocol, &hdr_len);
if (tso < 0) { if (tso < 0) {
goto out_drop; goto out_drop;
} else if (tso) { } else if (tso) {
tx_flags |= IGB_TX_FLAGS_TSO | IGB_TX_FLAGS_CSUM; tx_flags |= IGB_TX_FLAGS_TSO | IGB_TX_FLAGS_CSUM;
if (skb->protocol == htons(ETH_P_IP)) if (protocol == htons(ETH_P_IP))
tx_flags |= IGB_TX_FLAGS_IPV4; tx_flags |= IGB_TX_FLAGS_IPV4;
} else if (igb_tx_csum(tx_ring, skb, tx_flags, protocol) &&
} else if (igb_tx_csum(tx_ring, skb, tx_flags) &&
(skb->ip_summed == CHECKSUM_PARTIAL)) { (skb->ip_summed == CHECKSUM_PARTIAL)) {
tx_flags |= IGB_TX_FLAGS_CSUM; tx_flags |= IGB_TX_FLAGS_CSUM;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册