aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Duyck <aduyck@mirantis.com>2016-01-25 22:36:29 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2016-03-30 01:24:16 -0400
commit9f12df906cd807a05d71aa53a951532d1dd3b888 (patch)
tree32d4449824d6391d5c8bb70da70449409ef12e4f
parent56768045186c183f1d6e5cd916dd07751a777a8d (diff)
ixgbe: Store VXLAN port number in network order
The VXLAN port number should be stored in network order instead of in host order as it is accessed from the hot-path in ATR. This way we can avoid having to do any byte swaps in order to validate the port number. I moved the vxlan_port value into a hole in the read-mostly region of the adapter struct. This way it should be in a warm cache-line instead of in some isolated region in memory when it needs to be accessed. In addition I went through and stripped a bunch of unneeded ifdef flags since having an extra variable present doesn't really hurt anything and makes the code easier to read. I also went through and dropped the NETIF_F_RXCSUM flag which was being set in hw_encap_features but provides no value as the flag is not evaluated in the Rx path. Signed-off-by: Alexander Duyck <aduyck@mirantis.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe.h8
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c61
2 files changed, 20 insertions, 49 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
index 84fa28ceb200..458549c06a4f 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
@@ -661,9 +661,7 @@ struct ixgbe_adapter {
661#define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP (u32)(1 << 9) 661#define IXGBE_FLAG2_RSS_FIELD_IPV6_UDP (u32)(1 << 9)
662#define IXGBE_FLAG2_PTP_PPS_ENABLED (u32)(1 << 10) 662#define IXGBE_FLAG2_PTP_PPS_ENABLED (u32)(1 << 10)
663#define IXGBE_FLAG2_PHY_INTERRUPT (u32)(1 << 11) 663#define IXGBE_FLAG2_PHY_INTERRUPT (u32)(1 << 11)
664#ifdef CONFIG_IXGBE_VXLAN
665#define IXGBE_FLAG2_VXLAN_REREG_NEEDED BIT(12) 664#define IXGBE_FLAG2_VXLAN_REREG_NEEDED BIT(12)
666#endif
667#define IXGBE_FLAG2_VLAN_PROMISC BIT(13) 665#define IXGBE_FLAG2_VLAN_PROMISC BIT(13)
668 666
669 /* Tx fast path data */ 667 /* Tx fast path data */
@@ -675,6 +673,9 @@ struct ixgbe_adapter {
675 int num_rx_queues; 673 int num_rx_queues;
676 u16 rx_itr_setting; 674 u16 rx_itr_setting;
677 675
676 /* Port number used to identify VXLAN traffic */
677 __be16 vxlan_port;
678
678 /* TX */ 679 /* TX */
679 struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp; 680 struct ixgbe_ring *tx_ring[MAX_TX_QUEUES] ____cacheline_aligned_in_smp;
680 681
@@ -782,9 +783,6 @@ struct ixgbe_adapter {
782 u32 timer_event_accumulator; 783 u32 timer_event_accumulator;
783 u32 vferr_refcount; 784 u32 vferr_refcount;
784 struct ixgbe_mac_addr *mac_table; 785 struct ixgbe_mac_addr *mac_table;
785#ifdef CONFIG_IXGBE_VXLAN
786 u16 vxlan_port;
787#endif
788 struct kobject *info_kobj; 786 struct kobject *info_kobj;
789#ifdef CONFIG_IXGBE_HWMON 787#ifdef CONFIG_IXGBE_HWMON
790 struct hwmon_buff *ixgbe_hwmon_buff; 788 struct hwmon_buff *ixgbe_hwmon_buff;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index f19327325675..f67c9a6429ac 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -4531,9 +4531,7 @@ static void ixgbe_clear_vxlan_port(struct ixgbe_adapter *adapter)
4531 case ixgbe_mac_X550: 4531 case ixgbe_mac_X550:
4532 case ixgbe_mac_X550EM_x: 4532 case ixgbe_mac_X550EM_x:
4533 IXGBE_WRITE_REG(&adapter->hw, IXGBE_VXLANCTRL, 0); 4533 IXGBE_WRITE_REG(&adapter->hw, IXGBE_VXLANCTRL, 0);
4534#ifdef CONFIG_IXGBE_VXLAN
4535 adapter->vxlan_port = 0; 4534 adapter->vxlan_port = 0;
4536#endif
4537 break; 4535 break;
4538 default: 4536 default:
4539 break; 4537 break;
@@ -7561,9 +7559,6 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
7561 } hdr; 7559 } hdr;
7562 struct tcphdr *th; 7560 struct tcphdr *th;
7563 struct sk_buff *skb; 7561 struct sk_buff *skb;
7564#ifdef CONFIG_IXGBE_VXLAN
7565 u8 encap = false;
7566#endif /* CONFIG_IXGBE_VXLAN */
7567 __be16 vlan_id; 7562 __be16 vlan_id;
7568 7563
7569 /* if ring doesn't have a interrupt vector, cannot perform ATR */ 7564 /* if ring doesn't have a interrupt vector, cannot perform ATR */
@@ -7579,28 +7574,21 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
7579 /* snag network header to get L4 type and address */ 7574 /* snag network header to get L4 type and address */
7580 skb = first->skb; 7575 skb = first->skb;
7581 hdr.network = skb_network_header(skb); 7576 hdr.network = skb_network_header(skb);
7582 if (!skb->encapsulation) { 7577 th = tcp_hdr(skb);
7583 th = tcp_hdr(skb);
7584 } else {
7585#ifdef CONFIG_IXGBE_VXLAN 7578#ifdef CONFIG_IXGBE_VXLAN
7579 if (skb->encapsulation &&
7580 first->protocol == htons(ETH_P_IP) &&
7581 hdr.ipv4->protocol != IPPROTO_UDP) {
7586 struct ixgbe_adapter *adapter = q_vector->adapter; 7582 struct ixgbe_adapter *adapter = q_vector->adapter;
7587 7583
7588 if (!adapter->vxlan_port) 7584 /* verify the port is recognized as VXLAN */
7589 return; 7585 if (adapter->vxlan_port &&
7590 if (first->protocol != htons(ETH_P_IP) || 7586 udp_hdr(skb)->dest == adapter->vxlan_port) {
7591 hdr.ipv4->version != IPVERSION || 7587 hdr.network = skb_inner_network_header(skb);
7592 hdr.ipv4->protocol != IPPROTO_UDP) { 7588 th = inner_tcp_hdr(skb);
7593 return;
7594 } 7589 }
7595 if (ntohs(udp_hdr(skb)->dest) != adapter->vxlan_port)
7596 return;
7597 encap = true;
7598 hdr.network = skb_inner_network_header(skb);
7599 th = inner_tcp_hdr(skb);
7600#else
7601 return;
7602#endif /* CONFIG_IXGBE_VXLAN */
7603 } 7590 }
7591#endif /* CONFIG_IXGBE_VXLAN */
7604 7592
7605 /* Currently only IPv4/IPv6 with TCP is supported */ 7593 /* Currently only IPv4/IPv6 with TCP is supported */
7606 switch (hdr.ipv4->version) { 7594 switch (hdr.ipv4->version) {
@@ -7682,10 +7670,8 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
7682 break; 7670 break;
7683 } 7671 }
7684 7672
7685#ifdef CONFIG_IXGBE_VXLAN 7673 if (hdr.network != skb_network_header(skb))
7686 if (encap)
7687 input.formatted.flow_type |= IXGBE_ATR_L4TYPE_TUNNEL_MASK; 7674 input.formatted.flow_type |= IXGBE_ATR_L4TYPE_TUNNEL_MASK;
7688#endif /* CONFIG_IXGBE_VXLAN */
7689 7675
7690 /* This assumes the Rx queue and Tx queue are bound to the same CPU */ 7676 /* This assumes the Rx queue and Tx queue are bound to the same CPU */
7691 ixgbe_fdir_add_signature_filter_82599(&q_vector->adapter->hw, 7677 ixgbe_fdir_add_signature_filter_82599(&q_vector->adapter->hw,
@@ -8554,7 +8540,6 @@ static void ixgbe_add_vxlan_port(struct net_device *dev, sa_family_t sa_family,
8554{ 8540{
8555 struct ixgbe_adapter *adapter = netdev_priv(dev); 8541 struct ixgbe_adapter *adapter = netdev_priv(dev);
8556 struct ixgbe_hw *hw = &adapter->hw; 8542 struct ixgbe_hw *hw = &adapter->hw;
8557 u16 new_port = ntohs(port);
8558 8543
8559 if (!(adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE)) 8544 if (!(adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE))
8560 return; 8545 return;
@@ -8562,18 +8547,18 @@ static void ixgbe_add_vxlan_port(struct net_device *dev, sa_family_t sa_family,
8562 if (sa_family == AF_INET6) 8547 if (sa_family == AF_INET6)
8563 return; 8548 return;
8564 8549
8565 if (adapter->vxlan_port == new_port) 8550 if (adapter->vxlan_port == port)
8566 return; 8551 return;
8567 8552
8568 if (adapter->vxlan_port) { 8553 if (adapter->vxlan_port) {
8569 netdev_info(dev, 8554 netdev_info(dev,
8570 "Hit Max num of VXLAN ports, not adding port %d\n", 8555 "Hit Max num of VXLAN ports, not adding port %d\n",
8571 new_port); 8556 ntohs(port));
8572 return; 8557 return;
8573 } 8558 }
8574 8559
8575 adapter->vxlan_port = new_port; 8560 adapter->vxlan_port = port;
8576 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, new_port); 8561 IXGBE_WRITE_REG(hw, IXGBE_VXLANCTRL, ntohs(port));
8577} 8562}
8578 8563
8579/** 8564/**
@@ -8586,7 +8571,6 @@ static void ixgbe_del_vxlan_port(struct net_device *dev, sa_family_t sa_family,
8586 __be16 port) 8571 __be16 port)
8587{ 8572{
8588 struct ixgbe_adapter *adapter = netdev_priv(dev); 8573 struct ixgbe_adapter *adapter = netdev_priv(dev);
8589 u16 new_port = ntohs(port);
8590 8574
8591 if (!(adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE)) 8575 if (!(adapter->flags & IXGBE_FLAG_VXLAN_OFFLOAD_CAPABLE))
8592 return; 8576 return;
@@ -8594,9 +8578,9 @@ static void ixgbe_del_vxlan_port(struct net_device *dev, sa_family_t sa_family,
8594 if (sa_family == AF_INET6) 8578 if (sa_family == AF_INET6)
8595 return; 8579 return;
8596 8580
8597 if (adapter->vxlan_port != new_port) { 8581 if (adapter->vxlan_port != port) {
8598 netdev_info(dev, "Port %d was not found, not deleting\n", 8582 netdev_info(dev, "Port %d was not found, not deleting\n",
8599 new_port); 8583 ntohs(port));
8600 return; 8584 return;
8601 } 8585 }
8602 8586
@@ -9265,17 +9249,6 @@ skip_sriov:
9265 netdev->priv_flags |= IFF_UNICAST_FLT; 9249 netdev->priv_flags |= IFF_UNICAST_FLT;
9266 netdev->priv_flags |= IFF_SUPP_NOFCS; 9250 netdev->priv_flags |= IFF_SUPP_NOFCS;
9267 9251
9268#ifdef CONFIG_IXGBE_VXLAN
9269 switch (adapter->hw.mac.type) {
9270 case ixgbe_mac_X550:
9271 case ixgbe_mac_X550EM_x:
9272 netdev->hw_enc_features |= NETIF_F_RXCSUM;
9273 break;
9274 default:
9275 break;
9276 }
9277#endif /* CONFIG_IXGBE_VXLAN */
9278
9279#ifdef CONFIG_IXGBE_DCB 9252#ifdef CONFIG_IXGBE_DCB
9280 netdev->dcbnl_ops = &dcbnl_ops; 9253 netdev->dcbnl_ops = &dcbnl_ops;
9281#endif 9254#endif