Commit Graph

52 Commits (d3c0a944059bb0d45c3b56278249100258378b0c)

Author SHA1 Message Date
Rosen Penev c36ef5970b ramips: ethernet: Replace random_ether_addr with eth_hw_addr_random
eth_hw_addr_random additionally sets addr_assign_type to NET_ADDR_RANDOM.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
5 years ago
Deng Qingfang fd4804ce33 ramips: add MT7530 switch port-mirroring support
Compile & run tested on MT7620, MT7621

Signed-off-by: Deng Qingfang <dengqf6@mail2.sysu.edu.cn>
[Tested on Phicomm PSG1218 rev.A, MediaTek MT7620A ver:2 eco:6]
Tested-by: MingHao Chen <cmheia@email.com>
5 years ago
Chuanhong Guo fae125781e ramips: mtk-mmc: mt76x8: check ESD_MODE before applying AGPIO_CFG
Since mt76x8an ver1 eco2, SDXC pins can be switched to the
following pinmap:
sd_d1  -> PAD_I2S_SDI
sd_d0  -> PAD_I2S_WS
sd_cmd -> PAD_I2S_CLK
sd_d3  -> PAD_I2C_SCLK
sd_d2  -> PAD_I2C_SD
sd_clk -> PAD_GPIO0
sd_wp  -> PAD_TXD1
sd_cd  -> PAD_RXD1

To use this pinmap, one would need to set ESD_MODE bit (bit 15)
to 1 in GPIO1_MODE and switch other used pads into GPIO mode.
In this mode, we don't need to switch ethernet pins to digital
pad.

Check ESD_MODE bit before applying AGPIO_CFG and use rt_sysc_m32
to set it.

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
5 years ago
Pawel Dembicki 391df37829 ramips: mt7620: add EPHY base mdio address changing possibility
In some boards is requred to change the ephy mdio base address.

This patch add of property "mediatek,ephy-base-address" in gsw
part, which allows to change ephy base address.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
[fixed indentation in header file]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years ago
Pawel Dembicki c02a9a2514 ramips: mt7620: fix external PHY autopolling
The port initialisation is based on assumption that phy address and
port number is the same. SoC allow different numbers and some board
have it.

Use phy address instead the port number to make sure that correct
addresses are polled.

In situation when only one PHY with address 0x0 is conected to
port 4, autopolling is broken.

This patch make autopolling correct when port number and phy address
are different.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
5 years ago
Mathias Kresin f96c7f697f ramips: handle mdio address and switch port seperate
The phy handling code forces a phy mdio address and the switch port to
which a phy is attached to be the same. Albeit such a configuration is
used for most boards, it isn't for all.

Pass the switch port number to the ethernet phy connect functions, to
ensure the correct list entry is edited and not the list entry that
matches th phys mdio address.

Use the mdio address with mdiobus_get_phy instead of the port number,
to make sure the expected ethernet phy gets connected.

Signed-off-by: Mathias Kresin <dev@kresin.me>
5 years ago
Mathias Kresin fb423f6e01 ramips: ignore already handled ethernet phys
The whole logic in fe_phy_connect() is based on the asumption that mdio
address and switch port id are equal. Albeit it is true for most
boards, it doesn't is for all.

It isn't yet clear which subtargets/boards require the devicetree less
ethernet phy handling. Hence change the code in a way that it doesn't
touch ethernet phys which were early attached and are already handled.

Signed-off-by: Mathias Kresin <dev@kresin.me>
5 years ago
Birger Koblitz 88f7a29f99 ramips: add support for Edimax EW-7476RPC / EW-7478AC
SoC:	MediaTek MT7620a @ 580MHz
RAM:	64M (Winbond W9751G6KB-25)
FLASH:	8MB (Macronix)
WiFi:	SoC-integrated: MediaTek MT7620a bgn
WiFi:	MediaTek MT7612EN nac
GbE:	1x (RTL8211E)
BTN:	WPS - RFKILL/RF 50%/RF 100% toggle
LED:	- Wifi 5g (blue)
	- Wifi 2g (blue)
	- Crossband (green)
	- Power (green)
	- WPS (green)
	- LAN (Green)
UART:	UART is present as Pads with throughholes on the PCB. They are
	located next to the switch for the wifi configuration
	3.3V - RX - GND - TX / 57600-8N1
	3.3V is the square pad

Installation
------------
Update the factory image via the web-interfaces (by default:
192.168.9.2/24).
http://192.168.9.2/index.asp

ramips: add Edimax EW-7478AC

