aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mediatek (follow)
AgeCommit message (Collapse)AuthorFilesLines
2016-07-12net: mediatek: fix non static symbol warningsWei Yongjun1-3/+3
Fixes the following sparse warnings: drivers/net/ethernet/mediatek/mtk_eth_soc.c:79:5: warning: symbol '_mtk_mdio_write' was not declared. Should it be static? drivers/net/ethernet/mediatek/mtk_eth_soc.c:98:5: warning: symbol '_mtk_mdio_read' was not declared. Should it be static? Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-06net: mediatek: remove .owner field for driverWei Yongjun1-1/+0
Remove .owner field since calls to module_platform_driver() will set it automatically. Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-04net-next: mediatek: remove superfluous free_irq() callJohn Crispin1-1/+0
Commit 8067302973a1 ("net-next: mediatek: add support for IRQ grouping") adds handling for irq 1 and 2 to the uninit function but did not remove irq 0 which is not used since irq grouping was introduced. Fix this by removing the superfluous call to free_irq(). Reported-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: John Crispin <john@phrozen.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-07-02net-next: mediatek: fix compile error inside mtk_poll_controller()John Crispin1-1/+1
commit 8067302973a1 ("net-next: mediatek: add support for IRQ grouping") failed to properly update the irq handling inside mtk_poll_controller() causing compile errors if netconsole was enabled. Fix this by updating the code to use the new separated irq handler function for RX. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-30net-next: mediatek: add support for IRQ groupingJohn Crispin2-59/+111
The ethernet core has 3 IRQs. Using the IRQ grouping registers we are able to separate TX and RX IRQs, which allows us to service them on separate cores. This patch splits the IRQ handler into 2 separate functions, one for TX and another for RX. The TX housekeeping is split out into its own NAPI handler. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-30net-next: mediatek: add IRQ lockingJohn Crispin2-0/+8
The code that enables and disables IRQs is missing proper locking. After adding the IRQ grouping patch and routing the RX and TX IRQs to different cores we experienced IRQ stalls. Fix this by adding proper locking. We use a dedicated lock to reduce the latency if the IRQ code. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-30net-next: mediatek: don't use intermediate variables to store IRQ masksJohn Crispin1-12/+10
The code currently uses variables to store and never modify the bit masks of interrupts. This is legacy code from an early version of the driver that supported MIPS based SoCs where the IRQ bits depended on the actual SoC. As the bits are the same for all ARM based SoCs using this driver we can remove the intermediate variables. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-30net-next: mediatek: remove superfluous register readsJohn Crispin1-4/+0
The driver was originally written for MIPS based SoC. These required the IRQ mask register to be read after writing it to ensure that the content was actually applied. As this version only works on ARM based SoCs, we can safely remove the 2 reads as they are no longer required. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: remove superfluous queue wake up callJohn Crispin1-5/+2
The code checks if the queue should be stopped because we are below the threshold of free descriptors only to check if it should be started again. If we do end up in a state where we are at the threshold limit, it makes more sense to just stop the queue and wait for the next IRQ to trigger the TX housekeeping again. There is no rush in enqueuing the next packet, it needs to wait for all the others in the queue to be dispatched first anyway. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: only wake the queue if it is stoppedJohn Crispin1-1/+16
The current code unconditionally wakes up the queue at the end of each tx_poll action. Change the code to only wake up the queues if any of them have actually been stopped before. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: fix off by one in the TX ring allocationJohn Crispin1-2/+1
The TX ring setup has an off by one error causing it to not utilise all descriptors. This has the side effect that we need to reset the next pointer at runtime to make it work. Fix the off by one and remove the code fixing the ring at runtime. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: increase watchdog_timeoJohn Crispin1-1/+1
During stress testing, after reducing the threshold value, we have seen TX timeouts that were caused by the watchdog_timeo value being too low. Increase the value to 5 * HZ which is a value commonly used by many other drivers. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: fix threshold valueJohn Crispin1-2/+1
The logic to calculate the threshold value for stopping the TX queue is bad. Currently it will always use 1/2 of the rings size, which is way too much. Set the threshold to MAX_SKB_FRAGS. This makes sure that the queue is stopped when there is not enough room to accept an additional segment.  Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: disable all interrupts during probeJohn Crispin1-1/+1
The current code only disables those IRQs that we will later use. To ensure that we have a predefined state, we really want to disable all IRQs. Change the code to disable all IRQs to achieve this. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: add next data pointer coherency protectionJohn Crispin2-1/+2
The QDMA engine can fail to update the register pointing to the next TX descriptor if this bit does not get set in the QDMA configuration register. Not setting this bit can result in invalid values inside the TX rings registers which will causes TX stalls. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: dropped rx packets are not being counted properlyJohn Crispin1-0/+2
There are two places inside mtk_poll_rx where rx_dropped is not being incremented properly. Fix this by adding the missing code to increment the counter. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: invalid buffer lookup in mtk_tx_map()John Crispin1-1/+1
The lookup of the tx_buffer in the error path inside mtk_tx_map() uses the wrong descriptor pointer. This looks like a copy & paste error. Change the code to use the correct pointer. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: fix missing free of scratch memoryJohn Crispin2-5/+15
Scratch memory gets allocated in mtk_init_fq_dma() but the corresponding code to free it is missing inside mtk_dma_free() causing a memory leak. With this patch applied, we can run ifconfig up/down several thousand times without any problems. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-10net: mediatek: add missing return code checkJohn Crispin1-0/+3
The code fails to check if the scratch memory was properly allocated. Add this check and return with an error if the allocation failed. Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-03net-next: mediatek: properly handle RGMII modesJohn Crispin1-0/+3
If an external Gigabit PHY is connected to either of the MACs we need to be able to tell the PHY to use a delay. Not doing so will result in heavy packet loss and/or data corruption when using PHYs such as the IC+ IP1001. We tell the PHY which MII delay mode to use via the devictree. The ethernet driver needs to be adapted to handle all 3 rgmii-*id modes in the same way as normal rgmii when setting up the MAC. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-03net-next: mediatek: add fixed-phy supportJohn Crispin1-0/+3
The MT7623 SoC has a builtin gigabit switch. If we want to use it, GMAC1 needs to be configured using a fixed link speed and flow control settings. The easiest way to do this is to used the fixed-phy driver, allowing us to reuse the existing mdio polling code to setup the MAC. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-03net-next: mediatek: fix gigabit and flow control advertisementJohn Crispin1-4/+26
The current code will not setup the PHYs advertisement features correctly. Fix this and properly advertise Gigabit features and properly handle asymmetric pause frames. Signed-off-by: Sean Wang <keyhaede@gmail.com> Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-03net-next: mediatek: use mdiobus_free() in favour of kfree()John Crispin1-2/+2
The driver currently uses kfree() to clear the mii_bus. This is not the correct way to clear the memory and mdiobus_free() should be used instead. This patch fixes the two instances where this happens in the driver. Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: John Crispin <john@phrozen.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-12net: mediatek: do not set the QID field in the TX DMA descriptorsJohn Crispin1-2/+1
The QID field gets set to the mac id. This made the DMA linked list queue the traffic of each MAC on a different internal queue. However during long term testing we found that this will cause traffic stalls as the multi queue setup requires a more complete initialisation which is not part of the upstream driver yet. This patch removes the code setting the QID field, resulting in all traffic ending up in queue 0 which works without any special setup. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-12net: mediatek: move the pending_work struct to the device generic structJohn Crispin2-10/+7
The worker always touches both netdevs. It is ethernet core and not MAC specific. We only need one worker, which belongs into the ethernets core struct. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-12net: mediatek: fix mtk_pending_workJohn Crispin1-8/+20
The driver supports 2 MACs. Both run on the same DMA ring. If we hit a TX timeout we need to stop both netdevs before restarting them again. If we don't do this, mtk_stop() wont shutdown DMA and the consecutive call to mtk_open() wont restart DMA and enable IRQs. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-12net: mediatek: fix TX lockingJohn Crispin1-10/+10
Inside the TX path there is a lock inside the tx_map function. This is however too late. The patch moves the lock to the start of the xmit function right before the free count check of the DMA ring happens. If we do not do this, the code becomes racy leading to TX stalls and dropped packets. This happens as there are 2 netdevs running on the same physical DMA ring. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-12net: mediatek: fix stop and wakeup of queueJohn Crispin1-10/+27
The driver supports 2 MACs. Both run on the same DMA ring. If we go above/below the TX rings threshold value, we always need to wake/stop the queue of both devices. Not doing to can cause TX stalls and packet drops on one of the devices. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-12net: mediatek: remove superfluous reset callJohn Crispin1-4/+0
HW reset is triggered in the mtk_hw_init() function. There is no need to also reset the core during probe. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-12net: mediatek: mtk_cal_txd_req() returns bad valueJohn Crispin1-1/+1
The code used to also support the PDMA engine, which had 2 packet pointers per descriptor. Because of this we had to divide the result by 2 and round it up. This is no longer needed as the code only supports QDMA. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-04-12net: mediatek: watchdog_timeo was not setJohn Crispin1-0/+1
The original commit failed to set watchdog_timeo. This patch sets watchdog_timeo to HZ. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-03-23net: mediatek: fix checking for NULL instead of IS_ERR() in .probeVladimir Zapolskiy1-2/+2
devm_ioremap_resource() returns ERR_PTR() value on error, it never returns NULL, fix it and propagate the returned error upwards. Fixes: 656e705243fd ("net-next: mediatek: add support for MT7623 ethernet") Signed-off-by: Vladimir Zapolskiy <vz@mleia.com> Reviewed-by: Matthias Brugger <mbrugger@suse.com> Acked-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-03-18mediatek: unlock on error in mtk_tx_map()Dan Carpenter1-0/+2
There was a missing unlock on the error path. Fixes: 656e705243fd ('net-next: mediatek: add support for MT7623 ethernet') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-03-18mediatek: checking for IS_ERR() instead of NULLDan Carpenter1-2/+2
of_phy_connect() returns NULL on error, it never returns error pointers. Fixes: 656e705243fd ('net-next: mediatek: add support for MT7623 ethernet') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-03-14net: mediatek: check device_reset return codeArnd Bergmann1-1/+3
The device_reset() function may fail, so we have to check its return value, e.g. to make deferred probing work correctly. gcc warns about it because of the warn_unused_result attribute: drivers/net/ethernet/mediatek/mtk_eth_soc.c: In function 'mtk_probe': drivers/net/ethernet/mediatek/mtk_eth_soc.c:1679:2: error: ignoring return value of 'device_reset', declared with attribute warn_unused_result [-Werror=unused-result] This adds the trivial error check to propagate the return value to the generic platform device probe code. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-03-14net: mediatek: remove incorrect dma_mask assignmentArnd Bergmann1-3/+0
Device drivers should not mess with the DMA mask directly, but instead call dma_set_mask() etc if needed. In case of the mtk_eth_soc driver, the mask already gets set correctly when the device is created, and setting it again is against the documented API. This removes the incorrect setting. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-03-14net: mediatek: use dma_addr_t correctlyArnd Bergmann1-1/+1
dma_alloc_coherent() expects a dma_addr_t pointer as its argument, not an 'unsigned int', and gcc correctly warns about broken code in the mtk_init_fq_dma function: drivers/net/ethernet/mediatek/mtk_eth_soc.c: In function 'mtk_init_fq_dma': drivers/net/ethernet/mediatek/mtk_eth_soc.c:463:13: error: passing argument 3 of 'dma_alloc_coherent' from incompatible pointer type [-Werror=incompatible-pointer-types] This changes the type of the local variable to dma_addr_t. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-03-10net-next: mediatek: add Kconfig and MakefileJohn Crispin2-0/+22
This patch adds the Makefile and Kconfig required to make the driver build. Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>
2016-03-10net-next: mediatek: add support for MT7623 ethernetJohn Crispin2-0/+2228
Add ethernet support for MediaTek SoCs from the MT7623 family. These have dual GMAC. Depending on the exact version, there might be a built-in Gigabit switch (MT7530). The core does not have the typical DMA ring setup. Instead there is a linked list that we add descriptors to. There is only one linked list that both MACs use together. There is a special field inside the TX descriptors called the VQID. This allows us to assign packets to different internal queues. By using a separate id for each MAC we are able to get deterministic results for BQL. Additionally we need to provide the core with a block of scratch memory that is the same size as the RX ring and data buffer. This is really needed to make the HW datapath work. Although the driver does not support this yet, we still need to assign the memory and tell the core about it for RX to work. Signed-off-by: Felix Fietkau <nbd@openwrt.org> Signed-off-by: Michael Lee <igvtee@gmail.com> Signed-off-by: John Crispin <blogic@openwrt.org> Signed-off-by: David S. Miller <davem@davemloft.net>