提交 9f8cdf4f 编写于 作者: J Jesse Brandeburg 提交者: Jeff Garzik

ixgbe: xmit frame refactor

ixgbe_xmit_frame can be refactored to use fewer locals and better
utilize common kernel macros.

also fixed minor buglet with internal to driver vlan flag variable being
passed incorrectly.
Signed-off-by: NJesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: NJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: NJeff Garzik <jgarzik@redhat.com>
上级 74ce8dd2
...@@ -3213,8 +3213,8 @@ static int ixgbe_tso(struct ixgbe_adapter *adapter, ...@@ -3213,8 +3213,8 @@ static int ixgbe_tso(struct ixgbe_adapter *adapter,
unsigned int i; unsigned int i;
int err; int err;
struct ixgbe_tx_buffer *tx_buffer_info; struct ixgbe_tx_buffer *tx_buffer_info;
u32 vlan_macip_lens = 0, type_tucmd_mlhl = 0; u32 vlan_macip_lens = 0, type_tucmd_mlhl;
u32 mss_l4len_idx = 0, l4len; u32 mss_l4len_idx, l4len;
if (skb_is_gso(skb)) { if (skb_is_gso(skb)) {
if (skb_header_cloned(skb)) { if (skb_header_cloned(skb)) {
...@@ -3263,7 +3263,7 @@ static int ixgbe_tso(struct ixgbe_adapter *adapter, ...@@ -3263,7 +3263,7 @@ static int ixgbe_tso(struct ixgbe_adapter *adapter,
context_desc->seqnum_seed = 0; context_desc->seqnum_seed = 0;
/* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */ /* ADV DTYP TUCMD MKRLOC/ISCSIHEDLEN */
type_tucmd_mlhl |= (IXGBE_TXD_CMD_DEXT | type_tucmd_mlhl = (IXGBE_TXD_CMD_DEXT |
IXGBE_ADVTXD_DTYP_CTXT); IXGBE_ADVTXD_DTYP_CTXT);
if (skb->protocol == htons(ETH_P_IP)) if (skb->protocol == htons(ETH_P_IP))
...@@ -3272,7 +3272,7 @@ static int ixgbe_tso(struct ixgbe_adapter *adapter, ...@@ -3272,7 +3272,7 @@ static int ixgbe_tso(struct ixgbe_adapter *adapter,
context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd_mlhl); context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd_mlhl);
/* MSS L4LEN IDX */ /* MSS L4LEN IDX */
mss_l4len_idx |= mss_l4len_idx =
(skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT); (skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT);
mss_l4len_idx |= (l4len << IXGBE_ADVTXD_L4LEN_SHIFT); mss_l4len_idx |= (l4len << IXGBE_ADVTXD_L4LEN_SHIFT);
/* use index 1 for TSO */ /* use index 1 for TSO */
...@@ -3330,14 +3330,12 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter, ...@@ -3330,14 +3330,12 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter,
type_tucmd_mlhl |= type_tucmd_mlhl |=
IXGBE_ADVTXD_TUCMD_L4T_TCP; IXGBE_ADVTXD_TUCMD_L4T_TCP;
break; break;
case __constant_htons(ETH_P_IPV6): case __constant_htons(ETH_P_IPV6):
/* XXX what about other V6 headers?? */ /* XXX what about other V6 headers?? */
if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP) if (ipv6_hdr(skb)->nexthdr == IPPROTO_TCP)
type_tucmd_mlhl |= type_tucmd_mlhl |=
IXGBE_ADVTXD_TUCMD_L4T_TCP; IXGBE_ADVTXD_TUCMD_L4T_TCP;
break; break;
default: default:
if (unlikely(net_ratelimit())) { if (unlikely(net_ratelimit())) {
DPRINTK(PROBE, WARNING, DPRINTK(PROBE, WARNING,
...@@ -3354,6 +3352,7 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter, ...@@ -3354,6 +3352,7 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter,
tx_buffer_info->time_stamp = jiffies; tx_buffer_info->time_stamp = jiffies;
tx_buffer_info->next_to_watch = i; tx_buffer_info->next_to_watch = i;
adapter->hw_csum_tx_good++; adapter->hw_csum_tx_good++;
i++; i++;
if (i == tx_ring->count) if (i == tx_ring->count)
...@@ -3362,6 +3361,7 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter, ...@@ -3362,6 +3361,7 @@ static bool ixgbe_tx_csum(struct ixgbe_adapter *adapter,
return true; return true;
} }
return false; return false;
} }
...@@ -3533,43 +3533,35 @@ static int ixgbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev) ...@@ -3533,43 +3533,35 @@ static int ixgbe_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
{ {
struct ixgbe_adapter *adapter = netdev_priv(netdev); struct ixgbe_adapter *adapter = netdev_priv(netdev);
struct ixgbe_ring *tx_ring; struct ixgbe_ring *tx_ring;
unsigned int len = skb->len;
unsigned int first; unsigned int first;
unsigned int tx_flags = 0; unsigned int tx_flags = 0;
u8 hdr_len = 0; u8 hdr_len = 0;
int r_idx = 0, tso; int r_idx = 0, tso;
unsigned int mss = 0;
int count = 0; int count = 0;
unsigned int f; unsigned int f;
unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
len -= skb->data_len;
r_idx = (adapter->num_tx_queues - 1) & skb->queue_mapping; r_idx = (adapter->num_tx_queues - 1) & skb->queue_mapping;
tx_ring = &adapter->tx_ring[r_idx]; tx_ring = &adapter->tx_ring[r_idx];
if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
if (skb->len <= 0) { tx_flags |= vlan_tx_tag_get(skb);
dev_kfree_skb(skb); tx_flags <<= IXGBE_TX_FLAGS_VLAN_SHIFT;
return NETDEV_TX_OK; tx_flags |= IXGBE_TX_FLAGS_VLAN;
} }
mss = skb_shinfo(skb)->gso_size; /* three things can cause us to need a context descriptor */
if (skb_is_gso(skb) ||
if (mss) (skb->ip_summed == CHECKSUM_PARTIAL) ||
count++; (tx_flags & IXGBE_TX_FLAGS_VLAN))
else if (skb->ip_summed == CHECKSUM_PARTIAL)
count++; count++;
count += TXD_USE_COUNT(len); count += TXD_USE_COUNT(skb_headlen(skb));
for (f = 0; f < nr_frags; f++) for (f = 0; f < skb_shinfo(skb)->nr_frags; f++)
count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size); count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size);
if (ixgbe_maybe_stop_tx(netdev, tx_ring, count)) { if (ixgbe_maybe_stop_tx(netdev, tx_ring, count)) {
adapter->tx_busy++; adapter->tx_busy++;
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
if (adapter->vlgrp && vlan_tx_tag_present(skb)) {
tx_flags |= IXGBE_TX_FLAGS_VLAN;
tx_flags |= (vlan_tx_tag_get(skb) << IXGBE_TX_FLAGS_VLAN_SHIFT);
}
if (skb->protocol == htons(ETH_P_IP)) if (skb->protocol == htons(ETH_P_IP))
tx_flags |= IXGBE_TX_FLAGS_IPV4; tx_flags |= IXGBE_TX_FLAGS_IPV4;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册