Skip to content

Commit f294516

Browse files
Jiawen Wukuba-moo
authored andcommitted
net: txgbe: Support to set UDP tunnel port
Tunnel types VXLAN/VXLAN_GPE/GENEVE are supported for txgbe devices. The hardware supports to set only one port for each tunnel type. Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com> Link: https://patch.msgid.link/20250421022956.508018-2-jiawenwu@trustnetic.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 84ee6e5 commit f294516

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

drivers/net/ethernet/wangxun/txgbe/txgbe_main.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/string.h>
99
#include <linux/etherdevice.h>
1010
#include <linux/phylink.h>
11+
#include <net/udp_tunnel.h>
1112
#include <net/ip.h>
1213
#include <linux/if_vlan.h>
1314

@@ -537,6 +538,39 @@ void txgbe_do_reset(struct net_device *netdev)
537538
txgbe_reset(wx);
538539
}
539540

541+
static int txgbe_udp_tunnel_sync(struct net_device *dev, unsigned int table)
542+
{
543+
struct wx *wx = netdev_priv(dev);
544+
struct udp_tunnel_info ti;
545+
546+
udp_tunnel_nic_get_port(dev, table, 0, &ti);
547+
switch (ti.type) {
548+
case UDP_TUNNEL_TYPE_VXLAN:
549+
wr32(wx, TXGBE_CFG_VXLAN, ntohs(ti.port));
550+
break;
551+
case UDP_TUNNEL_TYPE_VXLAN_GPE:
552+
wr32(wx, TXGBE_CFG_VXLAN_GPE, ntohs(ti.port));
553+
break;
554+
case UDP_TUNNEL_TYPE_GENEVE:
555+
wr32(wx, TXGBE_CFG_GENEVE, ntohs(ti.port));
556+
break;
557+
default:
558+
break;
559+
}
560+
561+
return 0;
562+
}
563+
564+
static const struct udp_tunnel_nic_info txgbe_udp_tunnels = {
565+
.sync_table = txgbe_udp_tunnel_sync,
566+
.flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY,
567+
.tables = {
568+
{ .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
569+
{ .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN_GPE, },
570+
{ .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, },
571+
},
572+
};
573+
540574
static const struct net_device_ops txgbe_netdev_ops = {
541575
.ndo_open = txgbe_open,
542576
.ndo_stop = txgbe_close,
@@ -632,6 +666,7 @@ static int txgbe_probe(struct pci_dev *pdev,
632666
wx->driver_name = txgbe_driver_name;
633667
txgbe_set_ethtool_ops(netdev);
634668
netdev->netdev_ops = &txgbe_netdev_ops;
669+
netdev->udp_tunnel_nic_info = &txgbe_udp_tunnels;
635670

636671
/* setup the private structure */
637672
err = txgbe_sw_init(wx);
@@ -677,6 +712,7 @@ static int txgbe_probe(struct pci_dev *pdev,
677712
netdev->features |= NETIF_F_HIGHDMA;
678713
netdev->hw_features |= NETIF_F_GRO;
679714
netdev->features |= NETIF_F_GRO;
715+
netdev->features |= NETIF_F_RX_UDP_TUNNEL_PORT;
680716

681717
netdev->priv_flags |= IFF_UNICAST_FLT;
682718
netdev->priv_flags |= IFF_SUPP_NOFCS;

drivers/net/ethernet/wangxun/txgbe/txgbe_type.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
/* Port cfg registers */
8989
#define TXGBE_CFG_PORT_ST 0x14404
9090
#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
9194

9295
/* I2C registers */
9396
#define TXGBE_I2C_BASE 0x14900

0 commit comments

Comments
 (0)