diff options
author | Alexander Duyck <alexander.h.duyck@intel.com> | 2010-11-16 22:27:01 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2010-11-16 22:27:01 -0500 |
commit | ee9e0f0b40c4fb4ad71d677c094d518db42f7076 (patch) | |
tree | 11660dc6031dd00f3cb589e41e83770e8283051f /drivers/net/ixgbe | |
parent | c267fc166a3308c45c7f0ad2ddd6fc696caaeb80 (diff) |
ixgbe: cleanup ATR filter setup function
This change cleans up the ixgbe_atr filter setup function so that it uses
fewer items from the stack. Since the code is only applicable to IPv4 w/
TCP it makes sense to just use the pointers based on the headers themselves
instead of copying them to temp variables and then writing those to the
filters.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Tested-by: Ross Brattain <ross.b.brattain@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ixgbe')
-rw-r--r-- | drivers/net/ixgbe/ixgbe_main.c | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index 584608d267b2..402ab7b2706a 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -2530,7 +2530,14 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter, | |||
2530 | } | 2530 | } |
2531 | 2531 | ||
2532 | /* reinitialize flowdirector state */ | 2532 | /* reinitialize flowdirector state */ |
2533 | set_bit(__IXGBE_TX_FDIR_INIT_DONE, &ring->state); | 2533 | if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) && |
2534 | adapter->atr_sample_rate) { | ||
2535 | ring->atr_sample_rate = adapter->atr_sample_rate; | ||
2536 | ring->atr_count = 0; | ||
2537 | set_bit(__IXGBE_TX_FDIR_INIT_DONE, &ring->state); | ||
2538 | } else { | ||
2539 | ring->atr_sample_rate = 0; | ||
2540 | } | ||
2534 | 2541 | ||
2535 | /* enable queue */ | 2542 | /* enable queue */ |
2536 | txdctl |= IXGBE_TXDCTL_ENABLE; | 2543 | txdctl |= IXGBE_TXDCTL_ENABLE; |
@@ -6227,47 +6234,34 @@ static void ixgbe_tx_queue(struct ixgbe_ring *tx_ring, | |||
6227 | } | 6234 | } |
6228 | 6235 | ||
6229 | static void ixgbe_atr(struct ixgbe_adapter *adapter, struct sk_buff *skb, | 6236 | static void ixgbe_atr(struct ixgbe_adapter *adapter, struct sk_buff *skb, |
6230 | int queue, u32 tx_flags, __be16 protocol) | 6237 | u8 queue, u32 tx_flags, __be16 protocol) |
6231 | { | 6238 | { |
6232 | struct ixgbe_atr_input atr_input; | 6239 | struct ixgbe_atr_input atr_input; |
6233 | struct tcphdr *th; | ||
6234 | struct iphdr *iph = ip_hdr(skb); | 6240 | struct iphdr *iph = ip_hdr(skb); |
6235 | struct ethhdr *eth = (struct ethhdr *)skb->data; | 6241 | struct ethhdr *eth = (struct ethhdr *)skb->data; |
6236 | u16 vlan_id, src_port, dst_port, flex_bytes; | 6242 | struct tcphdr *th; |
6237 | u32 src_ipv4_addr, dst_ipv4_addr; | 6243 | u16 vlan_id; |
6238 | u8 l4type = 0; | ||
6239 | 6244 | ||
6240 | /* Right now, we support IPv4 only */ | 6245 | /* Right now, we support IPv4 w/ TCP only */ |
6241 | if (protocol != htons(ETH_P_IP)) | 6246 | if (protocol != htons(ETH_P_IP) || |
6247 | iph->protocol != IPPROTO_TCP) | ||
6242 | return; | 6248 | return; |
6243 | /* check if we're UDP or TCP */ | ||
6244 | if (iph->protocol == IPPROTO_TCP) { | ||
6245 | th = tcp_hdr(skb); | ||
6246 | src_port = th->source; | ||
6247 | dst_port = th->dest; | ||
6248 | l4type |= IXGBE_ATR_L4TYPE_TCP; | ||
6249 | /* l4type IPv4 type is 0, no need to assign */ | ||
6250 | } else { | ||
6251 | /* Unsupported L4 header, just bail here */ | ||
6252 | return; | ||
6253 | } | ||
6254 | 6249 | ||
6255 | memset(&atr_input, 0, sizeof(struct ixgbe_atr_input)); | 6250 | memset(&atr_input, 0, sizeof(struct ixgbe_atr_input)); |
6256 | 6251 | ||
6257 | vlan_id = (tx_flags & IXGBE_TX_FLAGS_VLAN_MASK) >> | 6252 | vlan_id = (tx_flags & IXGBE_TX_FLAGS_VLAN_MASK) >> |
6258 | IXGBE_TX_FLAGS_VLAN_SHIFT; | 6253 | IXGBE_TX_FLAGS_VLAN_SHIFT; |
6259 | src_ipv4_addr = iph->saddr; | 6254 | |
6260 | dst_ipv4_addr = iph->daddr; | 6255 | th = tcp_hdr(skb); |
6261 | flex_bytes = eth->h_proto; | ||
6262 | 6256 | ||
6263 | ixgbe_atr_set_vlan_id_82599(&atr_input, vlan_id); | 6257 | ixgbe_atr_set_vlan_id_82599(&atr_input, vlan_id); |
6264 | ixgbe_atr_set_src_port_82599(&atr_input, dst_port); | 6258 | ixgbe_atr_set_src_port_82599(&atr_input, th->dest); |
6265 | ixgbe_atr_set_dst_port_82599(&atr_input, src_port); | 6259 | ixgbe_atr_set_dst_port_82599(&atr_input, th->source); |
6266 | ixgbe_atr_set_flex_byte_82599(&atr_input, flex_bytes); | 6260 | ixgbe_atr_set_flex_byte_82599(&atr_input, eth->h_proto); |
6267 | ixgbe_atr_set_l4type_82599(&atr_input, l4type); | 6261 | ixgbe_atr_set_l4type_82599(&atr_input, IXGBE_ATR_L4TYPE_TCP); |
6268 | /* src and dst are inverted, think how the receiver sees them */ | 6262 | /* src and dst are inverted, think how the receiver sees them */ |
6269 | ixgbe_atr_set_src_ipv4_82599(&atr_input, dst_ipv4_addr); | 6263 | ixgbe_atr_set_src_ipv4_82599(&atr_input, iph->daddr); |
6270 | ixgbe_atr_set_dst_ipv4_82599(&atr_input, src_ipv4_addr); | 6264 | ixgbe_atr_set_dst_ipv4_82599(&atr_input, iph->saddr); |
6271 | 6265 | ||
6272 | /* This assumes the Rx queue and Tx queue are bound to the same CPU */ | 6266 | /* This assumes the Rx queue and Tx queue are bound to the same CPU */ |
6273 | ixgbe_fdir_add_signature_filter_82599(&adapter->hw, &atr_input, queue); | 6267 | ixgbe_fdir_add_signature_filter_82599(&adapter->hw, &atr_input, queue); |