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 'wangxun-netdev-features-support'

Mengyuan Lou says:

====================
Wangxun netdev features support

Implement tx_csum and rx_csum to support hardware checksum offload.
Implement ndo_vlan_rx_add_vid and ndo_vlan_rx_kill_vid.
Implement ndo_set_features.
Enable macros in netdev features which wangxun can support.
====================

Link: https://lore.kernel.org/r/20230530022632.17938-1-mengyuanlou@net-swift.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+1248 -19
+271 -1
drivers/net/ethernet/wangxun/libwx/wx_hw.c
··· 1182 1182 WX_WRITE_FLUSH(wx); 1183 1183 } 1184 1184 1185 + static void wx_vlan_strip_control(struct wx *wx, bool enable) 1186 + { 1187 + int i, j; 1188 + 1189 + for (i = 0; i < wx->num_rx_queues; i++) { 1190 + struct wx_ring *ring = wx->rx_ring[i]; 1191 + 1192 + j = ring->reg_idx; 1193 + wr32m(wx, WX_PX_RR_CFG(j), WX_PX_RR_CFG_VLAN, 1194 + enable ? WX_PX_RR_CFG_VLAN : 0); 1195 + } 1196 + } 1197 + 1185 1198 void wx_set_rx_mode(struct net_device *netdev) 1186 1199 { 1187 1200 struct wx *wx = netdev_priv(netdev); 1201 + netdev_features_t features; 1188 1202 u32 fctrl, vmolr, vlnctrl; 1189 1203 int count; 1204 + 1205 + features = netdev->features; 1190 1206 1191 1207 /* Check for Promiscuous and All Multicast modes */ 1192 1208 fctrl = rd32(wx, WX_PSR_CTL); ··· 1270 1254 wr32(wx, WX_PSR_VLAN_CTL, vlnctrl); 1271 1255 wr32(wx, WX_PSR_CTL, fctrl); 1272 1256 wr32(wx, WX_PSR_VM_L2CTL(0), vmolr); 1257 + 1258 + if ((features & NETIF_F_HW_VLAN_CTAG_RX) && 1259 + (features & NETIF_F_HW_VLAN_STAG_RX)) 1260 + wx_vlan_strip_control(wx, true); 1261 + else 1262 + wx_vlan_strip_control(wx, false); 1263 + 1273 1264 } 1274 1265 EXPORT_SYMBOL(wx_set_rx_mode); 1275 1266 ··· 1485 1462 WX_MAC_TX_CFG_TE, WX_MAC_TX_CFG_TE); 1486 1463 } 1487 1464 1465 + static void wx_restore_vlan(struct wx *wx) 1466 + { 1467 + u16 vid = 1; 1468 + 1469 + wx_vlan_rx_add_vid(wx->netdev, htons(ETH_P_8021Q), 0); 1470 + 1471 + for_each_set_bit_from(vid, wx->active_vlans, VLAN_N_VID) 1472 + wx_vlan_rx_add_vid(wx->netdev, htons(ETH_P_8021Q), vid); 1473 + } 1474 + 1488 1475 /** 1489 1476 * wx_configure_rx - Configure Receive Unit after Reset 1490 1477 * @wx: pointer to private structure ··· 1560 1527 wx_configure_port(wx); 1561 1528 1562 1529 wx_set_rx_mode(wx->netdev); 1563 - 1530 + wx_restore_vlan(wx); 1564 1531 wx_enable_sec_rx_path(wx); 1565 1532 1566 1533 wx_configure_tx(wx); ··· 1759 1726 return 0; 1760 1727 } 1761 1728 EXPORT_SYMBOL(wx_sw_init); 1729 + 1730 + /** 1731 + * wx_find_vlvf_slot - find the vlanid or the first empty slot 1732 + * @wx: pointer to hardware structure 1733 + * @vlan: VLAN id to write to VLAN filter 1734 + * 1735 + * return the VLVF index where this VLAN id should be placed 1736 + * 1737 + **/ 1738 + static int wx_find_vlvf_slot(struct wx *wx, u32 vlan) 1739 + { 1740 + u32 bits = 0, first_empty_slot = 0; 1741 + int regindex; 1742 + 1743 + /* short cut the special case */ 1744 + if (vlan == 0) 1745 + return 0; 1746 + 1747 + /* Search for the vlan id in the VLVF entries. Save off the first empty 1748 + * slot found along the way 1749 + */ 1750 + for (regindex = 1; regindex < WX_PSR_VLAN_SWC_ENTRIES; regindex++) { 1751 + wr32(wx, WX_PSR_VLAN_SWC_IDX, regindex); 1752 + bits = rd32(wx, WX_PSR_VLAN_SWC); 1753 + if (!bits && !(first_empty_slot)) 1754 + first_empty_slot = regindex; 1755 + else if ((bits & 0x0FFF) == vlan) 1756 + break; 1757 + } 1758 + 1759 + if (regindex >= WX_PSR_VLAN_SWC_ENTRIES) { 1760 + if (first_empty_slot) 1761 + regindex = first_empty_slot; 1762 + else 1763 + regindex = -ENOMEM; 1764 + } 1765 + 1766 + return regindex; 1767 + } 1768 + 1769 + /** 1770 + * wx_set_vlvf - Set VLAN Pool Filter 1771 + * @wx: pointer to hardware structure 1772 + * @vlan: VLAN id to write to VLAN filter 1773 + * @vind: VMDq output index that maps queue to VLAN id in VFVFB 1774 + * @vlan_on: boolean flag to turn on/off VLAN in VFVF 1775 + * @vfta_changed: pointer to boolean flag which indicates whether VFTA 1776 + * should be changed 1777 + * 1778 + * Turn on/off specified bit in VLVF table. 1779 + **/ 1780 + static int wx_set_vlvf(struct wx *wx, u32 vlan, u32 vind, bool vlan_on, 1781 + bool *vfta_changed) 1782 + { 1783 + int vlvf_index; 1784 + u32 vt, bits; 1785 + 1786 + /* If VT Mode is set 1787 + * Either vlan_on 1788 + * make sure the vlan is in VLVF 1789 + * set the vind bit in the matching VLVFB 1790 + * Or !vlan_on 1791 + * clear the pool bit and possibly the vind 1792 + */ 1793 + vt = rd32(wx, WX_CFG_PORT_CTL); 1794 + if (!(vt & WX_CFG_PORT_CTL_NUM_VT_MASK)) 1795 + return 0; 1796 + 1797 + vlvf_index = wx_find_vlvf_slot(wx, vlan); 1798 + if (vlvf_index < 0) 1799 + return vlvf_index; 1800 + 1801 + wr32(wx, WX_PSR_VLAN_SWC_IDX, vlvf_index); 1802 + if (vlan_on) { 1803 + /* set the pool bit */ 1804 + if (vind < 32) { 1805 + bits = rd32(wx, WX_PSR_VLAN_SWC_VM_L); 1806 + bits |= (1 << vind); 1807 + wr32(wx, WX_PSR_VLAN_SWC_VM_L, bits); 1808 + } else { 1809 + bits = rd32(wx, WX_PSR_VLAN_SWC_VM_H); 1810 + bits |= (1 << (vind - 32)); 1811 + wr32(wx, WX_PSR_VLAN_SWC_VM_H, bits); 1812 + } 1813 + } else { 1814 + /* clear the pool bit */ 1815 + if (vind < 32) { 1816 + bits = rd32(wx, WX_PSR_VLAN_SWC_VM_L); 1817 + bits &= ~(1 << vind); 1818 + wr32(wx, WX_PSR_VLAN_SWC_VM_L, bits); 1819 + bits |= rd32(wx, WX_PSR_VLAN_SWC_VM_H); 1820 + } else { 1821 + bits = rd32(wx, WX_PSR_VLAN_SWC_VM_H); 1822 + bits &= ~(1 << (vind - 32)); 1823 + wr32(wx, WX_PSR_VLAN_SWC_VM_H, bits); 1824 + bits |= rd32(wx, WX_PSR_VLAN_SWC_VM_L); 1825 + } 1826 + } 1827 + 1828 + if (bits) { 1829 + wr32(wx, WX_PSR_VLAN_SWC, (WX_PSR_VLAN_SWC_VIEN | vlan)); 1830 + if (!vlan_on && vfta_changed) 1831 + *vfta_changed = false; 1832 + } else { 1833 + wr32(wx, WX_PSR_VLAN_SWC, 0); 1834 + } 1835 + 1836 + return 0; 1837 + } 1838 + 1839 + /** 1840 + * wx_set_vfta - Set VLAN filter table 1841 + * @wx: pointer to hardware structure 1842 + * @vlan: VLAN id to write to VLAN filter 1843 + * @vind: VMDq output index that maps queue to VLAN id in VFVFB 1844 + * @vlan_on: boolean flag to turn on/off VLAN in VFVF 1845 + * 1846 + * Turn on/off specified VLAN in the VLAN filter table. 1847 + **/ 1848 + static int wx_set_vfta(struct wx *wx, u32 vlan, u32 vind, bool vlan_on) 1849 + { 1850 + u32 bitindex, vfta, targetbit; 1851 + bool vfta_changed = false; 1852 + int regindex, ret; 1853 + 1854 + /* this is a 2 part operation - first the VFTA, then the 1855 + * VLVF and VLVFB if VT Mode is set 1856 + * We don't write the VFTA until we know the VLVF part succeeded. 1857 + */ 1858 + 1859 + /* Part 1 1860 + * The VFTA is a bitstring made up of 128 32-bit registers 1861 + * that enable the particular VLAN id, much like the MTA: 1862 + * bits[11-5]: which register 1863 + * bits[4-0]: which bit in the register 1864 + */ 1865 + regindex = (vlan >> 5) & 0x7F; 1866 + bitindex = vlan & 0x1F; 1867 + targetbit = (1 << bitindex); 1868 + /* errata 5 */ 1869 + vfta = wx->mac.vft_shadow[regindex]; 1870 + if (vlan_on) { 1871 + if (!(vfta & targetbit)) { 1872 + vfta |= targetbit; 1873 + vfta_changed = true; 1874 + } 1875 + } else { 1876 + if ((vfta & targetbit)) { 1877 + vfta &= ~targetbit; 1878 + vfta_changed = true; 1879 + } 1880 + } 1881 + /* Part 2 1882 + * Call wx_set_vlvf to set VLVFB and VLVF 1883 + */ 1884 + ret = wx_set_vlvf(wx, vlan, vind, vlan_on, &vfta_changed); 1885 + if (ret != 0) 1886 + return ret; 1887 + 1888 + if (vfta_changed) 1889 + wr32(wx, WX_PSR_VLAN_TBL(regindex), vfta); 1890 + wx->mac.vft_shadow[regindex] = vfta; 1891 + 1892 + return 0; 1893 + } 1894 + 1895 + /** 1896 + * wx_clear_vfta - Clear VLAN filter table 1897 + * @wx: pointer to hardware structure 1898 + * 1899 + * Clears the VLAN filer table, and the VMDq index associated with the filter 1900 + **/ 1901 + static void wx_clear_vfta(struct wx *wx) 1902 + { 1903 + u32 offset; 1904 + 1905 + for (offset = 0; offset < wx->mac.vft_size; offset++) { 1906 + wr32(wx, WX_PSR_VLAN_TBL(offset), 0); 1907 + wx->mac.vft_shadow[offset] = 0; 1908 + } 1909 + 1910 + for (offset = 0; offset < WX_PSR_VLAN_SWC_ENTRIES; offset++) { 1911 + wr32(wx, WX_PSR_VLAN_SWC_IDX, offset); 1912 + wr32(wx, WX_PSR_VLAN_SWC, 0); 1913 + wr32(wx, WX_PSR_VLAN_SWC_VM_L, 0); 1914 + wr32(wx, WX_PSR_VLAN_SWC_VM_H, 0); 1915 + } 1916 + } 1917 + 1918 + int wx_vlan_rx_add_vid(struct net_device *netdev, 1919 + __be16 proto, u16 vid) 1920 + { 1921 + struct wx *wx = netdev_priv(netdev); 1922 + 1923 + /* add VID to filter table */ 1924 + wx_set_vfta(wx, vid, VMDQ_P(0), true); 1925 + set_bit(vid, wx->active_vlans); 1926 + 1927 + return 0; 1928 + } 1929 + EXPORT_SYMBOL(wx_vlan_rx_add_vid); 1930 + 1931 + int wx_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid) 1932 + { 1933 + struct wx *wx = netdev_priv(netdev); 1934 + 1935 + /* remove VID from filter table */ 1936 + if (vid) 1937 + wx_set_vfta(wx, vid, VMDQ_P(0), false); 1938 + clear_bit(vid, wx->active_vlans); 1939 + 1940 + return 0; 1941 + } 1942 + EXPORT_SYMBOL(wx_vlan_rx_kill_vid); 1943 + 1944 + /** 1945 + * wx_start_hw - Prepare hardware for Tx/Rx 1946 + * @wx: pointer to hardware structure 1947 + * 1948 + * Starts the hardware using the generic start_hw function 1949 + * and the generation start_hw function. 1950 + * Then performs revision-specific operations, if any. 1951 + **/ 1952 + void wx_start_hw(struct wx *wx) 1953 + { 1954 + int i; 1955 + 1956 + /* Clear the VLAN filter table */ 1957 + wx_clear_vfta(wx); 1958 + WX_WRITE_FLUSH(wx); 1959 + /* Clear the rate limiters */ 1960 + for (i = 0; i < wx->mac.max_tx_queues; i++) { 1961 + wr32(wx, WX_TDM_RP_IDX, i); 1962 + wr32(wx, WX_TDM_RP_RATE, 0); 1963 + } 1964 + } 1965 + EXPORT_SYMBOL(wx_start_hw); 1762 1966 1763 1967 MODULE_LICENSE("GPL");
+3
drivers/net/ethernet/wangxun/libwx/wx_hw.h
··· 26 26 int wx_change_mtu(struct net_device *netdev, int new_mtu); 27 27 void wx_disable_rx_queue(struct wx *wx, struct wx_ring *ring); 28 28 void wx_configure(struct wx *wx); 29 + void wx_start_hw(struct wx *wx); 29 30 int wx_disable_pcie_master(struct wx *wx); 30 31 int wx_stop_adapter(struct wx *wx); 31 32 void wx_reset_misc(struct wx *wx); 32 33 int wx_get_pcie_msix_counts(struct wx *wx, u16 *msix_count, u16 max_msix_count); 33 34 int wx_sw_init(struct wx *wx); 35 + int wx_vlan_rx_add_vid(struct net_device *netdev, __be16 proto, u16 vid); 36 + int wx_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid); 34 37 35 38 #endif /* _WX_HW_H_ */
+727 -7
drivers/net/ethernet/wangxun/libwx/wx_lib.c
··· 2 2 /* Copyright (c) 2019 - 2022 Beijing WangXun Technology Co., Ltd. */ 3 3 4 4 #include <linux/etherdevice.h> 5 + #include <net/ip6_checksum.h> 5 6 #include <net/page_pool.h> 7 + #include <net/inet_ecn.h> 6 8 #include <linux/iopoll.h> 9 + #include <linux/sctp.h> 7 10 #include <linux/pci.h> 11 + #include <net/tcp.h> 12 + #include <net/ip.h> 8 13 9 14 #include "wx_type.h" 10 15 #include "wx_lib.h" 11 16 #include "wx_hw.h" 17 + 18 + /* Lookup table mapping the HW PTYPE to the bit field for decoding */ 19 + static struct wx_dec_ptype wx_ptype_lookup[256] = { 20 + /* L2: mac */ 21 + [0x11] = WX_PTT(L2, NONE, NONE, NONE, NONE, PAY2), 22 + [0x12] = WX_PTT(L2, NONE, NONE, NONE, TS, PAY2), 23 + [0x13] = WX_PTT(L2, NONE, NONE, NONE, NONE, PAY2), 24 + [0x14] = WX_PTT(L2, NONE, NONE, NONE, NONE, PAY2), 25 + [0x15] = WX_PTT(L2, NONE, NONE, NONE, NONE, NONE), 26 + [0x16] = WX_PTT(L2, NONE, NONE, NONE, NONE, PAY2), 27 + [0x17] = WX_PTT(L2, NONE, NONE, NONE, NONE, NONE), 28 + 29 + /* L2: ethertype filter */ 30 + [0x18 ... 0x1F] = WX_PTT(L2, NONE, NONE, NONE, NONE, NONE), 31 + 32 + /* L3: ip non-tunnel */ 33 + [0x21] = WX_PTT(IP, FGV4, NONE, NONE, NONE, PAY3), 34 + [0x22] = WX_PTT(IP, IPV4, NONE, NONE, NONE, PAY3), 35 + [0x23] = WX_PTT(IP, IPV4, NONE, NONE, UDP, PAY4), 36 + [0x24] = WX_PTT(IP, IPV4, NONE, NONE, TCP, PAY4), 37 + [0x25] = WX_PTT(IP, IPV4, NONE, NONE, SCTP, PAY4), 38 + [0x29] = WX_PTT(IP, FGV6, NONE, NONE, NONE, PAY3), 39 + [0x2A] = WX_PTT(IP, IPV6, NONE, NONE, NONE, PAY3), 40 + [0x2B] = WX_PTT(IP, IPV6, NONE, NONE, UDP, PAY3), 41 + [0x2C] = WX_PTT(IP, IPV6, NONE, NONE, TCP, PAY4), 42 + [0x2D] = WX_PTT(IP, IPV6, NONE, NONE, SCTP, PAY4), 43 + 44 + /* L2: fcoe */ 45 + [0x30 ... 0x34] = WX_PTT(FCOE, NONE, NONE, NONE, NONE, PAY3), 46 + [0x38 ... 0x3C] = WX_PTT(FCOE, NONE, NONE, NONE, NONE, PAY3), 47 + 48 + /* IPv4 --> IPv4/IPv6 */ 49 + [0x81] = WX_PTT(IP, IPV4, IPIP, FGV4, NONE, PAY3), 50 + [0x82] = WX_PTT(IP, IPV4, IPIP, IPV4, NONE, PAY3), 51 + [0x83] = WX_PTT(IP, IPV4, IPIP, IPV4, UDP, PAY4), 52 + [0x84] = WX_PTT(IP, IPV4, IPIP, IPV4, TCP, PAY4), 53 + [0x85] = WX_PTT(IP, IPV4, IPIP, IPV4, SCTP, PAY4), 54 + [0x89] = WX_PTT(IP, IPV4, IPIP, FGV6, NONE, PAY3), 55 + [0x8A] = WX_PTT(IP, IPV4, IPIP, IPV6, NONE, PAY3), 56 + [0x8B] = WX_PTT(IP, IPV4, IPIP, IPV6, UDP, PAY4), 57 + [0x8C] = WX_PTT(IP, IPV4, IPIP, IPV6, TCP, PAY4), 58 + [0x8D] = WX_PTT(IP, IPV4, IPIP, IPV6, SCTP, PAY4), 59 + 60 + /* IPv4 --> GRE/NAT --> NONE/IPv4/IPv6 */ 61 + [0x90] = WX_PTT(IP, IPV4, IG, NONE, NONE, PAY3), 62 + [0x91] = WX_PTT(IP, IPV4, IG, FGV4, NONE, PAY3), 63 + [0x92] = WX_PTT(IP, IPV4, IG, IPV4, NONE, PAY3), 64 + [0x93] = WX_PTT(IP, IPV4, IG, IPV4, UDP, PAY4), 65 + [0x94] = WX_PTT(IP, IPV4, IG, IPV4, TCP, PAY4), 66 + [0x95] = WX_PTT(IP, IPV4, IG, IPV4, SCTP, PAY4), 67 + [0x99] = WX_PTT(IP, IPV4, IG, FGV6, NONE, PAY3), 68 + [0x9A] = WX_PTT(IP, IPV4, IG, IPV6, NONE, PAY3), 69 + [0x9B] = WX_PTT(IP, IPV4, IG, IPV6, UDP, PAY4), 70 + [0x9C] = WX_PTT(IP, IPV4, IG, IPV6, TCP, PAY4), 71 + [0x9D] = WX_PTT(IP, IPV4, IG, IPV6, SCTP, PAY4), 72 + 73 + /* IPv4 --> GRE/NAT --> MAC --> NONE/IPv4/IPv6 */ 74 + [0xA0] = WX_PTT(IP, IPV4, IGM, NONE, NONE, PAY3), 75 + [0xA1] = WX_PTT(IP, IPV4, IGM, FGV4, NONE, PAY3), 76 + [0xA2] = WX_PTT(IP, IPV4, IGM, IPV4, NONE, PAY3), 77 + [0xA3] = WX_PTT(IP, IPV4, IGM, IPV4, UDP, PAY4), 78 + [0xA4] = WX_PTT(IP, IPV4, IGM, IPV4, TCP, PAY4), 79 + [0xA5] = WX_PTT(IP, IPV4, IGM, IPV4, SCTP, PAY4), 80 + [0xA9] = WX_PTT(IP, IPV4, IGM, FGV6, NONE, PAY3), 81 + [0xAA] = WX_PTT(IP, IPV4, IGM, IPV6, NONE, PAY3), 82 + [0xAB] = WX_PTT(IP, IPV4, IGM, IPV6, UDP, PAY4), 83 + [0xAC] = WX_PTT(IP, IPV4, IGM, IPV6, TCP, PAY4), 84 + [0xAD] = WX_PTT(IP, IPV4, IGM, IPV6, SCTP, PAY4), 85 + 86 + /* IPv4 --> GRE/NAT --> MAC+VLAN --> NONE/IPv4/IPv6 */ 87 + [0xB0] = WX_PTT(IP, IPV4, IGMV, NONE, NONE, PAY3), 88 + [0xB1] = WX_PTT(IP, IPV4, IGMV, FGV4, NONE, PAY3), 89 + [0xB2] = WX_PTT(IP, IPV4, IGMV, IPV4, NONE, PAY3), 90 + [0xB3] = WX_PTT(IP, IPV4, IGMV, IPV4, UDP, PAY4), 91 + [0xB4] = WX_PTT(IP, IPV4, IGMV, IPV4, TCP, PAY4), 92 + [0xB5] = WX_PTT(IP, IPV4, IGMV, IPV4, SCTP, PAY4), 93 + [0xB9] = WX_PTT(IP, IPV4, IGMV, FGV6, NONE, PAY3), 94 + [0xBA] = WX_PTT(IP, IPV4, IGMV, IPV6, NONE, PAY3), 95 + [0xBB] = WX_PTT(IP, IPV4, IGMV, IPV6, UDP, PAY4), 96 + [0xBC] = WX_PTT(IP, IPV4, IGMV, IPV6, TCP, PAY4), 97 + [0xBD] = WX_PTT(IP, IPV4, IGMV, IPV6, SCTP, PAY4), 98 + 99 + /* IPv6 --> IPv4/IPv6 */ 100 + [0xC1] = WX_PTT(IP, IPV6, IPIP, FGV4, NONE, PAY3), 101 + [0xC2] = WX_PTT(IP, IPV6, IPIP, IPV4, NONE, PAY3), 102 + [0xC3] = WX_PTT(IP, IPV6, IPIP, IPV4, UDP, PAY4), 103 + [0xC4] = WX_PTT(IP, IPV6, IPIP, IPV4, TCP, PAY4), 104 + [0xC5] = WX_PTT(IP, IPV6, IPIP, IPV4, SCTP, PAY4), 105 + [0xC9] = WX_PTT(IP, IPV6, IPIP, FGV6, NONE, PAY3), 106 + [0xCA] = WX_PTT(IP, IPV6, IPIP, IPV6, NONE, PAY3), 107 + [0xCB] = WX_PTT(IP, IPV6, IPIP, IPV6, UDP, PAY4), 108 + [0xCC] = WX_PTT(IP, IPV6, IPIP, IPV6, TCP, PAY4), 109 + [0xCD] = WX_PTT(IP, IPV6, IPIP, IPV6, SCTP, PAY4), 110 + 111 + /* IPv6 --> GRE/NAT -> NONE/IPv4/IPv6 */ 112 + [0xD0] = WX_PTT(IP, IPV6, IG, NONE, NONE, PAY3), 113 + [0xD1] = WX_PTT(IP, IPV6, IG, FGV4, NONE, PAY3), 114 + [0xD2] = WX_PTT(IP, IPV6, IG, IPV4, NONE, PAY3), 115 + [0xD3] = WX_PTT(IP, IPV6, IG, IPV4, UDP, PAY4), 116 + [0xD4] = WX_PTT(IP, IPV6, IG, IPV4, TCP, PAY4), 117 + [0xD5] = WX_PTT(IP, IPV6, IG, IPV4, SCTP, PAY4), 118 + [0xD9] = WX_PTT(IP, IPV6, IG, FGV6, NONE, PAY3), 119 + [0xDA] = WX_PTT(IP, IPV6, IG, IPV6, NONE, PAY3), 120 + [0xDB] = WX_PTT(IP, IPV6, IG, IPV6, UDP, PAY4), 121 + [0xDC] = WX_PTT(IP, IPV6, IG, IPV6, TCP, PAY4), 122 + [0xDD] = WX_PTT(IP, IPV6, IG, IPV6, SCTP, PAY4), 123 + 124 + /* IPv6 --> GRE/NAT -> MAC -> NONE/IPv4/IPv6 */ 125 + [0xE0] = WX_PTT(IP, IPV6, IGM, NONE, NONE, PAY3), 126 + [0xE1] = WX_PTT(IP, IPV6, IGM, FGV4, NONE, PAY3), 127 + [0xE2] = WX_PTT(IP, IPV6, IGM, IPV4, NONE, PAY3), 128 + [0xE3] = WX_PTT(IP, IPV6, IGM, IPV4, UDP, PAY4), 129 + [0xE4] = WX_PTT(IP, IPV6, IGM, IPV4, TCP, PAY4), 130 + [0xE5] = WX_PTT(IP, IPV6, IGM, IPV4, SCTP, PAY4), 131 + [0xE9] = WX_PTT(IP, IPV6, IGM, FGV6, NONE, PAY3), 132 + [0xEA] = WX_PTT(IP, IPV6, IGM, IPV6, NONE, PAY3), 133 + [0xEB] = WX_PTT(IP, IPV6, IGM, IPV6, UDP, PAY4), 134 + [0xEC] = WX_PTT(IP, IPV6, IGM, IPV6, TCP, PAY4), 135 + [0xED] = WX_PTT(IP, IPV6, IGM, IPV6, SCTP, PAY4), 136 + 137 + /* IPv6 --> GRE/NAT -> MAC--> NONE/IPv */ 138 + [0xF0] = WX_PTT(IP, IPV6, IGMV, NONE, NONE, PAY3), 139 + [0xF1] = WX_PTT(IP, IPV6, IGMV, FGV4, NONE, PAY3), 140 + [0xF2] = WX_PTT(IP, IPV6, IGMV, IPV4, NONE, PAY3), 141 + [0xF3] = WX_PTT(IP, IPV6, IGMV, IPV4, UDP, PAY4), 142 + [0xF4] = WX_PTT(IP, IPV6, IGMV, IPV4, TCP, PAY4), 143 + [0xF5] = WX_PTT(IP, IPV6, IGMV, IPV4, SCTP, PAY4), 144 + [0xF9] = WX_PTT(IP, IPV6, IGMV, FGV6, NONE, PAY3), 145 + [0xFA] = WX_PTT(IP, IPV6, IGMV, IPV6, NONE, PAY3), 146 + [0xFB] = WX_PTT(IP, IPV6, IGMV, IPV6, UDP, PAY4), 147 + [0xFC] = WX_PTT(IP, IPV6, IGMV, IPV6, TCP, PAY4), 148 + [0xFD] = WX_PTT(IP, IPV6, IGMV, IPV6, SCTP, PAY4), 149 + }; 150 + 151 + static struct wx_dec_ptype wx_decode_ptype(const u8 ptype) 152 + { 153 + return wx_ptype_lookup[ptype]; 154 + } 12 155 13 156 /* wx_test_staterr - tests bits in Rx descriptor status and error fields */ 14 157 static __le32 wx_test_staterr(union wx_rx_desc *rx_desc, ··· 562 419 return false; 563 420 } 564 421 422 + static void wx_rx_hash(struct wx_ring *ring, 423 + union wx_rx_desc *rx_desc, 424 + struct sk_buff *skb) 425 + { 426 + u16 rss_type; 427 + 428 + if (!(ring->netdev->features & NETIF_F_RXHASH)) 429 + return; 430 + 431 + rss_type = le16_to_cpu(rx_desc->wb.lower.lo_dword.hs_rss.pkt_info) & 432 + WX_RXD_RSSTYPE_MASK; 433 + 434 + if (!rss_type) 435 + return; 436 + 437 + skb_set_hash(skb, le32_to_cpu(rx_desc->wb.lower.hi_dword.rss), 438 + (WX_RSS_L4_TYPES_MASK & (1ul << rss_type)) ? 439 + PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_L3); 440 + } 441 + 442 + /** 443 + * wx_rx_checksum - indicate in skb if hw indicated a good cksum 444 + * @ring: structure containing ring specific data 445 + * @rx_desc: current Rx descriptor being processed 446 + * @skb: skb currently being received and modified 447 + **/ 448 + static void wx_rx_checksum(struct wx_ring *ring, 449 + union wx_rx_desc *rx_desc, 450 + struct sk_buff *skb) 451 + { 452 + struct wx_dec_ptype dptype = wx_decode_ptype(WX_RXD_PKTTYPE(rx_desc)); 453 + 454 + skb_checksum_none_assert(skb); 455 + /* Rx csum disabled */ 456 + if (!(ring->netdev->features & NETIF_F_RXCSUM)) 457 + return; 458 + 459 + /* if IPv4 header checksum error */ 460 + if ((wx_test_staterr(rx_desc, WX_RXD_STAT_IPCS) && 461 + wx_test_staterr(rx_desc, WX_RXD_ERR_IPE)) || 462 + (wx_test_staterr(rx_desc, WX_RXD_STAT_OUTERIPCS) && 463 + wx_test_staterr(rx_desc, WX_RXD_ERR_OUTERIPER))) { 464 + ring->rx_stats.csum_err++; 465 + return; 466 + } 467 + 468 + /* L4 checksum offload flag must set for the below code to work */ 469 + if (!wx_test_staterr(rx_desc, WX_RXD_STAT_L4CS)) 470 + return; 471 + 472 + /* Hardware can't guarantee csum if IPv6 Dest Header found */ 473 + if (dptype.prot != WX_DEC_PTYPE_PROT_SCTP && WX_RXD_IPV6EX(rx_desc)) 474 + return; 475 + 476 + /* if L4 checksum error */ 477 + if (wx_test_staterr(rx_desc, WX_RXD_ERR_TCPE)) { 478 + ring->rx_stats.csum_err++; 479 + return; 480 + } 481 + 482 + /* It must be a TCP or UDP or SCTP packet with a valid checksum */ 483 + skb->ip_summed = CHECKSUM_UNNECESSARY; 484 + 485 + /* If there is an outer header present that might contain a checksum 486 + * we need to bump the checksum level by 1 to reflect the fact that 487 + * we are indicating we validated the inner checksum. 488 + */ 489 + if (dptype.etype >= WX_DEC_PTYPE_ETYPE_IG) 490 + __skb_incr_checksum_unnecessary(skb); 491 + ring->rx_stats.csum_good_cnt++; 492 + } 493 + 494 + static void wx_rx_vlan(struct wx_ring *ring, union wx_rx_desc *rx_desc, 495 + struct sk_buff *skb) 496 + { 497 + u16 ethertype; 498 + u8 idx = 0; 499 + 500 + if ((ring->netdev->features & 501 + (NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX)) && 502 + wx_test_staterr(rx_desc, WX_RXD_STAT_VP)) { 503 + idx = (le16_to_cpu(rx_desc->wb.lower.lo_dword.hs_rss.pkt_info) & 504 + 0x1c0) >> 6; 505 + ethertype = ring->q_vector->wx->tpid[idx]; 506 + __vlan_hwaccel_put_tag(skb, htons(ethertype), 507 + le16_to_cpu(rx_desc->wb.upper.vlan)); 508 + } 509 + } 510 + 511 + /** 512 + * wx_process_skb_fields - Populate skb header fields from Rx descriptor 513 + * @rx_ring: rx descriptor ring packet is being transacted on 514 + * @rx_desc: pointer to the EOP Rx descriptor 515 + * @skb: pointer to current skb being populated 516 + * 517 + * This function checks the ring, descriptor, and packet information in 518 + * order to populate the hash, checksum, protocol, and 519 + * other fields within the skb. 520 + **/ 521 + static void wx_process_skb_fields(struct wx_ring *rx_ring, 522 + union wx_rx_desc *rx_desc, 523 + struct sk_buff *skb) 524 + { 525 + wx_rx_hash(rx_ring, rx_desc, skb); 526 + wx_rx_checksum(rx_ring, rx_desc, skb); 527 + wx_rx_vlan(rx_ring, rx_desc, skb); 528 + skb_record_rx_queue(skb, rx_ring->queue_index); 529 + skb->protocol = eth_type_trans(skb, rx_ring->netdev); 530 + } 531 + 565 532 /** 566 533 * wx_clean_rx_irq - Clean completed descriptors from Rx ring - bounce buf 567 534 * @q_vector: structure containing interrupt and ring information ··· 739 486 /* probably a little skewed due to removing CRC */ 740 487 total_rx_bytes += skb->len; 741 488 742 - skb_record_rx_queue(skb, rx_ring->queue_index); 743 - skb->protocol = eth_type_trans(skb, rx_ring->netdev); 489 + /* populate checksum, timestamp, VLAN, and protocol */ 490 + wx_process_skb_fields(rx_ring, rx_desc, skb); 744 491 napi_gro_receive(&q_vector->napi, skb); 745 492 746 493 /* update budget accounting */ ··· 960 707 return 0; 961 708 } 962 709 710 + static u32 wx_tx_cmd_type(u32 tx_flags) 711 + { 712 + /* set type for advanced descriptor with frame checksum insertion */ 713 + u32 cmd_type = WX_TXD_DTYP_DATA | WX_TXD_IFCS; 714 + 715 + /* set HW vlan bit if vlan is present */ 716 + cmd_type |= WX_SET_FLAG(tx_flags, WX_TX_FLAGS_HW_VLAN, WX_TXD_VLE); 717 + /* set segmentation enable bits for TSO/FSO */ 718 + cmd_type |= WX_SET_FLAG(tx_flags, WX_TX_FLAGS_TSO, WX_TXD_TSE); 719 + /* set timestamp bit if present */ 720 + cmd_type |= WX_SET_FLAG(tx_flags, WX_TX_FLAGS_TSTAMP, WX_TXD_MAC_TSTAMP); 721 + cmd_type |= WX_SET_FLAG(tx_flags, WX_TX_FLAGS_LINKSEC, WX_TXD_LINKSEC); 722 + 723 + return cmd_type; 724 + } 725 + 726 + static void wx_tx_olinfo_status(union wx_tx_desc *tx_desc, 727 + u32 tx_flags, unsigned int paylen) 728 + { 729 + u32 olinfo_status = paylen << WX_TXD_PAYLEN_SHIFT; 730 + 731 + /* enable L4 checksum for TSO and TX checksum offload */ 732 + olinfo_status |= WX_SET_FLAG(tx_flags, WX_TX_FLAGS_CSUM, WX_TXD_L4CS); 733 + /* enable IPv4 checksum for TSO */ 734 + olinfo_status |= WX_SET_FLAG(tx_flags, WX_TX_FLAGS_IPV4, WX_TXD_IIPCS); 735 + /* enable outer IPv4 checksum for TSO */ 736 + olinfo_status |= WX_SET_FLAG(tx_flags, WX_TX_FLAGS_OUTER_IPV4, 737 + WX_TXD_EIPCS); 738 + /* Check Context must be set if Tx switch is enabled, which it 739 + * always is for case where virtual functions are running 740 + */ 741 + olinfo_status |= WX_SET_FLAG(tx_flags, WX_TX_FLAGS_CC, WX_TXD_CC); 742 + olinfo_status |= WX_SET_FLAG(tx_flags, WX_TX_FLAGS_IPSEC, 743 + WX_TXD_IPSEC); 744 + tx_desc->read.olinfo_status = cpu_to_le32(olinfo_status); 745 + } 746 + 963 747 static void wx_tx_map(struct wx_ring *tx_ring, 964 - struct wx_tx_buffer *first) 748 + struct wx_tx_buffer *first, 749 + const u8 hdr_len) 965 750 { 966 751 struct sk_buff *skb = first->skb; 967 752 struct wx_tx_buffer *tx_buffer; 753 + u32 tx_flags = first->tx_flags; 968 754 u16 i = tx_ring->next_to_use; 969 755 unsigned int data_len, size; 970 756 union wx_tx_desc *tx_desc; ··· 1011 719 dma_addr_t dma; 1012 720 u32 cmd_type; 1013 721 1014 - cmd_type = WX_TXD_DTYP_DATA | WX_TXD_IFCS; 722 + cmd_type = wx_tx_cmd_type(tx_flags); 1015 723 tx_desc = WX_TX_DESC(tx_ring, i); 1016 - 1017 - tx_desc->read.olinfo_status = cpu_to_le32(skb->len << WX_TXD_PAYLEN_SHIFT); 724 + wx_tx_olinfo_status(tx_desc, tx_flags, skb->len - hdr_len); 1018 725 1019 726 size = skb_headlen(skb); 1020 727 data_len = skb->data_len; ··· 1129 838 tx_ring->next_to_use = i; 1130 839 } 1131 840 841 + static void wx_tx_ctxtdesc(struct wx_ring *tx_ring, u32 vlan_macip_lens, 842 + u32 fcoe_sof_eof, u32 type_tucmd, u32 mss_l4len_idx) 843 + { 844 + struct wx_tx_context_desc *context_desc; 845 + u16 i = tx_ring->next_to_use; 846 + 847 + context_desc = WX_TX_CTXTDESC(tx_ring, i); 848 + i++; 849 + tx_ring->next_to_use = (i < tx_ring->count) ? i : 0; 850 + 851 + /* set bits to identify this as an advanced context descriptor */ 852 + type_tucmd |= WX_TXD_DTYP_CTXT; 853 + context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens); 854 + context_desc->seqnum_seed = cpu_to_le32(fcoe_sof_eof); 855 + context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd); 856 + context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx); 857 + } 858 + 859 + static void wx_get_ipv6_proto(struct sk_buff *skb, int offset, u8 *nexthdr) 860 + { 861 + struct ipv6hdr *hdr = (struct ipv6hdr *)(skb->data + offset); 862 + 863 + *nexthdr = hdr->nexthdr; 864 + offset += sizeof(struct ipv6hdr); 865 + while (ipv6_ext_hdr(*nexthdr)) { 866 + struct ipv6_opt_hdr _hdr, *hp; 867 + 868 + if (*nexthdr == NEXTHDR_NONE) 869 + return; 870 + hp = skb_header_pointer(skb, offset, sizeof(_hdr), &_hdr); 871 + if (!hp) 872 + return; 873 + if (*nexthdr == NEXTHDR_FRAGMENT) 874 + break; 875 + *nexthdr = hp->nexthdr; 876 + } 877 + } 878 + 879 + union network_header { 880 + struct iphdr *ipv4; 881 + struct ipv6hdr *ipv6; 882 + void *raw; 883 + }; 884 + 885 + static u8 wx_encode_tx_desc_ptype(const struct wx_tx_buffer *first) 886 + { 887 + u8 tun_prot = 0, l4_prot = 0, ptype = 0; 888 + struct sk_buff *skb = first->skb; 889 + 890 + if (skb->encapsulation) { 891 + union network_header hdr; 892 + 893 + switch (first->protocol) { 894 + case htons(ETH_P_IP): 895 + tun_prot = ip_hdr(skb)->protocol; 896 + ptype = WX_PTYPE_TUN_IPV4; 897 + break; 898 + case htons(ETH_P_IPV6): 899 + wx_get_ipv6_proto(skb, skb_network_offset(skb), &tun_prot); 900 + ptype = WX_PTYPE_TUN_IPV6; 901 + break; 902 + default: 903 + return ptype; 904 + } 905 + 906 + if (tun_prot == IPPROTO_IPIP) { 907 + hdr.raw = (void *)inner_ip_hdr(skb); 908 + ptype |= WX_PTYPE_PKT_IPIP; 909 + } else if (tun_prot == IPPROTO_UDP) { 910 + hdr.raw = (void *)inner_ip_hdr(skb); 911 + if (skb->inner_protocol_type != ENCAP_TYPE_ETHER || 912 + skb->inner_protocol != htons(ETH_P_TEB)) { 913 + ptype |= WX_PTYPE_PKT_IG; 914 + } else { 915 + if (((struct ethhdr *)skb_inner_mac_header(skb))->h_proto 916 + == htons(ETH_P_8021Q)) 917 + ptype |= WX_PTYPE_PKT_IGMV; 918 + else 919 + ptype |= WX_PTYPE_PKT_IGM; 920 + } 921 + 922 + } else if (tun_prot == IPPROTO_GRE) { 923 + hdr.raw = (void *)inner_ip_hdr(skb); 924 + if (skb->inner_protocol == htons(ETH_P_IP) || 925 + skb->inner_protocol == htons(ETH_P_IPV6)) { 926 + ptype |= WX_PTYPE_PKT_IG; 927 + } else { 928 + if (((struct ethhdr *)skb_inner_mac_header(skb))->h_proto 929 + == htons(ETH_P_8021Q)) 930 + ptype |= WX_PTYPE_PKT_IGMV; 931 + else 932 + ptype |= WX_PTYPE_PKT_IGM; 933 + } 934 + } else { 935 + return ptype; 936 + } 937 + 938 + switch (hdr.ipv4->version) { 939 + case IPVERSION: 940 + l4_prot = hdr.ipv4->protocol; 941 + break; 942 + case 6: 943 + wx_get_ipv6_proto(skb, skb_inner_network_offset(skb), &l4_prot); 944 + ptype |= WX_PTYPE_PKT_IPV6; 945 + break; 946 + default: 947 + return ptype; 948 + } 949 + } else { 950 + switch (first->protocol) { 951 + case htons(ETH_P_IP): 952 + l4_prot = ip_hdr(skb)->protocol; 953 + ptype = WX_PTYPE_PKT_IP; 954 + break; 955 + case htons(ETH_P_IPV6): 956 + wx_get_ipv6_proto(skb, skb_network_offset(skb), &l4_prot); 957 + ptype = WX_PTYPE_PKT_IP | WX_PTYPE_PKT_IPV6; 958 + break; 959 + default: 960 + return WX_PTYPE_PKT_MAC | WX_PTYPE_TYP_MAC; 961 + } 962 + } 963 + switch (l4_prot) { 964 + case IPPROTO_TCP: 965 + ptype |= WX_PTYPE_TYP_TCP; 966 + break; 967 + case IPPROTO_UDP: 968 + ptype |= WX_PTYPE_TYP_UDP; 969 + break; 970 + case IPPROTO_SCTP: 971 + ptype |= WX_PTYPE_TYP_SCTP; 972 + break; 973 + default: 974 + ptype |= WX_PTYPE_TYP_IP; 975 + break; 976 + } 977 + 978 + return ptype; 979 + } 980 + 981 + static int wx_tso(struct wx_ring *tx_ring, struct wx_tx_buffer *first, 982 + u8 *hdr_len, u8 ptype) 983 + { 984 + u32 vlan_macip_lens, type_tucmd, mss_l4len_idx; 985 + struct net_device *netdev = tx_ring->netdev; 986 + u32 l4len, tunhdr_eiplen_tunlen = 0; 987 + struct sk_buff *skb = first->skb; 988 + bool enc = skb->encapsulation; 989 + struct ipv6hdr *ipv6h; 990 + struct tcphdr *tcph; 991 + struct iphdr *iph; 992 + u8 tun_prot = 0; 993 + int err; 994 + 995 + if (skb->ip_summed != CHECKSUM_PARTIAL) 996 + return 0; 997 + 998 + if (!skb_is_gso(skb)) 999 + return 0; 1000 + 1001 + err = skb_cow_head(skb, 0); 1002 + if (err < 0) 1003 + return err; 1004 + 1005 + /* indicates the inner headers in the skbuff are valid. */ 1006 + iph = enc ? inner_ip_hdr(skb) : ip_hdr(skb); 1007 + if (iph->version == 4) { 1008 + tcph = enc ? inner_tcp_hdr(skb) : tcp_hdr(skb); 1009 + iph->tot_len = 0; 1010 + iph->check = 0; 1011 + tcph->check = ~csum_tcpudp_magic(iph->saddr, 1012 + iph->daddr, 0, 1013 + IPPROTO_TCP, 0); 1014 + first->tx_flags |= WX_TX_FLAGS_TSO | 1015 + WX_TX_FLAGS_CSUM | 1016 + WX_TX_FLAGS_IPV4 | 1017 + WX_TX_FLAGS_CC; 1018 + } else if (iph->version == 6 && skb_is_gso_v6(skb)) { 1019 + ipv6h = enc ? inner_ipv6_hdr(skb) : ipv6_hdr(skb); 1020 + tcph = enc ? inner_tcp_hdr(skb) : tcp_hdr(skb); 1021 + ipv6h->payload_len = 0; 1022 + tcph->check = ~csum_ipv6_magic(&ipv6h->saddr, 1023 + &ipv6h->daddr, 0, 1024 + IPPROTO_TCP, 0); 1025 + first->tx_flags |= WX_TX_FLAGS_TSO | 1026 + WX_TX_FLAGS_CSUM | 1027 + WX_TX_FLAGS_CC; 1028 + } 1029 + 1030 + /* compute header lengths */ 1031 + l4len = enc ? inner_tcp_hdrlen(skb) : tcp_hdrlen(skb); 1032 + *hdr_len = enc ? (skb_inner_transport_header(skb) - skb->data) : 1033 + skb_transport_offset(skb); 1034 + *hdr_len += l4len; 1035 + 1036 + /* update gso size and bytecount with header size */ 1037 + first->gso_segs = skb_shinfo(skb)->gso_segs; 1038 + first->bytecount += (first->gso_segs - 1) * *hdr_len; 1039 + 1040 + /* mss_l4len_id: use 0 as index for TSO */ 1041 + mss_l4len_idx = l4len << WX_TXD_L4LEN_SHIFT; 1042 + mss_l4len_idx |= skb_shinfo(skb)->gso_size << WX_TXD_MSS_SHIFT; 1043 + 1044 + /* vlan_macip_lens: HEADLEN, MACLEN, VLAN tag */ 1045 + if (enc) { 1046 + switch (first->protocol) { 1047 + case htons(ETH_P_IP): 1048 + tun_prot = ip_hdr(skb)->protocol; 1049 + first->tx_flags |= WX_TX_FLAGS_OUTER_IPV4; 1050 + break; 1051 + case htons(ETH_P_IPV6): 1052 + tun_prot = ipv6_hdr(skb)->nexthdr; 1053 + break; 1054 + default: 1055 + break; 1056 + } 1057 + switch (tun_prot) { 1058 + case IPPROTO_UDP: 1059 + tunhdr_eiplen_tunlen = WX_TXD_TUNNEL_UDP; 1060 + tunhdr_eiplen_tunlen |= ((skb_network_header_len(skb) >> 2) << 1061 + WX_TXD_OUTER_IPLEN_SHIFT) | 1062 + (((skb_inner_mac_header(skb) - 1063 + skb_transport_header(skb)) >> 1) << 1064 + WX_TXD_TUNNEL_LEN_SHIFT); 1065 + break; 1066 + case IPPROTO_GRE: 1067 + tunhdr_eiplen_tunlen = WX_TXD_TUNNEL_GRE; 1068 + tunhdr_eiplen_tunlen |= ((skb_network_header_len(skb) >> 2) << 1069 + WX_TXD_OUTER_IPLEN_SHIFT) | 1070 + (((skb_inner_mac_header(skb) - 1071 + skb_transport_header(skb)) >> 1) << 1072 + WX_TXD_TUNNEL_LEN_SHIFT); 1073 + break; 1074 + case IPPROTO_IPIP: 1075 + tunhdr_eiplen_tunlen = (((char *)inner_ip_hdr(skb) - 1076 + (char *)ip_hdr(skb)) >> 2) << 1077 + WX_TXD_OUTER_IPLEN_SHIFT; 1078 + break; 1079 + default: 1080 + break; 1081 + } 1082 + vlan_macip_lens = skb_inner_network_header_len(skb) >> 1; 1083 + } else { 1084 + vlan_macip_lens = skb_network_header_len(skb) >> 1; 1085 + } 1086 + 1087 + vlan_macip_lens |= skb_network_offset(skb) << WX_TXD_MACLEN_SHIFT; 1088 + vlan_macip_lens |= first->tx_flags & WX_TX_FLAGS_VLAN_MASK; 1089 + 1090 + type_tucmd = ptype << 24; 1091 + if (skb->vlan_proto == htons(ETH_P_8021AD) && 1092 + netdev->features & NETIF_F_HW_VLAN_STAG_TX) 1093 + type_tucmd |= WX_SET_FLAG(first->tx_flags, 1094 + WX_TX_FLAGS_HW_VLAN, 1095 + 0x1 << WX_TXD_TAG_TPID_SEL_SHIFT); 1096 + wx_tx_ctxtdesc(tx_ring, vlan_macip_lens, tunhdr_eiplen_tunlen, 1097 + type_tucmd, mss_l4len_idx); 1098 + 1099 + return 1; 1100 + } 1101 + 1102 + static void wx_tx_csum(struct wx_ring *tx_ring, struct wx_tx_buffer *first, 1103 + u8 ptype) 1104 + { 1105 + u32 tunhdr_eiplen_tunlen = 0, vlan_macip_lens = 0; 1106 + struct net_device *netdev = tx_ring->netdev; 1107 + u32 mss_l4len_idx = 0, type_tucmd; 1108 + struct sk_buff *skb = first->skb; 1109 + u8 tun_prot = 0; 1110 + 1111 + if (skb->ip_summed != CHECKSUM_PARTIAL) { 1112 + if (!(first->tx_flags & WX_TX_FLAGS_HW_VLAN) && 1113 + !(first->tx_flags & WX_TX_FLAGS_CC)) 1114 + return; 1115 + vlan_macip_lens = skb_network_offset(skb) << 1116 + WX_TXD_MACLEN_SHIFT; 1117 + } else { 1118 + u8 l4_prot = 0; 1119 + union { 1120 + struct iphdr *ipv4; 1121 + struct ipv6hdr *ipv6; 1122 + u8 *raw; 1123 + } network_hdr; 1124 + union { 1125 + struct tcphdr *tcphdr; 1126 + u8 *raw; 1127 + } transport_hdr; 1128 + 1129 + if (skb->encapsulation) { 1130 + network_hdr.raw = skb_inner_network_header(skb); 1131 + transport_hdr.raw = skb_inner_transport_header(skb); 1132 + vlan_macip_lens = skb_network_offset(skb) << 1133 + WX_TXD_MACLEN_SHIFT; 1134 + switch (first->protocol) { 1135 + case htons(ETH_P_IP): 1136 + tun_prot = ip_hdr(skb)->protocol; 1137 + break; 1138 + case htons(ETH_P_IPV6): 1139 + tun_prot = ipv6_hdr(skb)->nexthdr; 1140 + break; 1141 + default: 1142 + return; 1143 + } 1144 + switch (tun_prot) { 1145 + case IPPROTO_UDP: 1146 + tunhdr_eiplen_tunlen = WX_TXD_TUNNEL_UDP; 1147 + tunhdr_eiplen_tunlen |= 1148 + ((skb_network_header_len(skb) >> 2) << 1149 + WX_TXD_OUTER_IPLEN_SHIFT) | 1150 + (((skb_inner_mac_header(skb) - 1151 + skb_transport_header(skb)) >> 1) << 1152 + WX_TXD_TUNNEL_LEN_SHIFT); 1153 + break; 1154 + case IPPROTO_GRE: 1155 + tunhdr_eiplen_tunlen = WX_TXD_TUNNEL_GRE; 1156 + tunhdr_eiplen_tunlen |= ((skb_network_header_len(skb) >> 2) << 1157 + WX_TXD_OUTER_IPLEN_SHIFT) | 1158 + (((skb_inner_mac_header(skb) - 1159 + skb_transport_header(skb)) >> 1) << 1160 + WX_TXD_TUNNEL_LEN_SHIFT); 1161 + break; 1162 + case IPPROTO_IPIP: 1163 + tunhdr_eiplen_tunlen = (((char *)inner_ip_hdr(skb) - 1164 + (char *)ip_hdr(skb)) >> 2) << 1165 + WX_TXD_OUTER_IPLEN_SHIFT; 1166 + break; 1167 + default: 1168 + break; 1169 + } 1170 + 1171 + } else { 1172 + network_hdr.raw = skb_network_header(skb); 1173 + transport_hdr.raw = skb_transport_header(skb); 1174 + vlan_macip_lens = skb_network_offset(skb) << 1175 + WX_TXD_MACLEN_SHIFT; 1176 + } 1177 + 1178 + switch (network_hdr.ipv4->version) { 1179 + case IPVERSION: 1180 + vlan_macip_lens |= (transport_hdr.raw - network_hdr.raw) >> 1; 1181 + l4_prot = network_hdr.ipv4->protocol; 1182 + break; 1183 + case 6: 1184 + vlan_macip_lens |= (transport_hdr.raw - network_hdr.raw) >> 1; 1185 + l4_prot = network_hdr.ipv6->nexthdr; 1186 + break; 1187 + default: 1188 + break; 1189 + } 1190 + 1191 + switch (l4_prot) { 1192 + case IPPROTO_TCP: 1193 + mss_l4len_idx = (transport_hdr.tcphdr->doff * 4) << 1194 + WX_TXD_L4LEN_SHIFT; 1195 + break; 1196 + case IPPROTO_SCTP: 1197 + mss_l4len_idx = sizeof(struct sctphdr) << 1198 + WX_TXD_L4LEN_SHIFT; 1199 + break; 1200 + case IPPROTO_UDP: 1201 + mss_l4len_idx = sizeof(struct udphdr) << 1202 + WX_TXD_L4LEN_SHIFT; 1203 + break; 1204 + default: 1205 + break; 1206 + } 1207 + 1208 + /* update TX checksum flag */ 1209 + first->tx_flags |= WX_TX_FLAGS_CSUM; 1210 + } 1211 + first->tx_flags |= WX_TX_FLAGS_CC; 1212 + /* vlan_macip_lens: MACLEN, VLAN tag */ 1213 + vlan_macip_lens |= first->tx_flags & WX_TX_FLAGS_VLAN_MASK; 1214 + 1215 + type_tucmd = ptype << 24; 1216 + if (skb->vlan_proto == htons(ETH_P_8021AD) && 1217 + netdev->features & NETIF_F_HW_VLAN_STAG_TX) 1218 + type_tucmd |= WX_SET_FLAG(first->tx_flags, 1219 + WX_TX_FLAGS_HW_VLAN, 1220 + 0x1 << WX_TXD_TAG_TPID_SEL_SHIFT); 1221 + wx_tx_ctxtdesc(tx_ring, vlan_macip_lens, tunhdr_eiplen_tunlen, 1222 + type_tucmd, mss_l4len_idx); 1223 + } 1224 + 1132 1225 static netdev_tx_t wx_xmit_frame_ring(struct sk_buff *skb, 1133 1226 struct wx_ring *tx_ring) 1134 1227 { 1135 1228 u16 count = TXD_USE_COUNT(skb_headlen(skb)); 1136 1229 struct wx_tx_buffer *first; 1230 + u8 hdr_len = 0, ptype; 1137 1231 unsigned short f; 1232 + u32 tx_flags = 0; 1233 + int tso; 1138 1234 1139 1235 /* need: 1 descriptor per page * PAGE_SIZE/WX_MAX_DATA_PER_TXD, 1140 1236 * + 1 desc for skb_headlen/WX_MAX_DATA_PER_TXD, ··· 1542 864 first->bytecount = skb->len; 1543 865 first->gso_segs = 1; 1544 866 1545 - wx_tx_map(tx_ring, first); 867 + /* if we have a HW VLAN tag being added default to the HW one */ 868 + if (skb_vlan_tag_present(skb)) { 869 + tx_flags |= skb_vlan_tag_get(skb) << WX_TX_FLAGS_VLAN_SHIFT; 870 + tx_flags |= WX_TX_FLAGS_HW_VLAN; 871 + } 872 + 873 + /* record initial flags and protocol */ 874 + first->tx_flags = tx_flags; 875 + first->protocol = vlan_get_protocol(skb); 876 + 877 + ptype = wx_encode_tx_desc_ptype(first); 878 + 879 + tso = wx_tso(tx_ring, first, &hdr_len, ptype); 880 + if (tso < 0) 881 + goto out_drop; 882 + else if (!tso) 883 + wx_tx_csum(tx_ring, first, ptype); 884 + wx_tx_map(tx_ring, first, hdr_len); 885 + 886 + return NETDEV_TX_OK; 887 + out_drop: 888 + dev_kfree_skb_any(first->skb); 889 + first->skb = NULL; 1546 890 1547 891 return NETDEV_TX_OK; 1548 892 } ··· 2703 2003 rcu_read_unlock(); 2704 2004 } 2705 2005 EXPORT_SYMBOL(wx_get_stats64); 2006 + 2007 + int wx_set_features(struct net_device *netdev, netdev_features_t features) 2008 + { 2009 + netdev_features_t changed = netdev->features ^ features; 2010 + struct wx *wx = netdev_priv(netdev); 2011 + 2012 + if (changed & NETIF_F_RXHASH) 2013 + wr32m(wx, WX_RDB_RA_CTL, WX_RDB_RA_CTL_RSS_EN, 2014 + WX_RDB_RA_CTL_RSS_EN); 2015 + else 2016 + wr32m(wx, WX_RDB_RA_CTL, WX_RDB_RA_CTL_RSS_EN, 0); 2017 + 2018 + if (changed & 2019 + (NETIF_F_HW_VLAN_CTAG_RX | 2020 + NETIF_F_HW_VLAN_STAG_RX)) 2021 + wx_set_rx_mode(netdev); 2022 + 2023 + return 1; 2024 + } 2025 + EXPORT_SYMBOL(wx_set_features); 2706 2026 2707 2027 MODULE_LICENSE("GPL");
+1
drivers/net/ethernet/wangxun/libwx/wx_lib.h
··· 28 28 int wx_setup_resources(struct wx *wx); 29 29 void wx_get_stats64(struct net_device *netdev, 30 30 struct rtnl_link_stats64 *stats); 31 + int wx_set_features(struct net_device *netdev, netdev_features_t features); 31 32 32 33 #endif /* _NGBE_LIB_H_ */
+208 -4
drivers/net/ethernet/wangxun/libwx/wx_type.h
··· 6 6 7 7 #include <linux/bitfield.h> 8 8 #include <linux/netdevice.h> 9 + #include <linux/if_vlan.h> 10 + #include <net/ip.h> 9 11 10 12 #define WX_NCSI_SUP 0x8000 11 13 #define WX_NCSI_MASK 0x8000 ··· 66 64 #define WX_CFG_PORT_CTL_QINQ BIT(2) 67 65 #define WX_CFG_PORT_CTL_D_VLAN BIT(0) /* double vlan*/ 68 66 #define WX_CFG_TAG_TPID(_i) (0x14430 + ((_i) * 4)) 67 + #define WX_CFG_PORT_CTL_NUM_VT_MASK GENMASK(13, 12) /* number of TVs */ 68 + 69 69 70 70 /* GPIO Registers */ 71 71 #define WX_GPIO_DR 0x14800 ··· 91 87 /* TDM CTL BIT */ 92 88 #define WX_TDM_CTL_TE BIT(0) /* Transmit Enable */ 93 89 #define WX_TDM_PB_THRE(_i) (0x18020 + ((_i) * 4)) 90 + #define WX_TDM_RP_IDX 0x1820C 91 + #define WX_TDM_RP_RATE 0x18404 94 92 95 93 /***************************** RDB registers *********************************/ 96 94 /* receive packet buffer */ ··· 111 105 #define WX_RDB_PL_CFG_L2HDR BIT(3) 112 106 #define WX_RDB_PL_CFG_TUN_TUNHDR BIT(4) 113 107 #define WX_RDB_PL_CFG_TUN_OUTL2HDR BIT(5) 108 + #define WX_RDB_RA_CTL 0x194F4 109 + #define WX_RDB_RA_CTL_RSS_EN BIT(2) /* RSS Enable */ 114 110 115 111 /******************************* PSR Registers *******************************/ 116 112 /* psr control */ ··· 158 150 #define WX_PSR_LAN_FLEX_DW_H(_i) (0x15C04 + ((_i) * 16)) 159 151 #define WX_PSR_LAN_FLEX_MSK(_i) (0x15C08 + ((_i) * 16)) 160 152 153 + /* vlan tbl */ 154 + #define WX_PSR_VLAN_TBL(_i) (0x16000 + ((_i) * 4)) 155 + 161 156 /* mac switcher */ 162 157 #define WX_PSR_MAC_SWC_AD_L 0x16200 163 158 #define WX_PSR_MAC_SWC_AD_H 0x16204 ··· 171 160 #define WX_PSR_MAC_SWC_VM_H 0x1620C 172 161 #define WX_PSR_MAC_SWC_IDX 0x16210 173 162 #define WX_CLEAR_VMDQ_ALL 0xFFFFFFFFU 163 + 164 + /* vlan switch */ 165 + #define WX_PSR_VLAN_SWC 0x16220 166 + #define WX_PSR_VLAN_SWC_VM_L 0x16224 167 + #define WX_PSR_VLAN_SWC_VM_H 0x16228 168 + #define WX_PSR_VLAN_SWC_IDX 0x16230 /* 64 vlan entries */ 169 + /* VLAN pool filtering masks */ 170 + #define WX_PSR_VLAN_SWC_VIEN BIT(31) /* filter is valid */ 171 + #define WX_PSR_VLAN_SWC_ENTRIES 64 174 172 175 173 /********************************* RSEC **************************************/ 176 174 /* general rsec */ ··· 275 255 #define WX_PX_RR_RP(_i) (0x0100C + ((_i) * 0x40)) 276 256 #define WX_PX_RR_CFG(_i) (0x01010 + ((_i) * 0x40)) 277 257 /* PX_RR_CFG bit definitions */ 258 + #define WX_PX_RR_CFG_VLAN BIT(31) 278 259 #define WX_PX_RR_CFG_SPLIT_MODE BIT(26) 279 260 #define WX_PX_RR_CFG_RR_THER_SHIFT 16 280 261 #define WX_PX_RR_CFG_RR_HDR_SZ GENMASK(15, 12) ··· 317 296 #define WX_MAX_TXD 8192 318 297 319 298 #define WX_MAX_JUMBO_FRAME_SIZE 9432 /* max payload 9414 */ 299 + #define VMDQ_P(p) p 320 300 321 301 /* Supported Rx Buffer Sizes */ 322 302 #define WX_RXBUFFER_256 256 /* Used for skb receive header */ ··· 337 315 #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), WX_MAX_DATA_PER_TXD) 338 316 #define DESC_NEEDED (MAX_SKB_FRAGS + 4) 339 317 340 - /* Ether Types */ 341 - #define WX_ETH_P_CNM 0x22E7 342 - 343 318 #define WX_CFG_PORT_ST 0x14404 344 319 345 320 /******************* Receive Descriptor bit definitions **********************/ 346 321 #define WX_RXD_STAT_DD BIT(0) /* Done */ 347 322 #define WX_RXD_STAT_EOP BIT(1) /* End of Packet */ 323 + #define WX_RXD_STAT_VP BIT(5) /* IEEE VLAN Pkt */ 324 + #define WX_RXD_STAT_L4CS BIT(7) /* L4 xsum calculated */ 325 + #define WX_RXD_STAT_IPCS BIT(8) /* IP xsum calculated */ 326 + #define WX_RXD_STAT_OUTERIPCS BIT(10) /* Cloud IP xsum calculated*/ 348 327 328 + #define WX_RXD_ERR_OUTERIPER BIT(26) /* CRC IP Header error */ 349 329 #define WX_RXD_ERR_RXE BIT(29) /* Any MAC Error */ 330 + #define WX_RXD_ERR_TCPE BIT(30) /* TCP/UDP Checksum Error */ 331 + #define WX_RXD_ERR_IPE BIT(31) /* IP Checksum Error */ 350 332 333 + /* RSS Hash results */ 334 + #define WX_RXD_RSSTYPE_MASK GENMASK(3, 0) 335 + #define WX_RXD_RSSTYPE_IPV4_TCP 0x00000001U 336 + #define WX_RXD_RSSTYPE_IPV6_TCP 0x00000003U 337 + #define WX_RXD_RSSTYPE_IPV4_SCTP 0x00000004U 338 + #define WX_RXD_RSSTYPE_IPV6_SCTP 0x00000006U 339 + #define WX_RXD_RSSTYPE_IPV4_UDP 0x00000007U 340 + #define WX_RXD_RSSTYPE_IPV6_UDP 0x00000008U 341 + 342 + #define WX_RSS_L4_TYPES_MASK \ 343 + ((1ul << WX_RXD_RSSTYPE_IPV4_TCP) | \ 344 + (1ul << WX_RXD_RSSTYPE_IPV4_UDP) | \ 345 + (1ul << WX_RXD_RSSTYPE_IPV4_SCTP) | \ 346 + (1ul << WX_RXD_RSSTYPE_IPV6_TCP) | \ 347 + (1ul << WX_RXD_RSSTYPE_IPV6_UDP) | \ 348 + (1ul << WX_RXD_RSSTYPE_IPV6_SCTP)) 349 + /* TUN */ 350 + #define WX_PTYPE_TUN_IPV4 0x80 351 + #define WX_PTYPE_TUN_IPV6 0xC0 352 + 353 + /* PKT for TUN */ 354 + #define WX_PTYPE_PKT_IPIP 0x00 /* IP+IP */ 355 + #define WX_PTYPE_PKT_IG 0x10 /* IP+GRE */ 356 + #define WX_PTYPE_PKT_IGM 0x20 /* IP+GRE+MAC */ 357 + #define WX_PTYPE_PKT_IGMV 0x30 /* IP+GRE+MAC+VLAN */ 358 + /* PKT for !TUN */ 359 + #define WX_PTYPE_PKT_MAC 0x10 360 + #define WX_PTYPE_PKT_IP 0x20 361 + 362 + /* TYP for PKT=mac */ 363 + #define WX_PTYPE_TYP_MAC 0x01 364 + /* TYP for PKT=ip */ 365 + #define WX_PTYPE_PKT_IPV6 0x08 366 + #define WX_PTYPE_TYP_IPFRAG 0x01 367 + #define WX_PTYPE_TYP_IP 0x02 368 + #define WX_PTYPE_TYP_UDP 0x03 369 + #define WX_PTYPE_TYP_TCP 0x04 370 + #define WX_PTYPE_TYP_SCTP 0x05 371 + 372 + #define WX_RXD_PKTTYPE(_rxd) \ 373 + ((le32_to_cpu((_rxd)->wb.lower.lo_dword.data) >> 9) & 0xFF) 374 + #define WX_RXD_IPV6EX(_rxd) \ 375 + ((le32_to_cpu((_rxd)->wb.lower.lo_dword.data) >> 6) & 0x1) 351 376 /*********************** Transmit Descriptor Config Masks ****************/ 352 377 #define WX_TXD_STAT_DD BIT(0) /* Descriptor Done */ 353 378 #define WX_TXD_DTYP_DATA 0 /* Adv Data Descriptor */ ··· 402 333 #define WX_TXD_EOP BIT(24) /* End of Packet */ 403 334 #define WX_TXD_IFCS BIT(25) /* Insert FCS */ 404 335 #define WX_TXD_RS BIT(27) /* Report Status */ 336 + 337 + /*********************** Adv Transmit Descriptor Config Masks ****************/ 338 + #define WX_TXD_MAC_TSTAMP BIT(19) /* IEEE1588 time stamp */ 339 + #define WX_TXD_DTYP_CTXT BIT(20) /* Adv Context Desc */ 340 + #define WX_TXD_LINKSEC BIT(26) /* enable linksec */ 341 + #define WX_TXD_VLE BIT(30) /* VLAN pkt enable */ 342 + #define WX_TXD_TSE BIT(31) /* TCP Seg enable */ 343 + #define WX_TXD_CC BIT(7) /* Check Context */ 344 + #define WX_TXD_IPSEC BIT(8) /* enable ipsec esp */ 345 + #define WX_TXD_L4CS BIT(9) 346 + #define WX_TXD_IIPCS BIT(10) 347 + #define WX_TXD_EIPCS BIT(11) 348 + #define WX_TXD_PAYLEN_SHIFT 13 /* Adv desc PAYLEN shift */ 349 + #define WX_TXD_MACLEN_SHIFT 9 /* Adv ctxt desc mac len shift */ 350 + #define WX_TXD_TAG_TPID_SEL_SHIFT 11 351 + 352 + #define WX_TXD_L4LEN_SHIFT 8 /* Adv ctxt L4LEN shift */ 353 + #define WX_TXD_MSS_SHIFT 16 /* Adv ctxt MSS shift */ 354 + 355 + #define WX_TXD_OUTER_IPLEN_SHIFT 12 /* Adv ctxt OUTERIPLEN shift */ 356 + #define WX_TXD_TUNNEL_LEN_SHIFT 21 /* Adv ctxt TUNNELLEN shift */ 357 + #define WX_TXD_TUNNEL_TYPE_SHIFT 11 /* Adv Tx Desc Tunnel Type shift */ 358 + #define WX_TXD_TUNNEL_UDP FIELD_PREP(BIT(WX_TXD_TUNNEL_TYPE_SHIFT), 0) 359 + #define WX_TXD_TUNNEL_GRE FIELD_PREP(BIT(WX_TXD_TUNNEL_TYPE_SHIFT), 1) 360 + 361 + enum wx_tx_flags { 362 + /* cmd_type flags */ 363 + WX_TX_FLAGS_HW_VLAN = 0x01, 364 + WX_TX_FLAGS_TSO = 0x02, 365 + WX_TX_FLAGS_TSTAMP = 0x04, 366 + 367 + /* olinfo flags */ 368 + WX_TX_FLAGS_CC = 0x08, 369 + WX_TX_FLAGS_IPV4 = 0x10, 370 + WX_TX_FLAGS_CSUM = 0x20, 371 + WX_TX_FLAGS_OUTER_IPV4 = 0x100, 372 + WX_TX_FLAGS_LINKSEC = 0x200, 373 + WX_TX_FLAGS_IPSEC = 0x400, 374 + }; 375 + 376 + /* VLAN info */ 377 + #define WX_TX_FLAGS_VLAN_MASK GENMASK(31, 16) 378 + #define WX_TX_FLAGS_VLAN_SHIFT 16 379 + 380 + /* wx_dec_ptype.mac: outer mac */ 381 + enum wx_dec_ptype_mac { 382 + WX_DEC_PTYPE_MAC_IP = 0, 383 + WX_DEC_PTYPE_MAC_L2 = 2, 384 + WX_DEC_PTYPE_MAC_FCOE = 3, 385 + }; 386 + 387 + /* wx_dec_ptype.[e]ip: outer&encaped ip */ 388 + #define WX_DEC_PTYPE_IP_FRAG 0x4 389 + enum wx_dec_ptype_ip { 390 + WX_DEC_PTYPE_IP_NONE = 0, 391 + WX_DEC_PTYPE_IP_IPV4 = 1, 392 + WX_DEC_PTYPE_IP_IPV6 = 2, 393 + WX_DEC_PTYPE_IP_FGV4 = WX_DEC_PTYPE_IP_FRAG | WX_DEC_PTYPE_IP_IPV4, 394 + WX_DEC_PTYPE_IP_FGV6 = WX_DEC_PTYPE_IP_FRAG | WX_DEC_PTYPE_IP_IPV6, 395 + }; 396 + 397 + /* wx_dec_ptype.etype: encaped type */ 398 + enum wx_dec_ptype_etype { 399 + WX_DEC_PTYPE_ETYPE_NONE = 0, 400 + WX_DEC_PTYPE_ETYPE_IPIP = 1, /* IP+IP */ 401 + WX_DEC_PTYPE_ETYPE_IG = 2, /* IP+GRE */ 402 + WX_DEC_PTYPE_ETYPE_IGM = 3, /* IP+GRE+MAC */ 403 + WX_DEC_PTYPE_ETYPE_IGMV = 4, /* IP+GRE+MAC+VLAN */ 404 + }; 405 + 406 + /* wx_dec_ptype.proto: payload proto */ 407 + enum wx_dec_ptype_prot { 408 + WX_DEC_PTYPE_PROT_NONE = 0, 409 + WX_DEC_PTYPE_PROT_UDP = 1, 410 + WX_DEC_PTYPE_PROT_TCP = 2, 411 + WX_DEC_PTYPE_PROT_SCTP = 3, 412 + WX_DEC_PTYPE_PROT_ICMP = 4, 413 + WX_DEC_PTYPE_PROT_TS = 5, /* time sync */ 414 + }; 415 + 416 + /* wx_dec_ptype.layer: payload layer */ 417 + enum wx_dec_ptype_layer { 418 + WX_DEC_PTYPE_LAYER_NONE = 0, 419 + WX_DEC_PTYPE_LAYER_PAY2 = 1, 420 + WX_DEC_PTYPE_LAYER_PAY3 = 2, 421 + WX_DEC_PTYPE_LAYER_PAY4 = 3, 422 + }; 423 + 424 + struct wx_dec_ptype { 425 + u32 known:1; 426 + u32 mac:2; /* outer mac */ 427 + u32 ip:3; /* outer ip*/ 428 + u32 etype:3; /* encaped type */ 429 + u32 eip:3; /* encaped ip */ 430 + u32 prot:4; /* payload proto */ 431 + u32 layer:3; /* payload layer */ 432 + }; 433 + 434 + /* macro to make the table lines short */ 435 + #define WX_PTT(mac, ip, etype, eip, proto, layer)\ 436 + {1, \ 437 + WX_DEC_PTYPE_MAC_##mac, /* mac */\ 438 + WX_DEC_PTYPE_IP_##ip, /* ip */ \ 439 + WX_DEC_PTYPE_ETYPE_##etype, /* etype */\ 440 + WX_DEC_PTYPE_IP_##eip, /* eip */\ 441 + WX_DEC_PTYPE_PROT_##proto, /* proto */\ 442 + WX_DEC_PTYPE_LAYER_##layer /* layer */} 405 443 406 444 /* Host Interface Command Structures */ 407 445 struct wx_hic_hdr { ··· 588 412 u32 mta_shadow[128]; 589 413 s32 mc_filter_type; 590 414 u32 mcft_size; 415 + u32 vft_shadow[128]; 416 + u32 vft_size; 591 417 u32 num_rar_entries; 592 418 u32 rx_pb_size; 593 419 u32 tx_pb_size; ··· 686 508 } wb; /* writeback */ 687 509 }; 688 510 511 + struct wx_tx_context_desc { 512 + __le32 vlan_macip_lens; 513 + __le32 seqnum_seed; 514 + __le32 type_tucmd_mlhl; 515 + __le32 mss_l4len_idx; 516 + }; 517 + 518 + /* if _flag is in _input, return _result */ 519 + #define WX_SET_FLAG(_input, _flag, _result) \ 520 + (((_flag) <= (_result)) ? \ 521 + ((u32)((_input) & (_flag)) * ((_result) / (_flag))) : \ 522 + ((u32)((_input) & (_flag)) / ((_flag) / (_result)))) 523 + 689 524 #define WX_RX_DESC(R, i) \ 690 525 (&(((union wx_rx_desc *)((R)->desc))[i])) 691 526 #define WX_TX_DESC(R, i) \ 692 527 (&(((union wx_tx_desc *)((R)->desc))[i])) 528 + #define WX_TX_CTXTDESC(R, i) \ 529 + (&(((struct wx_tx_context_desc *)((R)->desc))[i])) 693 530 694 531 /* wrapper around a pointer to a socket buffer, 695 532 * so a DMA handle can be stored along with the buffer ··· 716 523 unsigned short gso_segs; 717 524 DEFINE_DMA_UNMAP_ADDR(dma); 718 525 DEFINE_DMA_UNMAP_LEN(len); 526 + __be16 protocol; 527 + u32 tx_flags; 719 528 }; 720 529 721 530 struct wx_rx_buffer { ··· 734 539 u64 bytes; 735 540 }; 736 541 542 + struct wx_rx_queue_stats { 543 + u64 csum_good_cnt; 544 + u64 csum_err; 545 + }; 546 + 737 547 /* iterator for handling rings in ring container */ 738 548 #define wx_for_each_ring(posm, headm) \ 739 549 for (posm = (headm).ring; posm; posm = posm->next) ··· 750 550 u8 count; /* total number of rings in vector */ 751 551 u8 itr; /* current ITR setting for ring */ 752 552 }; 753 - 754 553 struct wx_ring { 755 554 struct wx_ring *next; /* pointer to next ring in q_vector */ 756 555 struct wx_q_vector *q_vector; /* backpointer to host q_vector */ ··· 779 580 780 581 struct wx_queue_stats stats; 781 582 struct u64_stats_sync syncp; 583 + union { 584 + struct wx_rx_queue_stats rx_stats; 585 + }; 782 586 } ____cacheline_internodealigned_in_smp; 783 587 784 588 struct wx_q_vector { ··· 812 610 }; 813 611 814 612 struct wx { 613 + unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; 614 + 815 615 u8 __iomem *hw_addr; 816 616 struct pci_dev *pdev; 817 617 struct net_device *netdev;
+15 -5
drivers/net/ethernet/wangxun/ngbe/ngbe_main.c
··· 115 115 wx->mac.max_rx_queues = NGBE_MAX_RX_QUEUES; 116 116 wx->mac.max_tx_queues = NGBE_MAX_TX_QUEUES; 117 117 wx->mac.mcft_size = NGBE_MC_TBL_SIZE; 118 + wx->mac.vft_size = NGBE_SP_VFT_TBL_SIZE; 118 119 wx->mac.rx_pb_size = NGBE_RX_PB_SIZE; 119 120 wx->mac.tx_pb_size = NGBE_TDB_PB_SZ; 120 121 ··· 474 473 .ndo_change_mtu = wx_change_mtu, 475 474 .ndo_start_xmit = wx_xmit_frame, 476 475 .ndo_set_rx_mode = wx_set_rx_mode, 476 + .ndo_set_features = wx_set_features, 477 477 .ndo_validate_addr = eth_validate_addr, 478 478 .ndo_set_mac_address = wx_set_mac, 479 479 .ndo_get_stats64 = wx_get_stats64, 480 + .ndo_vlan_rx_add_vid = wx_vlan_rx_add_vid, 481 + .ndo_vlan_rx_kill_vid = wx_vlan_rx_kill_vid, 480 482 }; 481 483 482 484 /** ··· 555 551 ngbe_set_ethtool_ops(netdev); 556 552 netdev->netdev_ops = &ngbe_netdev_ops; 557 553 558 - netdev->features |= NETIF_F_HIGHDMA; 559 - netdev->features = NETIF_F_SG; 560 - 554 + netdev->features = NETIF_F_SG | NETIF_F_IP_CSUM | 555 + NETIF_F_TSO | NETIF_F_TSO6 | 556 + NETIF_F_RXHASH | NETIF_F_RXCSUM; 557 + netdev->features |= NETIF_F_SCTP_CRC | NETIF_F_TSO_MANGLEID; 558 + netdev->vlan_features |= netdev->features; 559 + netdev->features |= NETIF_F_IPV6_CSUM | NETIF_F_VLAN_FEATURES; 561 560 /* copy netdev features into list of user selectable features */ 562 - netdev->hw_features |= netdev->features | 563 - NETIF_F_RXALL; 561 + netdev->hw_features |= netdev->features | NETIF_F_RXALL; 562 + netdev->hw_features |= NETIF_F_NTUPLE | NETIF_F_HW_TC; 563 + netdev->features |= NETIF_F_HIGHDMA; 564 + netdev->hw_features |= NETIF_F_GRO; 565 + netdev->features |= NETIF_F_GRO; 564 566 565 567 netdev->priv_flags |= IFF_UNICAST_FLT; 566 568 netdev->priv_flags |= IFF_SUPP_NOFCS;
+1
drivers/net/ethernet/wangxun/ngbe/ngbe_type.h
··· 136 136 #define NGBE_RAR_ENTRIES 32 137 137 #define NGBE_RX_PB_SIZE 42 138 138 #define NGBE_MC_TBL_SIZE 128 139 + #define NGBE_SP_VFT_TBL_SIZE 128 139 140 #define NGBE_TDB_PB_SZ (20 * 1024) /* 160KB Packet Buffer */ 140 141 141 142 /* TX/RX descriptor defines */
+21 -2
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
··· 258 258 if (err != 0) 259 259 wx_err(wx, "Hardware Error: %d\n", err); 260 260 261 + wx_start_hw(wx); 261 262 /* do not flush user set addresses */ 262 263 memcpy(old_addr, &wx->mac_table[0].addr, netdev->addr_len); 263 264 wx_flush_sw_mac_table(wx); ··· 331 330 wx->mac.max_tx_queues = TXGBE_SP_MAX_TX_QUEUES; 332 331 wx->mac.max_rx_queues = TXGBE_SP_MAX_RX_QUEUES; 333 332 wx->mac.mcft_size = TXGBE_SP_MC_TBL_SIZE; 333 + wx->mac.vft_size = TXGBE_SP_VFT_TBL_SIZE; 334 334 wx->mac.rx_pb_size = TXGBE_SP_RX_PB_SIZE; 335 335 wx->mac.tx_pb_size = TXGBE_SP_TDB_PB_SZ; 336 336 ··· 493 491 .ndo_change_mtu = wx_change_mtu, 494 492 .ndo_start_xmit = wx_xmit_frame, 495 493 .ndo_set_rx_mode = wx_set_rx_mode, 494 + .ndo_set_features = wx_set_features, 496 495 .ndo_validate_addr = eth_validate_addr, 497 496 .ndo_set_mac_address = wx_set_mac, 498 497 .ndo_get_stats64 = wx_get_stats64, 498 + .ndo_vlan_rx_add_vid = wx_vlan_rx_add_vid, 499 + .ndo_vlan_rx_kill_vid = wx_vlan_rx_kill_vid, 499 500 }; 500 501 501 502 /** ··· 601 596 goto err_free_mac_table; 602 597 } 603 598 604 - netdev->features |= NETIF_F_HIGHDMA; 605 - netdev->features = NETIF_F_SG; 599 + netdev->features = NETIF_F_SG | 600 + NETIF_F_TSO | 601 + NETIF_F_TSO6 | 602 + NETIF_F_RXHASH | 603 + NETIF_F_RXCSUM | 604 + NETIF_F_HW_CSUM; 606 605 606 + netdev->gso_partial_features = NETIF_F_GSO_ENCAP_ALL; 607 + netdev->features |= netdev->gso_partial_features; 608 + netdev->features |= NETIF_F_SCTP_CRC; 609 + netdev->vlan_features |= netdev->features | NETIF_F_TSO_MANGLEID; 610 + netdev->hw_enc_features |= netdev->vlan_features; 611 + netdev->features |= NETIF_F_VLAN_FEATURES; 607 612 /* copy netdev features into list of user selectable features */ 608 613 netdev->hw_features |= netdev->features | NETIF_F_RXALL; 614 + netdev->hw_features |= NETIF_F_NTUPLE | NETIF_F_HW_TC; 615 + netdev->features |= NETIF_F_HIGHDMA; 616 + netdev->hw_features |= NETIF_F_GRO; 617 + netdev->features |= NETIF_F_GRO; 609 618 610 619 netdev->priv_flags |= IFF_UNICAST_FLT; 611 620 netdev->priv_flags |= IFF_SUPP_NOFCS;
+1
drivers/net/ethernet/wangxun/txgbe/txgbe_type.h
··· 77 77 #define TXGBE_SP_MAX_RX_QUEUES 128 78 78 #define TXGBE_SP_RAR_ENTRIES 128 79 79 #define TXGBE_SP_MC_TBL_SIZE 128 80 + #define TXGBE_SP_VFT_TBL_SIZE 128 80 81 #define TXGBE_SP_RX_PB_SIZE 512 81 82 #define TXGBE_SP_TDB_PB_SZ (160 * 1024) /* 160KB Packet Buffer */ 82 83