aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/emulex/benet
diff options
context:
space:
mode:
authorSathya Perla <sathya.perla@emulex.com>2014-03-27 01:16:19 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-28 14:24:54 -0400
commitc9c47142f6bf4684c13b571b312b67f3830f1d86 (patch)
treeaf9e9a3b0cd7f514f1c41bab0e7c58dc3ca214fd /drivers/net/ethernet/emulex/benet
parenta401801c6ed141f8cee735775a501ea9e3e6aaed (diff)
be2net: csum, tso and rss steering offload support for VxLAN
This patch mainly implements the add/del_vxlan_port() methods by invoking the needed FW cmds for supporting VxLAN offloads for Skyhawk-R. Signed-off-by: Sathya Perla <sathya.perla@emulex.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/emulex/benet')
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h7
-rw-r--r--drivers/net/ethernet/emulex/benet/be_hw.h3
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c124
3 files changed, 125 insertions, 9 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index a587c8aa27ed..8ccaa2520dc3 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -296,6 +296,7 @@ struct be_rx_compl_info {
296 u8 qnq; 296 u8 qnq;
297 u8 pkt_type; 297 u8 pkt_type;
298 u8 ip_frag; 298 u8 ip_frag;
299 u8 tunneled;
299}; 300};
300 301
301struct be_rx_obj { 302struct be_rx_obj {
@@ -371,10 +372,11 @@ enum vf_state {
371#define BE_FLAGS_WORKER_SCHEDULED (1 << 3) 372#define BE_FLAGS_WORKER_SCHEDULED (1 << 3)
372#define BE_FLAGS_VLAN_PROMISC (1 << 4) 373#define BE_FLAGS_VLAN_PROMISC (1 << 4)
373#define BE_FLAGS_NAPI_ENABLED (1 << 9) 374#define BE_FLAGS_NAPI_ENABLED (1 << 9)
374#define BE_UC_PMAC_COUNT 30
375#define BE_VF_UC_PMAC_COUNT 2
376#define BE_FLAGS_QNQ_ASYNC_EVT_RCVD (1 << 11) 375#define BE_FLAGS_QNQ_ASYNC_EVT_RCVD (1 << 11)
376#define BE_FLAGS_VXLAN_OFFLOADS (1 << 12)
377 377
378#define BE_UC_PMAC_COUNT 30
379#define BE_VF_UC_PMAC_COUNT 2
378/* Ethtool set_dump flags */ 380/* Ethtool set_dump flags */
379#define LANCER_INITIATE_FW_DUMP 0x1 381#define LANCER_INITIATE_FW_DUMP 0x1
380 382
@@ -494,6 +496,7 @@ struct be_adapter {
494 u32 sli_family; 496 u32 sli_family;
495 u8 hba_port_num; 497 u8 hba_port_num;
496 u16 pvid; 498 u16 pvid;
499 __be16 vxlan_port;
497 struct phy_info phy; 500 struct phy_info phy;
498 u8 wol_cap; 501 u8 wol_cap;
499 bool wol_en; 502 bool wol_en;
diff --git a/drivers/net/ethernet/emulex/benet/be_hw.h b/drivers/net/ethernet/emulex/benet/be_hw.h
index 28ac8dd0beaa..3bd198550edb 100644
--- a/drivers/net/ethernet/emulex/benet/be_hw.h
+++ b/drivers/net/ethernet/emulex/benet/be_hw.h
@@ -407,7 +407,8 @@ struct amap_eth_rx_compl_v1 {
407 u8 vntagp; /* dword 2 */ 407 u8 vntagp; /* dword 2 */
408 u8 header_len[8]; /* dword 2 */ 408 u8 header_len[8]; /* dword 2 */
409 u8 header_split[2]; /* dword 2 */ 409 u8 header_split[2]; /* dword 2 */
410 u8 rsvd1[13]; /* dword 2 */ 410 u8 rsvd1[12]; /* dword 2 */
411 u8 tunneled;
411 u8 valid; /* dword 2 */ 412 u8 valid; /* dword 2 */
412 u8 rsshash[32]; /* dword 3 */ 413 u8 rsshash[32]; /* dword 3 */
413} __packed; 414} __packed;
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 8790e5497ba0..c89dc85ad8d6 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -23,6 +23,7 @@
23#include <linux/aer.h> 23#include <linux/aer.h>
24#include <linux/if_bridge.h> 24#include <linux/if_bridge.h>
25#include <net/busy_poll.h> 25#include <net/busy_poll.h>
26#include <net/vxlan.h>
26 27
27MODULE_VERSION(DRV_VER); 28MODULE_VERSION(DRV_VER);
28MODULE_DEVICE_TABLE(pci, be_dev_ids); 29MODULE_DEVICE_TABLE(pci, be_dev_ids);
@@ -718,10 +719,23 @@ static inline u16 be_get_tx_vlan_tag(struct be_adapter *adapter,
718 return vlan_tag; 719 return vlan_tag;
719} 720}
720 721
722/* Used only for IP tunnel packets */
723static u16 skb_inner_ip_proto(struct sk_buff *skb)
724{
725 return (inner_ip_hdr(skb)->version == 4) ?
726 inner_ip_hdr(skb)->protocol : inner_ipv6_hdr(skb)->nexthdr;
727}
728
729static u16 skb_ip_proto(struct sk_buff *skb)
730{
731 return (ip_hdr(skb)->version == 4) ?
732 ip_hdr(skb)->protocol : ipv6_hdr(skb)->nexthdr;
733}
734
721static void wrb_fill_hdr(struct be_adapter *adapter, struct be_eth_hdr_wrb *hdr, 735static void wrb_fill_hdr(struct be_adapter *adapter, struct be_eth_hdr_wrb *hdr,
722 struct sk_buff *skb, u32 wrb_cnt, u32 len, bool skip_hw_vlan) 736 struct sk_buff *skb, u32 wrb_cnt, u32 len, bool skip_hw_vlan)
723{ 737{
724 u16 vlan_tag; 738 u16 vlan_tag, proto;
725 739
726 memset(hdr, 0, sizeof(*hdr)); 740 memset(hdr, 0, sizeof(*hdr));
727 741
@@ -734,9 +748,15 @@ static void wrb_fill_hdr(struct be_adapter *adapter, struct be_eth_hdr_wrb *hdr,
734 if (skb_is_gso_v6(skb) && !lancer_chip(adapter)) 748 if (skb_is_gso_v6(skb) && !lancer_chip(adapter))
735 AMAP_SET_BITS(struct amap_eth_hdr_wrb, lso6, hdr, 1); 749 AMAP_SET_BITS(struct amap_eth_hdr_wrb, lso6, hdr, 1);
736 } else if (skb->ip_summed == CHECKSUM_PARTIAL) { 750 } else if (skb->ip_summed == CHECKSUM_PARTIAL) {
737 if (is_tcp_pkt(skb)) 751 if (skb->encapsulation) {
752 AMAP_SET_BITS(struct amap_eth_hdr_wrb, ipcs, hdr, 1);
753 proto = skb_inner_ip_proto(skb);
754 } else {
755 proto = skb_ip_proto(skb);
756 }
757 if (proto == IPPROTO_TCP)
738 AMAP_SET_BITS(struct amap_eth_hdr_wrb, tcpcs, hdr, 1); 758 AMAP_SET_BITS(struct amap_eth_hdr_wrb, tcpcs, hdr, 1);
739 else if (is_udp_pkt(skb)) 759 else if (proto == IPPROTO_UDP)
740 AMAP_SET_BITS(struct amap_eth_hdr_wrb, udpcs, hdr, 1); 760 AMAP_SET_BITS(struct amap_eth_hdr_wrb, udpcs, hdr, 1);
741 } 761 }
742 762
@@ -1467,9 +1487,10 @@ static void be_rx_stats_update(struct be_rx_obj *rxo,
1467static inline bool csum_passed(struct be_rx_compl_info *rxcp) 1487static inline bool csum_passed(struct be_rx_compl_info *rxcp)
1468{ 1488{
1469 /* L4 checksum is not reliable for non TCP/UDP packets. 1489 /* L4 checksum is not reliable for non TCP/UDP packets.
1470 * Also ignore ipcksm for ipv6 pkts */ 1490 * Also ignore ipcksm for ipv6 pkts
1491 */
1471 return (rxcp->tcpf || rxcp->udpf) && rxcp->l4_csum && 1492 return (rxcp->tcpf || rxcp->udpf) && rxcp->l4_csum &&
1472 (rxcp->ip_csum || rxcp->ipv6); 1493 (rxcp->ip_csum || rxcp->ipv6) && !rxcp->err;
1473} 1494}
1474 1495
1475static struct be_rx_page_info *get_rx_page_info(struct be_rx_obj *rxo) 1496static struct be_rx_page_info *get_rx_page_info(struct be_rx_obj *rxo)
@@ -1612,6 +1633,8 @@ static void be_rx_compl_process(struct be_rx_obj *rxo, struct napi_struct *napi,
1612 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]); 1633 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]);
1613 if (netdev->features & NETIF_F_RXHASH) 1634 if (netdev->features & NETIF_F_RXHASH)
1614 skb_set_hash(skb, rxcp->rss_hash, PKT_HASH_TYPE_L3); 1635 skb_set_hash(skb, rxcp->rss_hash, PKT_HASH_TYPE_L3);
1636
1637 skb->encapsulation = rxcp->tunneled;
1615 skb_mark_napi_id(skb, napi); 1638 skb_mark_napi_id(skb, napi);
1616 1639
1617 if (rxcp->vlanf) 1640 if (rxcp->vlanf)
@@ -1668,6 +1691,8 @@ static void be_rx_compl_process_gro(struct be_rx_obj *rxo,
1668 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]); 1691 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]);
1669 if (adapter->netdev->features & NETIF_F_RXHASH) 1692 if (adapter->netdev->features & NETIF_F_RXHASH)
1670 skb_set_hash(skb, rxcp->rss_hash, PKT_HASH_TYPE_L3); 1693 skb_set_hash(skb, rxcp->rss_hash, PKT_HASH_TYPE_L3);
1694
1695 skb->encapsulation = rxcp->tunneled;
1671 skb_mark_napi_id(skb, napi); 1696 skb_mark_napi_id(skb, napi);
1672 1697
1673 if (rxcp->vlanf) 1698 if (rxcp->vlanf)
@@ -1704,6 +1729,8 @@ static void be_parse_rx_compl_v1(struct be_eth_rx_compl *compl,
1704 compl); 1729 compl);
1705 } 1730 }
1706 rxcp->port = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, port, compl); 1731 rxcp->port = AMAP_GET_BITS(struct amap_eth_rx_compl_v1, port, compl);
1732 rxcp->tunneled =
1733 AMAP_GET_BITS(struct amap_eth_rx_compl_v1, tunneled, compl);
1707} 1734}
1708 1735
1709static void be_parse_rx_compl_v0(struct be_eth_rx_compl *compl, 1736static void be_parse_rx_compl_v0(struct be_eth_rx_compl *compl,
@@ -2834,6 +2861,9 @@ static int be_open(struct net_device *netdev)
2834 2861
2835 netif_tx_start_all_queues(netdev); 2862 netif_tx_start_all_queues(netdev);
2836 be_roce_dev_open(adapter); 2863 be_roce_dev_open(adapter);
2864
2865 if (skyhawk_chip(adapter))
2866 vxlan_get_rx_port(netdev);
2837 return 0; 2867 return 0;
2838err: 2868err:
2839 be_close(adapter->netdev); 2869 be_close(adapter->netdev);
@@ -2989,6 +3019,19 @@ static void be_mac_clear(struct be_adapter *adapter)
2989 } 3019 }
2990} 3020}
2991 3021
3022static void be_disable_vxlan_offloads(struct be_adapter *adapter)
3023{
3024 if (adapter->flags & BE_FLAGS_VXLAN_OFFLOADS)
3025 be_cmd_manage_iface(adapter, adapter->if_handle,
3026 OP_CONVERT_TUNNEL_TO_NORMAL);
3027
3028 if (adapter->vxlan_port)
3029 be_cmd_set_vxlan_port(adapter, 0);
3030
3031 adapter->flags &= ~BE_FLAGS_VXLAN_OFFLOADS;
3032 adapter->vxlan_port = 0;
3033}
3034
2992static int be_clear(struct be_adapter *adapter) 3035static int be_clear(struct be_adapter *adapter)
2993{ 3036{
2994 be_cancel_worker(adapter); 3037 be_cancel_worker(adapter);
@@ -2996,6 +3039,8 @@ static int be_clear(struct be_adapter *adapter)
2996 if (sriov_enabled(adapter)) 3039 if (sriov_enabled(adapter))
2997 be_vf_clear(adapter); 3040 be_vf_clear(adapter);
2998 3041
3042 be_disable_vxlan_offloads(adapter);
3043
2999 /* delete the primary mac along with the uc-mac list */ 3044 /* delete the primary mac along with the uc-mac list */
3000 be_mac_clear(adapter); 3045 be_mac_clear(adapter);
3001 3046
@@ -4120,6 +4165,65 @@ static int be_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
4120 BRIDGE_MODE_VEPA : BRIDGE_MODE_VEB); 4165 BRIDGE_MODE_VEPA : BRIDGE_MODE_VEB);
4121} 4166}
4122 4167
4168static void be_add_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
4169 __be16 port)
4170{
4171 struct be_adapter *adapter = netdev_priv(netdev);
4172 struct device *dev = &adapter->pdev->dev;
4173 int status;
4174
4175 if (lancer_chip(adapter) || BEx_chip(adapter))
4176 return;
4177
4178 if (adapter->flags & BE_FLAGS_VXLAN_OFFLOADS) {
4179 dev_warn(dev, "Cannot add UDP port %d for VxLAN offloads\n",
4180 be16_to_cpu(port));
4181 dev_info(dev,
4182 "Only one UDP port supported for VxLAN offloads\n");
4183 return;
4184 }
4185
4186 status = be_cmd_manage_iface(adapter, adapter->if_handle,
4187 OP_CONVERT_NORMAL_TO_TUNNEL);
4188 if (status) {
4189 dev_warn(dev, "Failed to convert normal interface to tunnel\n");
4190 goto err;
4191 }
4192
4193 status = be_cmd_set_vxlan_port(adapter, port);
4194 if (status) {
4195 dev_warn(dev, "Failed to add VxLAN port\n");
4196 goto err;
4197 }
4198 adapter->flags |= BE_FLAGS_VXLAN_OFFLOADS;
4199 adapter->vxlan_port = port;
4200
4201 dev_info(dev, "Enabled VxLAN offloads for UDP port %d\n",
4202 be16_to_cpu(port));
4203 return;
4204err:
4205 be_disable_vxlan_offloads(adapter);
4206 return;
4207}
4208
4209static void be_del_vxlan_port(struct net_device *netdev, sa_family_t sa_family,
4210 __be16 port)
4211{
4212 struct be_adapter *adapter = netdev_priv(netdev);
4213
4214 if (lancer_chip(adapter) || BEx_chip(adapter))
4215 return;
4216
4217 if (adapter->vxlan_port != port)
4218 return;
4219
4220 be_disable_vxlan_offloads(adapter);
4221
4222 dev_info(&adapter->pdev->dev,
4223 "Disabled VxLAN offloads for UDP port %d\n",
4224 be16_to_cpu(port));
4225}
4226
4123static const struct net_device_ops be_netdev_ops = { 4227static const struct net_device_ops be_netdev_ops = {
4124 .ndo_open = be_open, 4228 .ndo_open = be_open,
4125 .ndo_stop = be_close, 4229 .ndo_stop = be_close,
@@ -4142,14 +4246,22 @@ static const struct net_device_ops be_netdev_ops = {
4142 .ndo_bridge_setlink = be_ndo_bridge_setlink, 4246 .ndo_bridge_setlink = be_ndo_bridge_setlink,
4143 .ndo_bridge_getlink = be_ndo_bridge_getlink, 4247 .ndo_bridge_getlink = be_ndo_bridge_getlink,
4144#ifdef CONFIG_NET_RX_BUSY_POLL 4248#ifdef CONFIG_NET_RX_BUSY_POLL
4145 .ndo_busy_poll = be_busy_poll 4249 .ndo_busy_poll = be_busy_poll,
4146#endif 4250#endif
4251 .ndo_add_vxlan_port = be_add_vxlan_port,
4252 .ndo_del_vxlan_port = be_del_vxlan_port,
4147}; 4253};
4148 4254
4149static void be_netdev_init(struct net_device *netdev) 4255static void be_netdev_init(struct net_device *netdev)
4150{ 4256{
4151 struct be_adapter *adapter = netdev_priv(netdev); 4257 struct be_adapter *adapter = netdev_priv(netdev);
4152 4258
4259 if (skyhawk_chip(adapter)) {
4260 netdev->hw_enc_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
4261 NETIF_F_TSO | NETIF_F_TSO6 |
4262 NETIF_F_GSO_UDP_TUNNEL;
4263 netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL;
4264 }
4153 netdev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 | 4265 netdev->hw_features |= NETIF_F_SG | NETIF_F_TSO | NETIF_F_TSO6 |
4154 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM | 4266 NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_RXCSUM |
4155 NETIF_F_HW_VLAN_CTAG_TX; 4267 NETIF_F_HW_VLAN_CTAG_TX;