@@ -479,6 +479,50 @@ static bool xgbe_is_pfc_queue(struct xgbe_prv_data *pdata,
479
479
return false;
480
480
}
481
481
482
+ static void xgbe_set_vxlan_id (struct xgbe_prv_data * pdata )
483
+ {
484
+ /* Program the VXLAN port */
485
+ XGMAC_IOWRITE_BITS (pdata , MAC_TIR , TNID , pdata -> vxlan_port );
486
+
487
+ netif_dbg (pdata , drv , pdata -> netdev , "VXLAN tunnel id set to %hx\n" ,
488
+ pdata -> vxlan_port );
489
+ }
490
+
491
+ static void xgbe_enable_vxlan (struct xgbe_prv_data * pdata )
492
+ {
493
+ if (!pdata -> hw_feat .vxn )
494
+ return ;
495
+
496
+ /* Program the VXLAN port */
497
+ xgbe_set_vxlan_id (pdata );
498
+
499
+ /* Allow for IPv6/UDP zero-checksum VXLAN packets */
500
+ XGMAC_IOWRITE_BITS (pdata , MAC_PFR , VUCC , 1 );
501
+
502
+ /* Enable VXLAN tunneling mode */
503
+ XGMAC_IOWRITE_BITS (pdata , MAC_TCR , VNM , 0 );
504
+ XGMAC_IOWRITE_BITS (pdata , MAC_TCR , VNE , 1 );
505
+
506
+ netif_dbg (pdata , drv , pdata -> netdev , "VXLAN acceleration enabled\n" );
507
+ }
508
+
509
+ static void xgbe_disable_vxlan (struct xgbe_prv_data * pdata )
510
+ {
511
+ if (!pdata -> hw_feat .vxn )
512
+ return ;
513
+
514
+ /* Disable tunneling mode */
515
+ XGMAC_IOWRITE_BITS (pdata , MAC_TCR , VNE , 0 );
516
+
517
+ /* Clear IPv6/UDP zero-checksum VXLAN packets setting */
518
+ XGMAC_IOWRITE_BITS (pdata , MAC_PFR , VUCC , 0 );
519
+
520
+ /* Clear the VXLAN port */
521
+ XGMAC_IOWRITE_BITS (pdata , MAC_TIR , TNID , 0 );
522
+
523
+ netif_dbg (pdata , drv , pdata -> netdev , "VXLAN acceleration disabled\n" );
524
+ }
525
+
482
526
static int xgbe_disable_tx_flow_control (struct xgbe_prv_data * pdata )
483
527
{
484
528
unsigned int max_q_count , q_count ;
@@ -1610,7 +1654,7 @@ static void xgbe_dev_xmit(struct xgbe_channel *channel)
1610
1654
struct xgbe_ring_desc * rdesc ;
1611
1655
struct xgbe_packet_data * packet = & ring -> packet_data ;
1612
1656
unsigned int tx_packets , tx_bytes ;
1613
- unsigned int csum , tso , vlan ;
1657
+ unsigned int csum , tso , vlan , vxlan ;
1614
1658
unsigned int tso_context , vlan_context ;
1615
1659
unsigned int tx_set_ic ;
1616
1660
int start_index = ring -> cur ;
@@ -1628,6 +1672,8 @@ static void xgbe_dev_xmit(struct xgbe_channel *channel)
1628
1672
TSO_ENABLE );
1629
1673
vlan = XGMAC_GET_BITS (packet -> attributes , TX_PACKET_ATTRIBUTES ,
1630
1674
VLAN_CTAG );
1675
+ vxlan = XGMAC_GET_BITS (packet -> attributes , TX_PACKET_ATTRIBUTES ,
1676
+ VXLAN );
1631
1677
1632
1678
if (tso && (packet -> mss != ring -> tx .cur_mss ))
1633
1679
tso_context = 1 ;
@@ -1759,6 +1805,10 @@ static void xgbe_dev_xmit(struct xgbe_channel *channel)
1759
1805
packet -> length );
1760
1806
}
1761
1807
1808
+ if (vxlan )
1809
+ XGMAC_SET_BITS_LE (rdesc -> desc3 , TX_NORMAL_DESC3 , VNP ,
1810
+ TX_NORMAL_DESC3_VXLAN_PACKET );
1811
+
1762
1812
for (i = cur_index - start_index + 1 ; i < packet -> rdesc_count ; i ++ ) {
1763
1813
cur_index ++ ;
1764
1814
rdata = XGBE_GET_DESC_DATA (ring , cur_index );
@@ -1920,9 +1970,27 @@ static int xgbe_dev_read(struct xgbe_channel *channel)
1920
1970
rdata -> rx .len = XGMAC_GET_BITS_LE (rdesc -> desc3 , RX_NORMAL_DESC3 , PL );
1921
1971
1922
1972
/* Set checksum done indicator as appropriate */
1923
- if (netdev -> features & NETIF_F_RXCSUM )
1973
+ if (netdev -> features & NETIF_F_RXCSUM ) {
1924
1974
XGMAC_SET_BITS (packet -> attributes , RX_PACKET_ATTRIBUTES ,
1925
1975
CSUM_DONE , 1 );
1976
+ XGMAC_SET_BITS (packet -> attributes , RX_PACKET_ATTRIBUTES ,
1977
+ TNPCSUM_DONE , 1 );
1978
+ }
1979
+
1980
+ /* Set the tunneled packet indicator */
1981
+ if (XGMAC_GET_BITS_LE (rdesc -> desc2 , RX_NORMAL_DESC2 , TNP )) {
1982
+ XGMAC_SET_BITS (packet -> attributes , RX_PACKET_ATTRIBUTES ,
1983
+ TNP , 1 );
1984
+
1985
+ l34t = XGMAC_GET_BITS_LE (rdesc -> desc3 , RX_NORMAL_DESC3 , L34T );
1986
+ switch (l34t ) {
1987
+ case RX_DESC3_L34T_IPV4_UNKNOWN :
1988
+ case RX_DESC3_L34T_IPV6_UNKNOWN :
1989
+ XGMAC_SET_BITS (packet -> attributes , RX_PACKET_ATTRIBUTES ,
1990
+ TNPCSUM_DONE , 0 );
1991
+ break ;
1992
+ }
1993
+ }
1926
1994
1927
1995
/* Check for errors (only valid in last descriptor) */
1928
1996
err = XGMAC_GET_BITS_LE (rdesc -> desc3 , RX_NORMAL_DESC3 , ES );
@@ -1942,12 +2010,23 @@ static int xgbe_dev_read(struct xgbe_channel *channel)
1942
2010
packet -> vlan_ctag );
1943
2011
}
1944
2012
} else {
1945
- if ((etlt == 0x05 ) || (etlt == 0x06 ))
2013
+ unsigned int tnp = XGMAC_GET_BITS (packet -> attributes ,
2014
+ RX_PACKET_ATTRIBUTES , TNP );
2015
+
2016
+ if ((etlt == 0x05 ) || (etlt == 0x06 )) {
1946
2017
XGMAC_SET_BITS (packet -> attributes , RX_PACKET_ATTRIBUTES ,
1947
2018
CSUM_DONE , 0 );
1948
- else
2019
+ XGMAC_SET_BITS (packet -> attributes , RX_PACKET_ATTRIBUTES ,
2020
+ TNPCSUM_DONE , 0 );
2021
+ } else if (tnp && ((etlt == 0x09 ) || (etlt == 0x0a ))) {
2022
+ XGMAC_SET_BITS (packet -> attributes , RX_PACKET_ATTRIBUTES ,
2023
+ CSUM_DONE , 0 );
2024
+ XGMAC_SET_BITS (packet -> attributes , RX_PACKET_ATTRIBUTES ,
2025
+ TNPCSUM_DONE , 0 );
2026
+ } else {
1949
2027
XGMAC_SET_BITS (packet -> errors , RX_PACKET_ERRORS ,
1950
2028
FRAME , 1 );
2029
+ }
1951
2030
}
1952
2031
1953
2032
pdata -> ext_stats .rxq_packets [channel -> queue_index ]++ ;
@@ -3536,5 +3615,10 @@ void xgbe_init_function_ptrs_dev(struct xgbe_hw_if *hw_if)
3536
3615
hw_if -> disable_ecc_ded = xgbe_disable_ecc_ded ;
3537
3616
hw_if -> disable_ecc_sec = xgbe_disable_ecc_sec ;
3538
3617
3618
+ /* For VXLAN */
3619
+ hw_if -> enable_vxlan = xgbe_enable_vxlan ;
3620
+ hw_if -> disable_vxlan = xgbe_disable_vxlan ;
3621
+ hw_if -> set_vxlan_id = xgbe_set_vxlan_id ;
3622
+
3539
3623
DBGPR ("<--xgbe_init_function_ptrs\n" );
3540
3624
}
0 commit comments