Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'implement-udp-tunnel-port-for-txgbe'

Jiawen Wu says:

====================
Implement udp tunnel port for txgbe

v3: https://lore.kernel.org/20250417080328.426554-1-jiawenwu@trustnetic.com
v2: https://lore.kernel.org/20250414091022.383328-1-jiawenwu@trustnetic.com
v1: https://lore.kernel.org/20250410074456.321847-1-jiawenwu@trustnetic.com
====================

Link: https://patch.msgid.link/20250421022956.508018-1-jiawenwu@trustnetic.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+71
+27
drivers/net/ethernet/wangxun/libwx/wx_lib.c
··· 3000 3000 } 3001 3001 EXPORT_SYMBOL(wx_fix_features); 3002 3002 3003 + #define WX_MAX_TUNNEL_HDR_LEN 80 3004 + netdev_features_t wx_features_check(struct sk_buff *skb, 3005 + struct net_device *netdev, 3006 + netdev_features_t features) 3007 + { 3008 + struct wx *wx = netdev_priv(netdev); 3009 + 3010 + if (!skb->encapsulation) 3011 + return features; 3012 + 3013 + if (wx->mac.type == wx_mac_em) 3014 + return features & ~NETIF_F_CSUM_MASK; 3015 + 3016 + if (unlikely(skb_inner_mac_header(skb) - skb_transport_header(skb) > 3017 + WX_MAX_TUNNEL_HDR_LEN)) 3018 + return features & ~NETIF_F_CSUM_MASK; 3019 + 3020 + if (skb->inner_protocol_type == ENCAP_TYPE_ETHER && 3021 + skb->inner_protocol != htons(ETH_P_IP) && 3022 + skb->inner_protocol != htons(ETH_P_IPV6) && 3023 + skb->inner_protocol != htons(ETH_P_TEB)) 3024 + return features & ~(NETIF_F_CSUM_MASK | NETIF_F_GSO_MASK); 3025 + 3026 + return features; 3027 + } 3028 + EXPORT_SYMBOL(wx_features_check); 3029 + 3003 3030 void wx_set_ring(struct wx *wx, u32 new_tx_count, 3004 3031 u32 new_rx_count, struct wx_ring *temp_ring) 3005 3032 {
+3
drivers/net/ethernet/wangxun/libwx/wx_lib.h
··· 33 33 int wx_set_features(struct net_device *netdev, netdev_features_t features); 34 34 netdev_features_t wx_fix_features(struct net_device *netdev, 35 35 netdev_features_t features); 36 + netdev_features_t wx_features_check(struct sk_buff *skb, 37 + struct net_device *netdev, 38 + netdev_features_t features); 36 39 void wx_set_ring(struct wx *wx, u32 new_tx_count, 37 40 u32 new_rx_count, struct wx_ring *temp_ring); 38 41
+1
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
··· 587 587 .ndo_set_rx_mode = wx_set_rx_mode, 588 588 .ndo_set_features = wx_set_features, 589 589 .ndo_fix_features = wx_fix_features, 590 + .ndo_features_check = wx_features_check, 590 591 .ndo_validate_addr = eth_validate_addr, 591 592 .ndo_set_mac_address = wx_set_mac, 592 593 .ndo_get_stats64 = wx_get_stats64,
+37
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
··· 8 8 #include <linux/string.h> 9 9 #include <linux/etherdevice.h> 10 10 #include <linux/phylink.h> 11 + #include <net/udp_tunnel.h> 11 12 #include <net/ip.h> 12 13 #include <linux/if_vlan.h> 13 14 ··· 538 537 txgbe_reset(wx); 539 538 } 540 539 540 + static int txgbe_udp_tunnel_sync(struct net_device *dev, unsigned int table) 541 + { 542 + struct wx *wx = netdev_priv(dev); 543 + struct udp_tunnel_info ti; 544 + 545 + udp_tunnel_nic_get_port(dev, table, 0, &ti); 546 + switch (ti.type) { 547 + case UDP_TUNNEL_TYPE_VXLAN: 548 + wr32(wx, TXGBE_CFG_VXLAN, ntohs(ti.port)); 549 + break; 550 + case UDP_TUNNEL_TYPE_VXLAN_GPE: 551 + wr32(wx, TXGBE_CFG_VXLAN_GPE, ntohs(ti.port)); 552 + break; 553 + case UDP_TUNNEL_TYPE_GENEVE: 554 + wr32(wx, TXGBE_CFG_GENEVE, ntohs(ti.port)); 555 + break; 556 + default: 557 + break; 558 + } 559 + 560 + return 0; 561 + } 562 + 563 + static const struct udp_tunnel_nic_info txgbe_udp_tunnels = { 564 + .sync_table = txgbe_udp_tunnel_sync, 565 + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, 566 + .tables = { 567 + { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, 568 + { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN_GPE, }, 569 + { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, }, 570 + }, 571 + }; 572 + 541 573 static const struct net_device_ops txgbe_netdev_ops = { 542 574 .ndo_open = txgbe_open, 543 575 .ndo_stop = txgbe_close, ··· 579 545 .ndo_set_rx_mode = wx_set_rx_mode, 580 546 .ndo_set_features = wx_set_features, 581 547 .ndo_fix_features = wx_fix_features, 548 + .ndo_features_check = wx_features_check, 582 549 .ndo_validate_addr = eth_validate_addr, 583 550 .ndo_set_mac_address = wx_set_mac, 584 551 .ndo_get_stats64 = wx_get_stats64, ··· 667 632 wx->driver_name = txgbe_driver_name; 668 633 txgbe_set_ethtool_ops(netdev); 669 634 netdev->netdev_ops = &txgbe_netdev_ops; 635 + netdev->udp_tunnel_nic_info = &txgbe_udp_tunnels; 670 636 671 637 /* setup the private structure */ 672 638 err = txgbe_sw_init(wx); ··· 713 677 netdev->features |= NETIF_F_HIGHDMA; 714 678 netdev->hw_features |= NETIF_F_GRO; 715 679 netdev->features |= NETIF_F_GRO; 680 + netdev->features |= NETIF_F_RX_UDP_TUNNEL_PORT; 716 681 717 682 netdev->priv_flags |= IFF_UNICAST_FLT; 718 683 netdev->priv_flags |= IFF_SUPP_NOFCS;
+3
drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
··· 88 88 /* Port cfg registers */ 89 89 #define TXGBE_CFG_PORT_ST 0x14404 90 90 #define TXGBE_CFG_PORT_ST_LINK_UP BIT(0) 91 + #define TXGBE_CFG_VXLAN 0x14410 92 + #define TXGBE_CFG_VXLAN_GPE 0x14414 93 + #define TXGBE_CFG_GENEVE 0x14418 91 94 92 95 /* I2C registers */ 93 96 #define TXGBE_I2C_BASE 0x14900