SoC:	MediaTek MT7620a @ 580MHz
RAM:	64M (Winbond W9751G6KB-25)
FLASH:	8MB (Macronix)
WiFi:	SoC-integrated: MediaTek MT7620a bgn
WiFi:	MediaTek MT7612EN nac
GbE:	1x (RTL8211E)
BTN:	WPS - RFKILL/RF 50%/RF 100% toggle
LED:	- Wifi 5g (blue)
	- Wifi 2g (blue)
	- Crossband (green)
	- Power (green)
	- WPS (green)
	- LAN (Green)
UART:	UART is present as Pads with throughholes on the PCB. They are
	located next to the switch for the wifi configuration
	3.3V - RX - GND - TX / 57600-8N1
	3.3V is the square pad

Installation
------------
Update the factory image via the web-interfaces (by default:
http://edimaxext.setup)
Or push wpa button on power on and send firmware via tftp to 192.168.1.6

The EW-7478AC is identical to the EW-7476RPC, except instead of 2 internal
antennas it has 2 external ones.

Signed-off-by: Birger Koblitz <mail@birger-koblitz.de>
[merge conflict in 01_leds]
Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years ago
Petr Štetiar bf58bc3bd8 ramips: ethernet: remove unused SIOCETHTOOL ioctl handling
This ioctl is currently routed through generic interface code.

  dev_ioctl
    dev_ethtool
      __ethtool_get_link_ksettings
        phy_ethtool_ioctl

Cc: Felix Fietkau <nbd@nbd.name>
Cc: John Crispin <john@phrozen.org>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
5 years ago
Felix Fietkau c9262a96d1 ramips: implement vlan rx offload on MT7621
Avoids the overhead of software VLAN untagging in the network stack

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years ago
Felix Fietkau bee7ff7cf3 ramips: allow packets with ttl=0
Some broken ISPs (e.g. Comcast) send DHCPv6 packets with hop limit=0.
This trips up the TTL=0 check in the PPE if enabled.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
5 years ago
HsiuWen Yen fe7d965ea9 ramips: fix two-way hash and auto ageout on MT7621
Current code directly writes the FOE entry to hash_val+1 position
when hash collision occurs. However, it is found that this behavior
will cause the cache and the hardware FOE table to be inconsistent.

For example, there are three flows, and their hashed values are all
equal to 100. The first flow is written to the position of 100. The
second flow is written to the position of 100+1. Then, the logic of
the current code will also write the third flow to 100+1.

At this time, the cache has flow 1 and 2; and the hardware FOE table
has flow 1 and 3, where these two parts store different contents.
So it is necessary to check whether the hash_val+1 is also occupied
before writing. If hash_val+1 is also occupied, we won’t bind th
third flow to the FOE table.

Addition to that, we also cancel the processing of foe_entry removal
because the hardware has auto age-out ability. The hardware will
periodically iterate through the FOE table to find out the time-out
entry and set it as INVALID.

Signed-off-by: HsiuWen Yen <y.hsiuwen@gmail.com>
5 years ago
John Crispin 93c35bfa21 ramips: whitespace cleanup inside hnat driver
Signed-off-by: John Crispin <john@phrozen.org>
5 years ago
HsiuWen Yen 6b9bdbd493 ramips: add two-way hashing scheme for MT7621
Sometimes the tuples might be hashed to the same FOE entry.
When this hash collision problem occurs, some of the
connections will not be bound and consequently the CPU
idle rate cannot reach 100%. Therefore, two-way hashing
is adopted to alleviate this problem.

Signed-off-by: HsiuWen Yen <y.hsiuwen@gmail.com>
5 years ago
Pawel Dembicki b85fe43ec8 ramips: mt7620: add force use of mdio-mode
Some boards have external switches different than mt7530.

This patch allow to use mdio-mode without 0x1f register.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
6 years ago
Mathias Kresin 287b7aa583 ramips: drop obsolete sd card driver code
The pinmux for all SoCs using this driver is now set via the pinmux. It
makes this code obsolete.

Some of the code targeting the mt76x8 SoCs is still required. The sd
card pins share the pads with the EPHY. These pads need to be switched
to digital mode if the pins are used for sd cards.

The eMMC 8-bit mode has to be enabled via pinmux instead of a kernel
option. The uart2 group need to be set to function "sdxc d5 d4", pwm1
to "sdxc d6" and pwm0 to "sdxc d7" to do so. It can't be done by as
part of a default pinmux, as it would break the normal operation of
uart2.

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Felix Fietkau b605a84a74 ramips: ethernet: unify tx descriptor buffer splitting
A buffer is split into multiple descriptors if it exceeds 16 KB.
Apply the same split for the skb head as well (to deal with corner cases
on fraglist support)

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Jo-Philipp Wich 4302c917cc Revert "ramips: mmc: Fix init for MT7628AN"
This reverts commit 3a8efaef00.

The change reportedly breaks UART2 on some boards. Furthermore it uses
bitwise logic on an uninitialized variable and fails to explain what it
is fixing exactly.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
6 years ago
Mathias Kresin 1ea1f3a223 ramips: mt7620: fix bad indent
Fix the indent to make the make it obvious which condition is the
parent of the loop.

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Pawel Dembicki 4877ad44c7 ramips: mt7620: enable all ports unconditionally
This patch make all mt7620 ephy ports turned on.
It is necessary for some JBOOT devices.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
6 years ago
Chen Minqiang f6d81e2fa1 mt7620: gsw: make IntPHY and ExtPHY share mdio addr 4 possible
To share mdio addr for IntPHY and ExtPHY,
as described in the documentation (MT7620_ProgrammingGuide.pdf).
(refer: http://download.villagetelco.org/hardware/MT7620/MT7620_ProgrammingGuide.pdf)

when port4 setup to work as gmac mode, dts like:

&gsw {
    mediatek,port4 = "gmac";
};

we should set SYSCFG1.GE2_MODE==0x0 (RGMII).
but SYSCFG1.GE2_MODE may have been set to 3(RJ-45) by uboot/default
so we need to re-set it to 0x0

before this changes:
gsw: 4FE + 2GE may not work correctly and MDIO addr 4 cannot be used by ExtPHY

after this changes:
gsw: 4FE + 2GE works and MDIO addr 4 can be used by ExtPHY

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
6 years ago
Daniel Gimpelevich 379fe50672 ramips: fix gigabit switch PHY access on MDIO
When PHY's are defined on the MDIO bus in the DTS, gigabit support was
being masked out for no apparent reason, pegging all such ports to 10/100.
If gigabit support must be disabled for some reason, there should be a
"max-speed" property in the DTS.

Reported-by: James McKenzie <openwrt@madingley.org>
Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
6 years ago
Daniel Gimpelevich 5a6229a93d ramips: remove superfluous & confusing DT binding
Mediatek has a reference platform that pairs an MT7620A with an MT7530W,
where the latter responds on MDIO address 0x1f while both chips respond on
0x0 to 0x4. The driver special-cases this arrangement to make sure it's
talking to the right chip, but two different ways in two different places.
This patch consolidates the detection without the current requirement of
both tests to be separately satisfied in the DTS.

Signed-off-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
6 years ago
LoveSy 3a8efaef00 ramips: mmc: Fix init for MT7628AN
There is another thing about crc to do when initialize SD card on
MT7628.
This commit is to fix this init issue.

Signed-off-by: LoveSy <shana@zju.edu.cn>
6 years ago
Felix Fietkau 2601e34fad ramips: ethernet: disable fraglist support
The code has some remaining issues that cause ethernet hangs, so
disable it for now until we can get it fixed

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 0c285bd081 ramips: ethernet: use own page_frag_cache
Using the NAPI or netdev frag cache along with other drivers can lead to
32 KiB pages being held for a long time, despite only being used for
very few page fragment.
This can happen if the ethernet driver grabs one or two fragments for rx
ring refill, while other drivers use (and free up) the remaining
fragments. The 32 KiB higher-order page can only be freed once all users
have freed their fragments, which only happens after the rings of all
drivers holding the fragments have wrapped around.

Depending on the traffic patterns, this can waste a lot of memory and
look a lot like a memory leak

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 01df4a2565 ramips: ethernet: use skb_free_frag to free fragments
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 9a4253b81f ramips: improve ethernet driver performance with GRO/TSO
GRO stores packets as fraglist. If they are routed back to the ethernet
device, they need to be re-segmented if the driver does not support
sending fraglists.
Add the missing support for that, along with a missing feature flag that
allows full routed GRO->TSO offload.
Considerably reduces CPU utilization for routing

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Mathias Kresin 5da2c68d00 ramips: mt7621: fix mtu setting with kernel 4.14
Since kernel 4.10 commit 61e84623ace3 ("net: centralize net_device
min/max MTU checking"), the range of mtu is [min_mtu, max_mtu], which
is [68, 1500] by default.

It's necessary to set a max_mtu if a mtu > 1500 is supported.

Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago
Felix Fietkau ec502cd3fe ramips: rename ethernet driver folder to the same one that upstream uses
Preparation for sharing offload code with the mediatek target through
generic files/

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Rosen Penev 66cc6dd6c4 ramips: mmc: Add back some non-mt7621 code that staging removed
This reverts commit 8a570921b5.

This seems to have been accidentally reverted. This fixes mt7620 and
mt7628.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Acked-by: Daniel Golle <daniel@makrotopia.org>
6 years ago
John Crispin 8a570921b5 Revert "ramips: Add back some non-mt7621 code that staging removed"
This reverts commit 048e41f649.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
Rosen Penev 048e41f649 ramips: Add back some non-mt7621 code that staging removed
Staging is meant only for mt7621 but for OpenWrt more is needed.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Rosen Penev fec205f654 ramips: mmc: Sync with staging driver
Mostly whitespace cleanups. Some unneeded code was removed.

MMC init was also moved to the probe function as in
6069bdd

The cleanup commits are over 100, making it hard to do them individually.

Tested on GnuBee PC1 with an SD card being used as swap.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
v2: Fixed compile issue with mt7620
6 years ago
John Crispin 7e15e21766 Revert "ramips: mmc: Sync with staging drivers"
This reverts commit 2d401925b9.

Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
Wei Yongjun 87c254c87e staging: mt7621-eth: fix return value check in mt7621_gsw_probe()
In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: f079b6406348 ("staging: mt7621-eth: add gigabit switch driver (GSW)")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years ago
Wei Yongjun edec251870 staging: mt7621-eth: fix return value check in mtk_connect_phy_node()
In case of error, the function of_phy_connect() returns NULL pointer not
ERR_PTR(). The IS_ERR() test in the return value check should be
replaced with NULL test.

Fixes: e3cbf478f846 ("staging: mt7621-eth: add the drivers core files")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years ago
Wei Yongjun c4ae54dfab staging: mt7621-eth: fix return value check in mtk_probe()
In case of error, the function devm_ioremap_resource() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: e3cbf478f846 ("staging: mt7621-eth: add the drivers core files")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 years ago
Rosen Penev 2d401925b9 ramips: mmc: Sync with staging drivers
Mostly whitespace cleanups. Some unneeded code was removed.

MMC init was also moved to the probe function as in
6069bdd087

The cleanup commits are over 100, making it hard to do them individually.

Tested on GnuBee PC1 with an SD card being used as swap.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Felix Fietkau 6069bdd087 ramips: move mtk-mmc init to probe function to avoid breaking NAND flash
The driver messes with the pin control settings - MMC and NAND are
mutually exclusive

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 173d93ea23 ramips: fix locking issues in the ethernet driver
The stats update needs to protect against being interrupted by a tasklet
The u64 stats seqlock needs to be initialized

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau ceff5d8c82 ramips: add missing unlock in fe_phy_link_adjust
Based on patch by Neil Brown

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
John Crispin bfed382540 ramips: fix build error caused by missing ifdef guard in hwnat code
Signed-off-by: John Crispin <john@phrozen.org>
6 years ago
John Crispin 424a9ae128 ramips: implement hardware NAT offload for MT7621
Supports IPv4 flow offloading on MT7621 for Routing, SNAT and DNAT

Supported are regular ethernet->ethernet connections, including one
802.1q VLAN and/or PPPoE encapsulation

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
NeilBrown f27336e115 ramips: mtk-mmc: don't advertise highmem support.
of_dma_configure() sets a default ->dma_mask of
DMA_BIT_MASK(32), claiming devices can DMA from
the full 32bit address space.
The mtk-mmc driver does not support access to
highmem pages, so it is really limited to the
bottom 512M (actually 448M due to 64M of IO space).
Setting ->dma_mask to NULL causes mmc_setup_queue()
to fall-back to using BLK_BOUNCE_HIGH to tell the
block layer to use a bounce-buffer for any highmem
pages requiring IO.

Signed-off-by: NeilBrown <neil@brown.name>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 6a621f4bd9 ramips: fix BUG_ON on mtk-mmc driver probe
Our .dts files only have one device defined and this is unlikely to
change, so statically initialize host->id to 0.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau f9b2d369a6 ramips: move mtk-mmc driver code out of patches-*/ and into files-*/
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau a276002079 ramips: remove dead (and potentially crashy) code in mt7621 gsw init
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 147b679891 ramips: rename ethernet priv->device field to dev to match upstream
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Pawel Dembicki 39b5218434 ramips: mt7620: power up ephy port 4
In some boards port 4 of mt7620 switch is powered down in bootloader
configuration as lan/wan package leak mitigation.

Reset ephy port 4 to default settings to power up the port.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
[clarify issue in commit message]
Signed-off-by: Mathias Kresin <dev@kresin.me>
6 years ago