summaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mediatek
Commit message (Collapse)AuthorAgeFilesLines
* net: ethernet: mtk_eth_soc: add xdp tx return bulking supportLorenzo Bianconi2022-07-291-6/+14
| | | | | | | Convert mtk_eth_soc driver to xdp_return_frame_bulk APIs. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: introduce xdp multi-frag supportLorenzo Bianconi2022-07-291-43/+82
| | | | | | | | Add the capability to map non-linear xdp frames in XDP_TX and ndo_xdp_xmit callback. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: introduce mtk_xdp_frame_map utility routineLorenzo Bianconi2022-07-291-26/+42
| | | | | | | | This is a preliminary patch to add xdp multi-frag support to mtk_eth_soc driver Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk-ppe: fix traffic offload with bridged wlanLorenzo Bianconi2022-07-251-17/+13
| | | | | | | | | | | | | A typical flow offload scenario for OpenWrt users is routed traffic received by the wan interface that is redirected to a wlan device belonging to the lan bridge. Current implementation fails to fill wdma offload info in mtk_flow_get_wdma_info() since odev device is the local bridge. Fix the issue running dev_fill_forward_path routine in mtk_flow_get_wdma_info in order to identify the wlan device. Tested-by: Paolo Valerio <pvalerio@redhat.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: add support for page_pool_get_statsLorenzo Bianconi2022-07-252-3/+35
| | | | | | | | Introduce support for the page_pool stats API into mtk_eth_soc driver. Report page_pool stats through ethtool. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: add xmit XDP supportLorenzo Bianconi2022-07-252-22/+180
| | | | | | | | Introduce XDP support for XDP_TX verdict and ndo_xdp_xmit function pointer. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: introduce xdp ethtool countersLorenzo Bianconi2022-07-252-2/+36
| | | | | | | Report xdp stats through ethtool Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: add basic XDP supportLorenzo Bianconi2022-07-252-19/+145
| | | | | | | | | | | Introduce basic XDP support to mtk_eth_soc driver. Supported XDP verdicts: - XDP_PASS - XDP_DROP - XDP_REDIRECT Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: rely on page_pool for single page buffersLorenzo Bianconi2022-07-253-40/+156
| | | | | | | | Rely on page_pool allocator for single page buffers in order to keep them dma mapped and add skb recycling support. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski2022-07-212-1/+4
|\ | | | | | | | | | | No conflicts. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| * net: ethernet: mtk_ppe: fix possible NULL pointer dereference in ↵Lorenzo Bianconi2022-07-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | mtk_flow_get_wdma_info odev pointer can be NULL in mtk_flow_offload_replace routine according to the flower action rules. Fix possible NULL pointer dereference in mtk_flow_get_wdma_info. Fixes: a333215e10cb5 ("net: ethernet: mtk_eth_soc: implement flow offloading to WED devices") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://lore.kernel.org/r/4e1685bc4976e21e364055f6bee86261f8f9ee93.1658137753.git.lorenzo@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| * net: ethernet: mtk_eth_soc: fix off by one check of ARRAY_SIZETom Rix2022-07-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In mtk_wed_tx_ring_setup(.., int idx, ..), idx is used as an index here struct mtk_wed_ring *ring = &dev->tx_ring[idx]; The bounds of idx are checked here BUG_ON(idx > ARRAY_SIZE(dev->tx_ring)); If idx is the size of the array, it will pass this check and overflow. So change the check to >= . Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") Signed-off-by: Tom Rix <trix@redhat.com> Link: https://lore.kernel.org/r/20220716214654.1540240-1-trix@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | eth: mtk: switch to netif_napi_add_tx()Jakub Kicinski2022-07-081-2/+1
| | | | | | | | | | | | | | netif_napi_add_tx() does not require the weight argument. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* | net: ethernet: mtk-star-emac: enable half duplex hardware supportBiao Huang2022-06-291-18/+12
| | | | | | | | | | | | | | | | | | Current driver doesn't support half duplex correctly. This patch enable half duplex capability in hardware. Signed-off-by: Biao Huang <biao.huang@mediatek.com> Signed-off-by: Yinghua Pan <ot_yinghua.pan@mediatek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* | net: ethernet: mtk-star-emac: separate tx/rx handling with two NAPIsBiao Huang2022-06-291-141/+199
| | | | | | | | | | | | | | | | | | | | | | | | Current driver may lost tx interrupts under bidirectional test with iperf3, which leads to some unexpected issues. This patch let rx/tx interrupt enable/disable separately, and rx/tx are handled in different NAPIs. Signed-off-by: Biao Huang <biao.huang@mediatek.com> Signed-off-by: Yinghua Pan <ot_yinghua.pan@mediatek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* | net: ethernet: mtk-star-emac: add support for MII interfaceBiao Huang2022-06-291-1/+11
| | | | | | | | | | | | | | | | | | Add support for MII interface. If user wants to use MII, assign "MII" to "phy-mode" property in dts. Signed-off-by: Biao Huang <biao.huang@mediatek.com> Signed-off-by: Yinghua Pan <ot_yinghua.pan@mediatek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* | net: ethernet: mtk-star-emac: add timing adjustment supportBiao Huang2022-06-291-0/+33
| | | | | | | | | | | | | | | | | | | | Add simple clock inversion for timing adjustment in driver. Add property "mediatek,txc-inverse" or "mediatek,rxc-inverse" to device node when necessary. Signed-off-by: Biao Huang <biao.huang@mediatek.com> Signed-off-by: Yinghua Pan <ot_yinghua.pan@mediatek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* | net: ethernet: mtk-star-emac: add clock pad selection for RMIIBiao Huang2022-06-291-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch add a new dts property named "mediatek,rmii-rxc" parsing in driver, which will configure MAC to select which pin the RMII reference clock is connected to, TXC or RXC. TXC pad is the default reference clock pin. If user wants to use RXC pad instead, add "mediatek,rmii-rxc" to corresponding device node. Signed-off-by: Biao Huang <biao.huang@mediatek.com> Signed-off-by: Yinghua Pan <ot_yinghua.pan@mediatek.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* | net: ethernet: mtk-star-emac: add support for MT8365 SoCBiao Huang2022-06-291-11/+64
| | | | | | | | | | | | | | | | | | Add Ethernet driver support for MT8365 SoC. Signed-off-by: Biao Huang <biao.huang@mediatek.com> Signed-off-by: Yinghua Pan <ot_yinghua.pan@mediatek.com> Signed-off-by: Fabien Parent <fparent@baylibre.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* | net: ethernet: mtk-star-emac: modify IRQ trigger flagsBiao Huang2022-06-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | If the flags in request_irq() is IRQF_TRIGGER_NONE, the trigger method is determined by "interrupt" property in dts. So, modify the flag from IRQF_TRIGGER_FALLING to IRQF_TRIGGER_NONE. Signed-off-by: Biao Huang <biao.huang@mediatek.com> Signed-off-by: Yinghua Pan <ot_yinghua.pan@mediatek.com> Reviewed-by: Bartosz Golaszewski <brgl@bgdev.pl> Signed-off-by: David S. Miller <davem@davemloft.net>
* | net: ethernet: mtk-star-emac: store bit_clk_div in compat structureBiao Huang2022-06-291-4/+19
| | | | | | | | | | | | | | | | | | Not all the SoC are using the same clock divider. Move the divider into a compat structure specific to the SoCs. Signed-off-by: Biao Huang <biao.huang@mediatek.com> Signed-off-by: Fabien Parent <fparent@baylibre.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* | Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/netJakub Kicinski2022-06-091-2/+19
|\| | | | | | | | | | | No conflicts. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| * net: ethernet: mtk_eth_soc: fix misuse of mem alloc interface ↵Chen Lin2022-06-081-2/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | netdev[napi]_alloc_frag When rx_flag == MTK_RX_FLAGS_HWLRO, rx_data_len = MTK_MAX_LRO_RX_LENGTH(4096 * 3) > PAGE_SIZE. netdev_alloc_frag is for alloction of page fragment only. Reference to other drivers and Documentation/vm/page_frags.rst Branch to use __get_free_pages when ring->frag_size > PAGE_SIZE. Signed-off-by: Chen Lin <chen45464546@163.com> Link: https://lore.kernel.org/r/1654692413-2598-1-git-send-email-chen45464546@163.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* | net: ethernet: mtk_eth_soc: enable rx cksum offload for MTK_NETSYS_V2Lorenzo Bianconi2022-06-071-2/+9
|/ | | | | | | | Enable rx checksum offload for mt7986 chipset. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://lore.kernel.org/r/c8699805c18f7fd38315fcb8da2787676d83a32c.1654544585.git.lorenzo@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* net: ethernet: mtk_eth_soc: out of bounds read in mtk_hwlro_get_fdir_entry()Dan Carpenter2022-05-271-0/+3
| | | | | | | | | The "fsp->location" variable comes from user via ethtool_get_rxnfc(). Check that it is valid to prevent an out of bounds read. Fixes: 7aab747e5563 ("net: ethernet: mediatek: add ethtool functions to configure RX flows of HW LRO") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: fix error code in mtk_flow_offload_replace()Dan Carpenter2022-05-231-1/+2
| | | | | | | | | Preserve the error code from mtk_foe_entry_commit(). Do not return success. Fixes: c4f033d9e03e ("net: ethernet: mtk_eth_soc: rework hardware flow table management") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: introduce support for mt7986 chipsetLorenzo Bianconi2022-05-222-1/+72
| | | | | | | | Add support for mt7986-eth driver available on mt7986 soc. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: convert scratch_ring pointer to voidLorenzo Bianconi2022-05-222-2/+2
| | | | | | | Simplify the code converting scratch_ring pointer to void Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: convert ring dma pointer to voidLorenzo Bianconi2022-05-222-20/+16
| | | | | | | Simplify the code converting {tx,rx} ring dma pointer to void Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: introduce MTK_NETSYS_V2 supportLorenzo Bianconi2022-05-222-75/+372
| | | | | | | | | | Introduce MTK_NETSYS_V2 support. MTK_NETSYS_V2 defines 32B TX/RX DMA descriptors. This is a preliminary patch to add mt7986 ethernet support. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: introduce device register mapLorenzo Bianconi2022-05-222-181/+188
| | | | | | | | | | Introduce reg_map structure to add the capability to support different register definitions. Move register definitions in mtk_regmap structure. This is a preliminary patch to introduce mt7986 ethernet support. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: rely on rxd_size field in mtk_rx_alloc/mtk_rx_cleanLorenzo Bianconi2022-05-221-8/+18
| | | | | | | | | | Remove mtk_rx_dma structure layout dependency in mtk_rx_alloc/mtk_rx_clean. Initialize to 0 rxd3 and rxd4 in mtk_rx_alloc. This is a preliminary patch to add mt7986 ethernet support. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: rely on txd_size field in mtk_poll_tx/mtk_poll_rxLorenzo Bianconi2022-05-221-3/+6
| | | | | | | | This is a preliminary to ad mt7986 ethernet support. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: add rxd_size to mtk_soc_dataLorenzo Bianconi2022-05-222-4/+11
| | | | | | | | | | Similar to tx counterpart, introduce rxd_size in mtk_soc_data data structure. This is a preliminary patch to add mt7986 ethernet support. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: rely on txd_size in txd_to_idxLorenzo Bianconi2022-05-221-4/+7
| | | | | | | | This is a preliminary patch to add mt7986 ethernet support. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: rely on txd_size in mtk_desc_to_tx_bufLorenzo Bianconi2022-05-221-11/+15
| | | | | | | | This is a preliminary patch to add mt7986 ethernet support. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: rely on txd_size in mtk_tx_alloc/mtk_tx_cleanLorenzo Bianconi2022-05-221-10/+13
| | | | | | | | This is a preliminary patch to add mt7986 ethernet support. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: add txd_size to mtk_soc_dataLorenzo Bianconi2022-05-222-13/+38
| | | | | | | | | | | In order to remove mtk_tx_dma size dependency, introduce txd_size in mtk_soc_data data structure. Rely on txd_size in mtk_init_fq_dma() and mtk_dma_free() routines. This is a preliminary patch to add mt7986 ethernet support. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: move tx dma desc configuration in ↵Lorenzo Bianconi2022-05-222-49/+67
| | | | | | | | | | | | mtk_tx_set_dma_desc Move tx dma descriptor configuration in mtk_tx_set_dma_desc routine. This is a preliminary patch to introduce mt7986 ethernet support since it relies on a different tx dma descriptor layout. Tested-by: Sam Shih <sam.shih@mediatek.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* net: ethernet: mtk_eth_soc: rely on GFP_KERNEL for dma_alloc_coherent ↵Lorenzo Bianconi2022-05-221-5/+4
| | | | | | | | | | | whenever possible Rely on GFP_KERNEL for dma descriptors mappings in mtk_tx_alloc(), mtk_rx_alloc() and mtk_init_fq_dma() since they are run in non-irq context. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* eth: mtk_eth_soc: silence the GCC 12 array-bounds warningJakub Kicinski2022-05-221-0/+5
| | | | | | | | | | | | GCC 12 gets upset because in mtk_foe_entry_commit_subflow() this driver allocates a partial structure. The writes are within bounds. Silence these warnings for now, our build bot runs GCC 12 so we won't allow any new instances. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
* eth: mtk_ppe: fix up after mergeJakub Kicinski2022-05-191-1/+2
| | | | | | | | | | I missed this in the barrage of GCC 12 warnings. Commit cf2df74e202d ("net: fix dev_fill_forward_path with pppoe + bridge") changed the pointer into an array. Fixes: d7e6f5836038 ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net") Link: https://lore.kernel.org/r/20220520012555.2262461-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* net: mtk_eth_soc: partially convert to phylink_pcsRussell King (Oracle)2022-05-193-58/+53
| | | | | | | | | | Partially convert mtk_eth_soc to phylink_pcs, moving the configuration, link up and AN restart over. However, it seems mac_pcs_get_state() doesn't actually get the state from the PCS, so we can't convert that over without a better understanding of the hardware. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* net: mtk_eth_soc: convert code structure to suit split PCS supportRussell King (Oracle)2022-05-192-59/+79
| | | | | | | | | | Provide a mtk_pcs structure which encapsulates everything that the PCS functions need (the regmap and ana_rgc3 offset), and use this in the PCS functions. Provide shim functions to convert from the existing "mtk_sgmii_*" interface to the converted PCS functions. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* net: mtk_eth_soc: move restoration of SYSCFG0 to mac_finish()Russell King (Oracle)2022-05-192-2/+10
| | | | | | | | | | The SGMIISYS configuration is performed while ETHSYS_SYSCFG0 is in a disabled state. In order to preserve this when we switch to phylink_pcs we need to move the restoration of this register to the mac_finish() callback. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* net: mtk_eth_soc: move MAC_MCR setting to mac_finish()Russell King (Oracle)2022-05-191-11/+22
| | | | | | | | | Move the setting of the MTK_MAC_MCR register from the end of mac_config into the phylink mac_finish() method, to keep it as the very last write that is done during configuration. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* net: mtk_eth_soc: add fixme comment for state->speed useRussell King (Oracle)2022-05-191-0/+8
| | | | | | | | | | | | | | Add a fixme comment for the last remaining incorrect usage of state->speed in the mac_config() method, which is strangely in a code path which is only run when the PHY interface mode changes. This means if we are in RGMII mode, changes in state->speed will not cause the INTF_MODE, TRGMII_RCK_CTRL and TRGMII_TCK_CTRL registers to be set according to the speed, nor will the TRGPLL clock be set to the correct value. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* net: mtk_eth_soc: provide mtk_sgmii_config()Russell King (Oracle)2022-05-193-12/+20
| | | | | | | | Provide mtk_sgmii_config() to wrap up the decisions about which SGMII configuration will be called. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* net: mtk_eth_soc: stop passing phylink state to sgmii setupRussell King (Oracle)2022-05-193-4/+4
| | | | | | | | | Now that mtk_sgmii_setup_mode_force() only uses the interface mode from the phylink state, pass just the interface mode into this function. Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
* net: mtk_eth_soc: correct 802.3z duplex settingRussell King2022-05-193-10/+29
| | | | | | | | | | Phylink does not guarantee that state->duplex will be set correctly in the mac_config() call, so it's a bug that the driver makes use of it. Move the 802.3z PCS duplex configuration to mac_link_up(). Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <kuba@kernel.org>