forked from coolsnowwolf/lede
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[bot] AutoMerging: merge all upstream's changes:
* https://github.com/coolsnowwolf/lede: Revert "uboot-rockchip:doornet2 detaches from evb rk (coolsnowwolf#9812)" uboot-rockchip:doornet2 detaches from evb rk (coolsnowwolf#9812) generic: fix swconfig_leds.c in 5.18 kernel: bump 5.10 to 5.10.131 (coolsnowwolf#9807) kernel: backport upstream mtk_eth_soc patches (coolsnowwolf#9809)
Showing
44 changed files
with
3,241 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
LINUX_VERSION-5.10 = .127 | ||
LINUX_KERNEL_HASH-5.10.127 = 419233ee0b1ee1dc2be8abf1b241545d10dad19d95f237180d6ccdc0cd221580 | ||
LINUX_VERSION-5.10 = .131 | ||
LINUX_KERNEL_HASH-5.10.131 = 8bc441442c16c330a7148fe3cca9edcd98bc0fc9f68304633c7eb641770d21ce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,7 @@ Signed-off-by: Pablo Neira Ayuso <[email protected]> | |
nft_trans_table_update(trans) = true; | ||
list_add_tail(&trans->list, &ctx->net->nft.commit_list); | ||
return 0; | ||
@@ -7916,11 +7920,10 @@ static int nf_tables_commit(struct net * | ||
@@ -7923,11 +7927,10 @@ static int nf_tables_commit(struct net * | ||
switch (trans->msg_type) { | ||
case NFT_MSG_NEWTABLE: | ||
if (nft_trans_table_update(trans)) { | ||
|
@@ -86,7 +86,7 @@ Signed-off-by: Pablo Neira Ayuso <[email protected]> | |
} else { | ||
nft_clear(net, trans->ctx.table); | ||
} | ||
@@ -8133,11 +8136,9 @@ static int __nf_tables_abort(struct net | ||
@@ -8140,11 +8143,9 @@ static int __nf_tables_abort(struct net | ||
switch (trans->msg_type) { | ||
case NFT_MSG_NEWTABLE: | ||
if (nft_trans_table_update(trans)) { | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,7 +166,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
u16 addr_type = 0; | ||
u32 timestamp; | ||
u8 l4proto = 0; | ||
@@ -329,10 +372,14 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -326,10 +369,14 @@ mtk_flow_offload_replace(struct mtk_eth | ||
if (data.pppoe.num == 1) | ||
mtk_foe_entry_set_pppoe(&foe, data.pppoe.sid); | ||
|
||
|
@@ -182,15 +182,15 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
entry = kzalloc(sizeof(*entry), GFP_KERNEL); | ||
if (!entry) | ||
return -ENOMEM; | ||
@@ -346,6 +393,7 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -343,6 +390,7 @@ mtk_flow_offload_replace(struct mtk_eth | ||
} | ||
|
||
entry->hash = hash; | ||
+ entry->wed_index = wed_index; | ||
err = rhashtable_insert_fast(ð->flow_table, &entry->node, | ||
mtk_flow_ht_params); | ||
if (err < 0) | ||
@@ -356,6 +404,8 @@ clear_flow: | ||
@@ -353,6 +401,8 @@ clear_flow: | ||
mtk_foe_entry_clear(ð->ppe, hash); | ||
free: | ||
kfree(entry); | ||
|
@@ -199,7 +199,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
return err; | ||
} | ||
|
||
@@ -372,6 +422,8 @@ mtk_flow_offload_destroy(struct mtk_eth | ||
@@ -369,6 +419,8 @@ mtk_flow_offload_destroy(struct mtk_eth | ||
mtk_foe_entry_clear(ð->ppe, entry->hash); | ||
rhashtable_remove_fast(ð->flow_table, &entry->node, | ||
mtk_flow_ht_params); | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
static void | ||
mtk_flow_offload_mangle_eth(const struct flow_action_entry *act, void *eth) | ||
{ | ||
@@ -299,6 +313,9 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -296,6 +310,9 @@ mtk_flow_offload_replace(struct mtk_eth | ||
case FLOW_DISSECTOR_KEY_IPV4_ADDRS: | ||
offload_type = MTK_PPE_PKT_TYPE_IPV4_HNAPT; | ||
break; | ||
|
@@ -59,7 +59,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
default: | ||
return -EOPNOTSUPP; | ||
} | ||
@@ -334,6 +351,17 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -331,6 +348,17 @@ mtk_flow_offload_replace(struct mtk_eth | ||
mtk_flow_set_ipv4_addr(&foe, &data, false); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
|
||
--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
@@ -566,10 +566,13 @@ mtk_eth_setup_tc_block(struct net_device | ||
@@ -563,10 +563,13 @@ mtk_eth_setup_tc_block(struct net_device | ||
int mtk_eth_setup_tc(struct net_device *dev, enum tc_setup_type type, | ||
void *type_data) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,7 +103,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
|
||
--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
@@ -414,7 +414,7 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -411,7 +411,7 @@ mtk_flow_offload_replace(struct mtk_eth | ||
|
||
entry->cookie = f->cookie; | ||
timestamp = mtk_eth_timestamp(eth); | ||
|
@@ -112,7 +112,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
if (hash < 0) { | ||
err = hash; | ||
goto free; | ||
@@ -429,7 +429,7 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -426,7 +426,7 @@ mtk_flow_offload_replace(struct mtk_eth | ||
|
||
return 0; | ||
clear_flow: | ||
|
@@ -121,7 +121,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
free: | ||
kfree(entry); | ||
if (wed_index >= 0) | ||
@@ -447,7 +447,7 @@ mtk_flow_offload_destroy(struct mtk_eth | ||
@@ -444,7 +444,7 @@ mtk_flow_offload_destroy(struct mtk_eth | ||
if (!entry) | ||
return -ENOENT; | ||
|
||
|
@@ -130,7 +130,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
rhashtable_remove_fast(ð->flow_table, &entry->node, | ||
mtk_flow_ht_params); | ||
if (entry->wed_index >= 0) | ||
@@ -469,7 +469,7 @@ mtk_flow_offload_stats(struct mtk_eth *e | ||
@@ -466,7 +466,7 @@ mtk_flow_offload_stats(struct mtk_eth *e | ||
if (!entry) | ||
return -ENOENT; | ||
|
||
|
@@ -139,7 +139,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
if (timestamp < 0) | ||
return -ETIMEDOUT; | ||
|
||
@@ -525,7 +525,7 @@ mtk_eth_setup_tc_block(struct net_device | ||
@@ -522,7 +522,7 @@ mtk_eth_setup_tc_block(struct net_device | ||
struct flow_block_cb *block_cb; | ||
flow_setup_cb_t *cb; | ||
|
||
|
@@ -148,7 +148,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
return -EOPNOTSUPP; | ||
|
||
if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) | ||
@@ -577,7 +577,7 @@ int mtk_eth_setup_tc(struct net_device * | ||
@@ -574,7 +574,7 @@ int mtk_eth_setup_tc(struct net_device * | ||
|
||
int mtk_eth_offload_init(struct mtk_eth *eth) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -360,7 +360,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
int i; | ||
|
||
if (rhashtable_lookup(ð->flow_table, &f->cookie, mtk_flow_ht_params)) | ||
@@ -413,23 +398,21 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -410,23 +395,21 @@ mtk_flow_offload_replace(struct mtk_eth | ||
return -ENOMEM; | ||
|
||
entry->cookie = f->cookie; | ||
|
@@ -392,7 +392,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
free: | ||
kfree(entry); | ||
if (wed_index >= 0) | ||
@@ -447,7 +430,7 @@ mtk_flow_offload_destroy(struct mtk_eth | ||
@@ -444,7 +427,7 @@ mtk_flow_offload_destroy(struct mtk_eth | ||
if (!entry) | ||
return -ENOENT; | ||
|
||
|
@@ -401,15 +401,15 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
rhashtable_remove_fast(ð->flow_table, &entry->node, | ||
mtk_flow_ht_params); | ||
if (entry->wed_index >= 0) | ||
@@ -461,7 +444,6 @@ static int | ||
@@ -458,7 +441,6 @@ static int | ||
mtk_flow_offload_stats(struct mtk_eth *eth, struct flow_cls_offload *f) | ||
{ | ||
struct mtk_flow_entry *entry; | ||
- int timestamp; | ||
u32 idle; | ||
|
||
entry = rhashtable_lookup(ð->flow_table, &f->cookie, | ||
@@ -469,11 +451,7 @@ mtk_flow_offload_stats(struct mtk_eth *e | ||
@@ -466,11 +448,7 @@ mtk_flow_offload_stats(struct mtk_eth *e | ||
if (!entry) | ||
return -ENOENT; | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -452,7 +452,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
struct { | ||
u16 id; | ||
__be16 proto; | ||
@@ -260,9 +262,45 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -257,9 +259,45 @@ mtk_flow_offload_replace(struct mtk_eth | ||
return -EOPNOTSUPP; | ||
} | ||
|
||
|
@@ -498,7 +498,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
if (act->mangle.htype == FLOW_ACT_MANGLE_HDR_TYPE_ETH) | ||
mtk_flow_offload_mangle_eth(act, &data.eth); | ||
break; | ||
@@ -294,17 +332,6 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -291,17 +329,6 @@ mtk_flow_offload_replace(struct mtk_eth | ||
} | ||
} | ||
|
||
|
@@ -516,7 +516,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
if (!is_valid_ether_addr(data.eth.h_source) || | ||
!is_valid_ether_addr(data.eth.h_dest)) | ||
return -EINVAL; | ||
@@ -318,10 +345,13 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -315,10 +342,13 @@ mtk_flow_offload_replace(struct mtk_eth | ||
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) { | ||
struct flow_match_ports ports; | ||
|
||
|
@@ -531,7 +531,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
return -EOPNOTSUPP; | ||
} | ||
|
||
@@ -351,6 +381,9 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -348,6 +378,9 @@ mtk_flow_offload_replace(struct mtk_eth | ||
if (act->id != FLOW_ACTION_MANGLE) | ||
continue; | ||
|
||
|
@@ -541,7 +541,7 @@ Signed-off-by: Felix Fietkau <[email protected]> | |
switch (act->mangle.htype) { | ||
case FLOW_ACT_MANGLE_HDR_TYPE_TCP: | ||
case FLOW_ACT_MANGLE_HDR_TYPE_UDP: | ||
@@ -376,6 +409,9 @@ mtk_flow_offload_replace(struct mtk_eth | ||
@@ -373,6 +406,9 @@ mtk_flow_offload_replace(struct mtk_eth | ||
return err; | ||
} | ||
|
||
|
56 changes: 56 additions & 0 deletions
56
...ric/backport-5.15/702-v5.19-11-net-ethernet-mtk_eth_soc-wed-fix-sparse-endian-warni.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
From: Felix Fietkau <[email protected]> | ||
Date: Fri, 8 Apr 2022 10:59:45 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc/wed: fix sparse endian warnings | ||
|
||
Descriptor fields are little-endian | ||
|
||
Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") | ||
Reported-by: kernel test robot <[email protected]> | ||
Signed-off-by: Felix Fietkau <[email protected]> | ||
Signed-off-by: David S. Miller <[email protected]> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_wed.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c | ||
@@ -144,16 +144,17 @@ mtk_wed_buffer_alloc(struct mtk_wed_devi | ||
|
||
for (s = 0; s < MTK_WED_BUF_PER_PAGE; s++) { | ||
u32 txd_size; | ||
+ u32 ctrl; | ||
|
||
txd_size = dev->wlan.init_buf(buf, buf_phys, token++); | ||
|
||
- desc->buf0 = buf_phys; | ||
- desc->buf1 = buf_phys + txd_size; | ||
- desc->ctrl = FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN0, | ||
- txd_size) | | ||
- FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1, | ||
- MTK_WED_BUF_SIZE - txd_size) | | ||
- MTK_WDMA_DESC_CTRL_LAST_SEG1; | ||
+ desc->buf0 = cpu_to_le32(buf_phys); | ||
+ desc->buf1 = cpu_to_le32(buf_phys + txd_size); | ||
+ ctrl = FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN0, txd_size) | | ||
+ FIELD_PREP(MTK_WDMA_DESC_CTRL_LEN1, | ||
+ MTK_WED_BUF_SIZE - txd_size) | | ||
+ MTK_WDMA_DESC_CTRL_LAST_SEG1; | ||
+ desc->ctrl = cpu_to_le32(ctrl); | ||
desc->info = 0; | ||
desc++; | ||
|
||
@@ -184,12 +185,14 @@ mtk_wed_free_buffer(struct mtk_wed_devic | ||
|
||
for (i = 0, page_idx = 0; i < dev->buf_ring.size; i += MTK_WED_BUF_PER_PAGE) { | ||
void *page = page_list[page_idx++]; | ||
+ dma_addr_t buf_addr; | ||
|
||
if (!page) | ||
break; | ||
|
||
- dma_unmap_page(dev->hw->dev, desc[i].buf0, | ||
- PAGE_SIZE, DMA_BIDIRECTIONAL); | ||
+ buf_addr = le32_to_cpu(desc[i].buf0); | ||
+ dma_unmap_page(dev->hw->dev, buf_addr, PAGE_SIZE, | ||
+ DMA_BIDIRECTIONAL); | ||
__free_page(page); | ||
} | ||
|
25 changes: 25 additions & 0 deletions
25
...ric/backport-5.15/702-v5.19-12-net-ethernet-mtk_eth_soc-fix-return-value-check-in-m.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From: Yang Yingliang <[email protected]> | ||
Date: Fri, 8 Apr 2022 11:22:46 +0800 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: fix return value check in | ||
mtk_wed_add_hw() | ||
|
||
If syscon_regmap_lookup_by_phandle() fails, it never return NULL pointer, | ||
change the check to IS_ERR(). | ||
|
||
Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") | ||
Reported-by: Hulk Robot <[email protected]> | ||
Signed-off-by: Yang Yingliang <[email protected]> | ||
Signed-off-by: David S. Miller <[email protected]> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_wed.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c | ||
@@ -816,7 +816,7 @@ void mtk_wed_add_hw(struct device_node * | ||
return; | ||
|
||
regs = syscon_regmap_lookup_by_phandle(np, NULL); | ||
- if (!regs) | ||
+ if (IS_ERR(regs)) | ||
return; | ||
|
||
rcu_assign_pointer(mtk_soc_wed_ops, &wed_ops); |
35 changes: 35 additions & 0 deletions
35
...ric/backport-5.15/702-v5.19-13-net-ethernet-mtk_eth_soc-use-standard-property-for-c.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
From: Lorenzo Bianconi <[email protected]> | ||
Date: Mon, 11 Apr 2022 12:13:25 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: use standard property for | ||
cci-control-port | ||
|
||
Rely on standard cci-control-port property to identify CCI port | ||
reference. | ||
Update mt7622 dts binding. | ||
|
||
Signed-off-by: Lorenzo Bianconi <[email protected]> | ||
Signed-off-by: David S. Miller <[email protected]> | ||
--- | ||
|
||
--- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi | ||
+++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi | ||
@@ -962,7 +962,7 @@ | ||
power-domains = <&scpsys MT7622_POWER_DOMAIN_ETHSYS>; | ||
mediatek,ethsys = <ðsys>; | ||
mediatek,sgmiisys = <&sgmiisys>; | ||
- mediatek,cci-control = <&cci_control2>; | ||
+ cci-control-port = <&cci_control2>; | ||
mediatek,wed = <&wed0>, <&wed1>; | ||
mediatek,pcie-mirror = <&pcie_mirror>; | ||
mediatek,hifsys = <&hifsys>; | ||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -3185,7 +3185,7 @@ static int mtk_probe(struct platform_dev | ||
struct regmap *cci; | ||
|
||
cci = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, | ||
- "mediatek,cci-control"); | ||
+ "cci-control-port"); | ||
/* enable CPU/bus coherency */ | ||
if (!IS_ERR(cci)) | ||
regmap_write(cci, 0, 3); |
33 changes: 33 additions & 0 deletions
33
...ric/backport-5.15/702-v5.19-14-net-ethernet-mtk_eth_soc-use-after-free-in-__mtk_ppe.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
From: Dan Carpenter <[email protected]> | ||
Date: Tue, 12 Apr 2022 12:24:19 +0300 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: use after free in | ||
__mtk_ppe_check_skb() | ||
|
||
The __mtk_foe_entry_clear() function frees "entry" so we have to use | ||
the _safe() version of hlist_for_each_entry() to prevent a use after | ||
free. | ||
|
||
Fixes: 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac address based offload entries") | ||
Signed-off-by: Dan Carpenter <[email protected]> | ||
Signed-off-by: David S. Miller <[email protected]> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_ppe.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.c | ||
@@ -600,6 +600,7 @@ void __mtk_ppe_check_skb(struct mtk_ppe | ||
struct mtk_foe_entry *hwe = &ppe->foe_table[hash]; | ||
struct mtk_flow_entry *entry; | ||
struct mtk_foe_bridge key = {}; | ||
+ struct hlist_node *n; | ||
struct ethhdr *eh; | ||
bool found = false; | ||
u8 *tag; | ||
@@ -609,7 +610,7 @@ void __mtk_ppe_check_skb(struct mtk_ppe | ||
if (FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) == MTK_FOE_STATE_BIND) | ||
goto out; | ||
|
||
- hlist_for_each_entry(entry, head, list) { | ||
+ hlist_for_each_entry_safe(entry, n, head, list) { | ||
if (entry->type == MTK_FLOW_TYPE_L2_SUBFLOW) { | ||
if (unlikely(FIELD_GET(MTK_FOE_IB1_STATE, hwe->ib1) == | ||
MTK_FOE_STATE_BIND)) |
22 changes: 22 additions & 0 deletions
22
...ric/backport-5.15/702-v5.19-15-net-ethernet-mtk_eth_soc-add-check-for-allocation-fa.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
From: Dan Carpenter <[email protected]> | ||
Date: Thu, 21 Apr 2022 18:49:02 +0300 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: add check for allocation failure | ||
|
||
Check if the kzalloc() failed. | ||
|
||
Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") | ||
Signed-off-by: Dan Carpenter <[email protected]> | ||
Signed-off-by: David S. Miller <[email protected]> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_wed.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_wed.c | ||
@@ -827,6 +827,8 @@ void mtk_wed_add_hw(struct device_node * | ||
goto unlock; | ||
|
||
hw = kzalloc(sizeof(*hw), GFP_KERNEL); | ||
+ if (!hw) | ||
+ goto unlock; | ||
hw->node = np; | ||
hw->regs = regs; | ||
hw->eth = eth; |
26 changes: 26 additions & 0 deletions
26
...ric/backport-5.15/702-v5.19-16-eth-mtk_eth_soc-silence-the-GCC-12-array-bounds-warn.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From: Jakub Kicinski <kuba@kernel.org> | ||
Date: Fri, 20 May 2022 12:56:03 -0700 | ||
Subject: [PATCH] eth: mtk_eth_soc: silence the GCC 12 array-bounds warning | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/Makefile | ||
+++ b/drivers/net/ethernet/mediatek/Makefile | ||
@@ -11,3 +11,8 @@ mtk_eth-$(CONFIG_NET_MEDIATEK_SOC_WED) + | ||
endif | ||
obj-$(CONFIG_NET_MEDIATEK_SOC_WED) += mtk_wed_ops.o | ||
obj-$(CONFIG_NET_MEDIATEK_STAR_EMAC) += mtk_star_emac.o | ||
+ | ||
+# FIXME: temporarily silence -Warray-bounds on non W=1+ builds | ||
+ifndef KBUILD_EXTRA_WARN | ||
+CFLAGS_mtk_ppe.o += -Wno-array-bounds | ||
+endif |
52 changes: 52 additions & 0 deletions
52
...ric/backport-5.15/702-v5.19-17-net-ethernet-mtk_eth_soc-rely-on-GFP_KERNEL-for-dma_.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:26 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on GFP_KERNEL for | ||
dma_alloc_coherent 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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -845,7 +845,7 @@ static int mtk_init_fq_dma(struct mtk_et | ||
eth->scratch_ring = dma_alloc_coherent(eth->dma_dev, | ||
cnt * sizeof(struct mtk_tx_dma), | ||
ð->phy_scratch_ring, | ||
- GFP_ATOMIC); | ||
+ GFP_KERNEL); | ||
if (unlikely(!eth->scratch_ring)) | ||
return -ENOMEM; | ||
|
||
@@ -1623,7 +1623,7 @@ static int mtk_tx_alloc(struct mtk_eth * | ||
goto no_tx_mem; | ||
|
||
ring->dma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz, | ||
- &ring->phys, GFP_ATOMIC); | ||
+ &ring->phys, GFP_KERNEL); | ||
if (!ring->dma) | ||
goto no_tx_mem; | ||
|
||
@@ -1641,8 +1641,7 @@ static int mtk_tx_alloc(struct mtk_eth * | ||
*/ | ||
if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { | ||
ring->dma_pdma = dma_alloc_coherent(eth->dma_dev, MTK_DMA_SIZE * sz, | ||
- &ring->phys_pdma, | ||
- GFP_ATOMIC); | ||
+ &ring->phys_pdma, GFP_KERNEL); | ||
if (!ring->dma_pdma) | ||
goto no_tx_mem; | ||
|
||
@@ -1757,7 +1756,7 @@ static int mtk_rx_alloc(struct mtk_eth * | ||
|
||
ring->dma = dma_alloc_coherent(eth->dma_dev, | ||
rx_dma_size * sizeof(*ring->dma), | ||
- &ring->phys, GFP_ATOMIC); | ||
+ &ring->phys, GFP_KERNEL); | ||
if (!ring->dma) | ||
return -ENOMEM; | ||
|
206 changes: 206 additions & 0 deletions
206
...ric/backport-5.15/702-v5.19-18-net-ethernet-mtk_eth_soc-move-tx-dma-desc-configurat.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:27 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: move tx dma desc configuration in | ||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -971,18 +971,51 @@ static void setup_tx_buf(struct mtk_eth | ||
} | ||
} | ||
|
||
+static void mtk_tx_set_dma_desc(struct net_device *dev, struct mtk_tx_dma *desc, | ||
+ struct mtk_tx_dma_desc_info *info) | ||
+{ | ||
+ struct mtk_mac *mac = netdev_priv(dev); | ||
+ u32 data; | ||
+ | ||
+ WRITE_ONCE(desc->txd1, info->addr); | ||
+ | ||
+ data = TX_DMA_SWC | TX_DMA_PLEN0(info->size); | ||
+ if (info->last) | ||
+ data |= TX_DMA_LS0; | ||
+ WRITE_ONCE(desc->txd3, data); | ||
+ | ||
+ data = (mac->id + 1) << TX_DMA_FPORT_SHIFT; /* forward port */ | ||
+ if (info->first) { | ||
+ if (info->gso) | ||
+ data |= TX_DMA_TSO; | ||
+ /* tx checksum offload */ | ||
+ if (info->csum) | ||
+ data |= TX_DMA_CHKSUM; | ||
+ /* vlan header offload */ | ||
+ if (info->vlan) | ||
+ data |= TX_DMA_INS_VLAN | info->vlan_tci; | ||
+ } | ||
+ WRITE_ONCE(desc->txd4, data); | ||
+} | ||
+ | ||
static int mtk_tx_map(struct sk_buff *skb, struct net_device *dev, | ||
int tx_num, struct mtk_tx_ring *ring, bool gso) | ||
{ | ||
+ struct mtk_tx_dma_desc_info txd_info = { | ||
+ .size = skb_headlen(skb), | ||
+ .gso = gso, | ||
+ .csum = skb->ip_summed == CHECKSUM_PARTIAL, | ||
+ .vlan = skb_vlan_tag_present(skb), | ||
+ .vlan_tci = skb_vlan_tag_get(skb), | ||
+ .first = true, | ||
+ .last = !skb_is_nonlinear(skb), | ||
+ }; | ||
struct mtk_mac *mac = netdev_priv(dev); | ||
struct mtk_eth *eth = mac->hw; | ||
struct mtk_tx_dma *itxd, *txd; | ||
struct mtk_tx_dma *itxd_pdma, *txd_pdma; | ||
struct mtk_tx_buf *itx_buf, *tx_buf; | ||
- dma_addr_t mapped_addr; | ||
- unsigned int nr_frags; | ||
int i, n_desc = 1; | ||
- u32 txd4 = 0, fport; | ||
int k = 0; | ||
|
||
itxd = ring->next_free; | ||
@@ -990,49 +1023,32 @@ static int mtk_tx_map(struct sk_buff *sk | ||
if (itxd == ring->last_free) | ||
return -ENOMEM; | ||
|
||
- /* set the forward port */ | ||
- fport = (mac->id + 1) << TX_DMA_FPORT_SHIFT; | ||
- txd4 |= fport; | ||
- | ||
itx_buf = mtk_desc_to_tx_buf(ring, itxd); | ||
memset(itx_buf, 0, sizeof(*itx_buf)); | ||
|
||
- if (gso) | ||
- txd4 |= TX_DMA_TSO; | ||
- | ||
- /* TX Checksum offload */ | ||
- if (skb->ip_summed == CHECKSUM_PARTIAL) | ||
- txd4 |= TX_DMA_CHKSUM; | ||
- | ||
- /* VLAN header offload */ | ||
- if (skb_vlan_tag_present(skb)) | ||
- txd4 |= TX_DMA_INS_VLAN | skb_vlan_tag_get(skb); | ||
- | ||
- mapped_addr = dma_map_single(eth->dma_dev, skb->data, | ||
- skb_headlen(skb), DMA_TO_DEVICE); | ||
- if (unlikely(dma_mapping_error(eth->dma_dev, mapped_addr))) | ||
+ txd_info.addr = dma_map_single(eth->dma_dev, skb->data, txd_info.size, | ||
+ DMA_TO_DEVICE); | ||
+ if (unlikely(dma_mapping_error(eth->dma_dev, txd_info.addr))) | ||
return -ENOMEM; | ||
|
||
- WRITE_ONCE(itxd->txd1, mapped_addr); | ||
+ mtk_tx_set_dma_desc(dev, itxd, &txd_info); | ||
+ | ||
itx_buf->flags |= MTK_TX_FLAGS_SINGLE0; | ||
itx_buf->flags |= (!mac->id) ? MTK_TX_FLAGS_FPORT0 : | ||
MTK_TX_FLAGS_FPORT1; | ||
- setup_tx_buf(eth, itx_buf, itxd_pdma, mapped_addr, skb_headlen(skb), | ||
+ setup_tx_buf(eth, itx_buf, itxd_pdma, txd_info.addr, txd_info.size, | ||
k++); | ||
|
||
/* TX SG offload */ | ||
txd = itxd; | ||
txd_pdma = qdma_to_pdma(ring, txd); | ||
- nr_frags = skb_shinfo(skb)->nr_frags; | ||
|
||
- for (i = 0; i < nr_frags; i++) { | ||
+ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | ||
skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
unsigned int offset = 0; | ||
int frag_size = skb_frag_size(frag); | ||
|
||
while (frag_size) { | ||
- bool last_frag = false; | ||
- unsigned int frag_map_size; | ||
bool new_desc = true; | ||
|
||
if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA) || | ||
@@ -1047,23 +1063,17 @@ static int mtk_tx_map(struct sk_buff *sk | ||
new_desc = false; | ||
} | ||
|
||
- | ||
- frag_map_size = min(frag_size, MTK_TX_DMA_BUF_LEN); | ||
- mapped_addr = skb_frag_dma_map(eth->dma_dev, frag, offset, | ||
- frag_map_size, | ||
- DMA_TO_DEVICE); | ||
- if (unlikely(dma_mapping_error(eth->dma_dev, mapped_addr))) | ||
+ memset(&txd_info, 0, sizeof(struct mtk_tx_dma_desc_info)); | ||
+ txd_info.size = min(frag_size, MTK_TX_DMA_BUF_LEN); | ||
+ txd_info.last = i == skb_shinfo(skb)->nr_frags - 1 && | ||
+ !(frag_size - txd_info.size); | ||
+ txd_info.addr = skb_frag_dma_map(eth->dma_dev, frag, | ||
+ offset, txd_info.size, | ||
+ DMA_TO_DEVICE); | ||
+ if (unlikely(dma_mapping_error(eth->dma_dev, txd_info.addr))) | ||
goto err_dma; | ||
|
||
- if (i == nr_frags - 1 && | ||
- (frag_size - frag_map_size) == 0) | ||
- last_frag = true; | ||
- | ||
- WRITE_ONCE(txd->txd1, mapped_addr); | ||
- WRITE_ONCE(txd->txd3, (TX_DMA_SWC | | ||
- TX_DMA_PLEN0(frag_map_size) | | ||
- last_frag * TX_DMA_LS0)); | ||
- WRITE_ONCE(txd->txd4, fport); | ||
+ mtk_tx_set_dma_desc(dev, txd, &txd_info); | ||
|
||
tx_buf = mtk_desc_to_tx_buf(ring, txd); | ||
if (new_desc) | ||
@@ -1073,20 +1083,17 @@ static int mtk_tx_map(struct sk_buff *sk | ||
tx_buf->flags |= (!mac->id) ? MTK_TX_FLAGS_FPORT0 : | ||
MTK_TX_FLAGS_FPORT1; | ||
|
||
- setup_tx_buf(eth, tx_buf, txd_pdma, mapped_addr, | ||
- frag_map_size, k++); | ||
+ setup_tx_buf(eth, tx_buf, txd_pdma, txd_info.addr, | ||
+ txd_info.size, k++); | ||
|
||
- frag_size -= frag_map_size; | ||
- offset += frag_map_size; | ||
+ frag_size -= txd_info.size; | ||
+ offset += txd_info.size; | ||
} | ||
} | ||
|
||
/* store skb to cleanup */ | ||
itx_buf->skb = skb; | ||
|
||
- WRITE_ONCE(itxd->txd4, txd4); | ||
- WRITE_ONCE(itxd->txd3, (TX_DMA_SWC | TX_DMA_PLEN0(skb_headlen(skb)) | | ||
- (!nr_frags * TX_DMA_LS0))); | ||
if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { | ||
if (k & 0x1) | ||
txd_pdma->txd2 |= TX_DMA_LS0; | ||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
@@ -842,6 +842,17 @@ enum mkt_eth_capabilities { | ||
MTK_MUX_U3_GMAC2_TO_QPHY | \ | ||
MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA) | ||
|
||
+struct mtk_tx_dma_desc_info { | ||
+ dma_addr_t addr; | ||
+ u32 size; | ||
+ u16 vlan_tci; | ||
+ u8 gso:1; | ||
+ u8 csum:1; | ||
+ u8 vlan:1; | ||
+ u8 first:1; | ||
+ u8 last:1; | ||
+}; | ||
+ | ||
/* struct mtk_eth_data - This is the structure holding all differences | ||
* among various plaforms | ||
* @ana_rgc3: The offset for register ANA_RGC3 related to |
167 changes: 167 additions & 0 deletions
167
...ric/backport-5.15/702-v5.19-19-net-ethernet-mtk_eth_soc-add-txd_size-to-mtk_soc_dat.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:28 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: add txd_size to mtk_soc_data | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -837,20 +837,20 @@ static inline bool mtk_rx_get_desc(struc | ||
/* the qdma core needs scratch memory to be setup */ | ||
static int mtk_init_fq_dma(struct mtk_eth *eth) | ||
{ | ||
+ const struct mtk_soc_data *soc = eth->soc; | ||
dma_addr_t phy_ring_tail; | ||
int cnt = MTK_DMA_SIZE; | ||
dma_addr_t dma_addr; | ||
int i; | ||
|
||
eth->scratch_ring = dma_alloc_coherent(eth->dma_dev, | ||
- cnt * sizeof(struct mtk_tx_dma), | ||
+ cnt * soc->txrx.txd_size, | ||
ð->phy_scratch_ring, | ||
GFP_KERNEL); | ||
if (unlikely(!eth->scratch_ring)) | ||
return -ENOMEM; | ||
|
||
- eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE, | ||
- GFP_KERNEL); | ||
+ eth->scratch_head = kcalloc(cnt, MTK_QDMA_PAGE_SIZE, GFP_KERNEL); | ||
if (unlikely(!eth->scratch_head)) | ||
return -ENOMEM; | ||
|
||
@@ -860,16 +860,19 @@ static int mtk_init_fq_dma(struct mtk_et | ||
if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr))) | ||
return -ENOMEM; | ||
|
||
- phy_ring_tail = eth->phy_scratch_ring + | ||
- (sizeof(struct mtk_tx_dma) * (cnt - 1)); | ||
+ phy_ring_tail = eth->phy_scratch_ring + soc->txrx.txd_size * (cnt - 1); | ||
|
||
for (i = 0; i < cnt; i++) { | ||
- eth->scratch_ring[i].txd1 = | ||
- (dma_addr + (i * MTK_QDMA_PAGE_SIZE)); | ||
+ struct mtk_tx_dma *txd; | ||
+ | ||
+ txd = (void *)eth->scratch_ring + i * soc->txrx.txd_size; | ||
+ txd->txd1 = dma_addr + i * MTK_QDMA_PAGE_SIZE; | ||
if (i < cnt - 1) | ||
- eth->scratch_ring[i].txd2 = (eth->phy_scratch_ring + | ||
- ((i + 1) * sizeof(struct mtk_tx_dma))); | ||
- eth->scratch_ring[i].txd3 = TX_DMA_SDL(MTK_QDMA_PAGE_SIZE); | ||
+ txd->txd2 = eth->phy_scratch_ring + | ||
+ (i + 1) * soc->txrx.txd_size; | ||
+ | ||
+ txd->txd3 = TX_DMA_PLEN0(MTK_QDMA_PAGE_SIZE); | ||
+ txd->txd4 = 0; | ||
} | ||
|
||
mtk_w32(eth, eth->phy_scratch_ring, MTK_QDMA_FQ_HEAD); | ||
@@ -2169,6 +2172,7 @@ static int mtk_dma_init(struct mtk_eth * | ||
|
||
static void mtk_dma_free(struct mtk_eth *eth) | ||
{ | ||
+ const struct mtk_soc_data *soc = eth->soc; | ||
int i; | ||
|
||
for (i = 0; i < MTK_MAC_COUNT; i++) | ||
@@ -2176,9 +2180,8 @@ static void mtk_dma_free(struct mtk_eth | ||
netdev_reset_queue(eth->netdev[i]); | ||
if (eth->scratch_ring) { | ||
dma_free_coherent(eth->dma_dev, | ||
- MTK_DMA_SIZE * sizeof(struct mtk_tx_dma), | ||
- eth->scratch_ring, | ||
- eth->phy_scratch_ring); | ||
+ MTK_DMA_SIZE * soc->txrx.txd_size, | ||
+ eth->scratch_ring, eth->phy_scratch_ring); | ||
eth->scratch_ring = NULL; | ||
eth->phy_scratch_ring = 0; | ||
} | ||
@@ -3388,6 +3391,9 @@ static const struct mtk_soc_data mt2701_ | ||
.hw_features = MTK_HW_FEATURES, | ||
.required_clks = MT7623_CLKS_BITMAP, | ||
.required_pctl = true, | ||
+ .txrx = { | ||
+ .txd_size = sizeof(struct mtk_tx_dma), | ||
+ }, | ||
}; | ||
|
||
static const struct mtk_soc_data mt7621_data = { | ||
@@ -3396,6 +3402,9 @@ static const struct mtk_soc_data mt7621_ | ||
.required_clks = MT7621_CLKS_BITMAP, | ||
.required_pctl = false, | ||
.offload_version = 2, | ||
+ .txrx = { | ||
+ .txd_size = sizeof(struct mtk_tx_dma), | ||
+ }, | ||
}; | ||
|
||
static const struct mtk_soc_data mt7622_data = { | ||
@@ -3405,6 +3414,9 @@ static const struct mtk_soc_data mt7622_ | ||
.required_clks = MT7622_CLKS_BITMAP, | ||
.required_pctl = false, | ||
.offload_version = 2, | ||
+ .txrx = { | ||
+ .txd_size = sizeof(struct mtk_tx_dma), | ||
+ }, | ||
}; | ||
|
||
static const struct mtk_soc_data mt7623_data = { | ||
@@ -3413,6 +3425,9 @@ static const struct mtk_soc_data mt7623_ | ||
.required_clks = MT7623_CLKS_BITMAP, | ||
.required_pctl = true, | ||
.offload_version = 2, | ||
+ .txrx = { | ||
+ .txd_size = sizeof(struct mtk_tx_dma), | ||
+ }, | ||
}; | ||
|
||
static const struct mtk_soc_data mt7629_data = { | ||
@@ -3421,6 +3436,9 @@ static const struct mtk_soc_data mt7629_ | ||
.hw_features = MTK_HW_FEATURES, | ||
.required_clks = MT7629_CLKS_BITMAP, | ||
.required_pctl = false, | ||
+ .txrx = { | ||
+ .txd_size = sizeof(struct mtk_tx_dma), | ||
+ }, | ||
}; | ||
|
||
static const struct mtk_soc_data rt5350_data = { | ||
@@ -3428,6 +3446,9 @@ static const struct mtk_soc_data rt5350_ | ||
.hw_features = MTK_HW_FEATURES_MT7628, | ||
.required_clks = MT7628_CLKS_BITMAP, | ||
.required_pctl = false, | ||
+ .txrx = { | ||
+ .txd_size = sizeof(struct mtk_tx_dma), | ||
+ }, | ||
}; | ||
|
||
const struct of_device_id of_mtk_match[] = { | ||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
@@ -863,6 +863,7 @@ struct mtk_tx_dma_desc_info { | ||
* the target SoC | ||
* @required_pctl A bool value to show whether the SoC requires | ||
* the extra setup for those pins used by GMAC. | ||
+ * @txd_size Tx DMA descriptor size. | ||
*/ | ||
struct mtk_soc_data { | ||
u32 ana_rgc3; | ||
@@ -871,6 +872,9 @@ struct mtk_soc_data { | ||
bool required_pctl; | ||
u8 offload_version; | ||
netdev_features_t hw_features; | ||
+ struct { | ||
+ u32 txd_size; | ||
+ } txrx; | ||
}; | ||
|
||
/* currently no SoC has more than 2 macs */ |
78 changes: 78 additions & 0 deletions
78
...ric/backport-5.15/702-v5.19-20-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-mtk_tx_.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:29 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size in | ||
mtk_tx_alloc/mtk_tx_clean | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -1624,8 +1624,10 @@ static int mtk_napi_rx(struct napi_struc | ||
|
||
static int mtk_tx_alloc(struct mtk_eth *eth) | ||
{ | ||
+ const struct mtk_soc_data *soc = eth->soc; | ||
struct mtk_tx_ring *ring = ð->tx_ring; | ||
- int i, sz = sizeof(*ring->dma); | ||
+ int i, sz = soc->txrx.txd_size; | ||
+ struct mtk_tx_dma *txd; | ||
|
||
ring->buf = kcalloc(MTK_DMA_SIZE, sizeof(*ring->buf), | ||
GFP_KERNEL); | ||
@@ -1641,8 +1643,10 @@ static int mtk_tx_alloc(struct mtk_eth * | ||
int next = (i + 1) % MTK_DMA_SIZE; | ||
u32 next_ptr = ring->phys + next * sz; | ||
|
||
- ring->dma[i].txd2 = next_ptr; | ||
- ring->dma[i].txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; | ||
+ txd = (void *)ring->dma + i * sz; | ||
+ txd->txd2 = next_ptr; | ||
+ txd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; | ||
+ txd->txd4 = 0; | ||
} | ||
|
||
/* On MT7688 (PDMA only) this driver uses the ring->dma structs | ||
@@ -1664,7 +1668,7 @@ static int mtk_tx_alloc(struct mtk_eth * | ||
ring->dma_size = MTK_DMA_SIZE; | ||
atomic_set(&ring->free_count, MTK_DMA_SIZE - 2); | ||
ring->next_free = &ring->dma[0]; | ||
- ring->last_free = &ring->dma[MTK_DMA_SIZE - 1]; | ||
+ ring->last_free = (void *)txd; | ||
ring->last_free_ptr = (u32)(ring->phys + ((MTK_DMA_SIZE - 1) * sz)); | ||
ring->thresh = MAX_SKB_FRAGS; | ||
|
||
@@ -1697,6 +1701,7 @@ no_tx_mem: | ||
|
||
static void mtk_tx_clean(struct mtk_eth *eth) | ||
{ | ||
+ const struct mtk_soc_data *soc = eth->soc; | ||
struct mtk_tx_ring *ring = ð->tx_ring; | ||
int i; | ||
|
||
@@ -1709,17 +1714,15 @@ static void mtk_tx_clean(struct mtk_eth | ||
|
||
if (ring->dma) { | ||
dma_free_coherent(eth->dma_dev, | ||
- MTK_DMA_SIZE * sizeof(*ring->dma), | ||
- ring->dma, | ||
- ring->phys); | ||
+ MTK_DMA_SIZE * soc->txrx.txd_size, | ||
+ ring->dma, ring->phys); | ||
ring->dma = NULL; | ||
} | ||
|
||
if (ring->dma_pdma) { | ||
dma_free_coherent(eth->dma_dev, | ||
- MTK_DMA_SIZE * sizeof(*ring->dma_pdma), | ||
- ring->dma_pdma, | ||
- ring->phys_pdma); | ||
+ MTK_DMA_SIZE * soc->txrx.txd_size, | ||
+ ring->dma_pdma, ring->phys_pdma); | ||
ring->dma_pdma = NULL; | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
...ric/backport-5.15/702-v5.19-21-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-mtk_des.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:30 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size in | ||
mtk_desc_to_tx_buf | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -890,10 +890,11 @@ static inline void *mtk_qdma_phys_to_vir | ||
return ret + (desc - ring->phys); | ||
} | ||
|
||
-static inline struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring, | ||
- struct mtk_tx_dma *txd) | ||
+static struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring, | ||
+ struct mtk_tx_dma *txd, | ||
+ u32 txd_size) | ||
{ | ||
- int idx = txd - ring->dma; | ||
+ int idx = ((void *)txd - (void *)ring->dma) / txd_size; | ||
|
||
return &ring->buf[idx]; | ||
} | ||
@@ -1015,6 +1016,7 @@ static int mtk_tx_map(struct sk_buff *sk | ||
}; | ||
struct mtk_mac *mac = netdev_priv(dev); | ||
struct mtk_eth *eth = mac->hw; | ||
+ const struct mtk_soc_data *soc = eth->soc; | ||
struct mtk_tx_dma *itxd, *txd; | ||
struct mtk_tx_dma *itxd_pdma, *txd_pdma; | ||
struct mtk_tx_buf *itx_buf, *tx_buf; | ||
@@ -1026,7 +1028,7 @@ static int mtk_tx_map(struct sk_buff *sk | ||
if (itxd == ring->last_free) | ||
return -ENOMEM; | ||
|
||
- itx_buf = mtk_desc_to_tx_buf(ring, itxd); | ||
+ itx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->txrx.txd_size); | ||
memset(itx_buf, 0, sizeof(*itx_buf)); | ||
|
||
txd_info.addr = dma_map_single(eth->dma_dev, skb->data, txd_info.size, | ||
@@ -1054,7 +1056,7 @@ static int mtk_tx_map(struct sk_buff *sk | ||
while (frag_size) { | ||
bool new_desc = true; | ||
|
||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA) || | ||
+ if (MTK_HAS_CAPS(soc->caps, MTK_QDMA) || | ||
(i & 0x1)) { | ||
txd = mtk_qdma_phys_to_virt(ring, txd->txd2); | ||
txd_pdma = qdma_to_pdma(ring, txd); | ||
@@ -1078,7 +1080,8 @@ static int mtk_tx_map(struct sk_buff *sk | ||
|
||
mtk_tx_set_dma_desc(dev, txd, &txd_info); | ||
|
||
- tx_buf = mtk_desc_to_tx_buf(ring, txd); | ||
+ tx_buf = mtk_desc_to_tx_buf(ring, txd, | ||
+ soc->txrx.txd_size); | ||
if (new_desc) | ||
memset(tx_buf, 0, sizeof(*tx_buf)); | ||
tx_buf->skb = (struct sk_buff *)MTK_DMA_DUMMY_DESC; | ||
@@ -1097,7 +1100,7 @@ static int mtk_tx_map(struct sk_buff *sk | ||
/* store skb to cleanup */ | ||
itx_buf->skb = skb; | ||
|
||
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { | ||
+ if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { | ||
if (k & 0x1) | ||
txd_pdma->txd2 |= TX_DMA_LS0; | ||
else | ||
@@ -1115,7 +1118,7 @@ static int mtk_tx_map(struct sk_buff *sk | ||
*/ | ||
wmb(); | ||
|
||
- if (MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) { | ||
+ if (MTK_HAS_CAPS(soc->caps, MTK_QDMA)) { | ||
if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || | ||
!netdev_xmit_more()) | ||
mtk_w32(eth, txd->txd2, MTK_QTX_CTX_PTR); | ||
@@ -1129,13 +1132,13 @@ static int mtk_tx_map(struct sk_buff *sk | ||
|
||
err_dma: | ||
do { | ||
- tx_buf = mtk_desc_to_tx_buf(ring, itxd); | ||
+ tx_buf = mtk_desc_to_tx_buf(ring, itxd, soc->txrx.txd_size); | ||
|
||
/* unmap dma */ | ||
mtk_tx_unmap(eth, tx_buf, false); | ||
|
||
itxd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; | ||
- if (!MTK_HAS_CAPS(eth->soc->caps, MTK_QDMA)) | ||
+ if (!MTK_HAS_CAPS(soc->caps, MTK_QDMA)) | ||
itxd_pdma->txd2 = TX_DMA_DESP2_DEF; | ||
|
||
itxd = mtk_qdma_phys_to_virt(ring, itxd->txd2); | ||
@@ -1449,7 +1452,8 @@ static int mtk_poll_tx_qdma(struct mtk_e | ||
if ((desc->txd3 & TX_DMA_OWNER_CPU) == 0) | ||
break; | ||
|
||
- tx_buf = mtk_desc_to_tx_buf(ring, desc); | ||
+ tx_buf = mtk_desc_to_tx_buf(ring, desc, | ||
+ eth->soc->txrx.txd_size); | ||
if (tx_buf->flags & MTK_TX_FLAGS_FPORT1) | ||
mac = 1; | ||
|
39 changes: 39 additions & 0 deletions
39
...ric/backport-5.15/702-v5.19-22-net-ethernet-mtk_eth_soc-rely-on-txd_size-in-txd_to_.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:31 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size in txd_to_idx | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -905,9 +905,10 @@ static struct mtk_tx_dma *qdma_to_pdma(s | ||
return ring->dma_pdma - ring->dma + dma; | ||
} | ||
|
||
-static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma) | ||
+static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma, | ||
+ u32 txd_size) | ||
{ | ||
- return ((void *)dma - (void *)ring->dma) / sizeof(*dma); | ||
+ return ((void *)dma - (void *)ring->dma) / txd_size; | ||
} | ||
|
||
static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf, | ||
@@ -1123,8 +1124,10 @@ static int mtk_tx_map(struct sk_buff *sk | ||
!netdev_xmit_more()) | ||
mtk_w32(eth, txd->txd2, MTK_QTX_CTX_PTR); | ||
} else { | ||
- int next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd), | ||
- ring->dma_size); | ||
+ int next_idx; | ||
+ | ||
+ next_idx = NEXT_DESP_IDX(txd_to_idx(ring, txd, soc->txrx.txd_size), | ||
+ ring->dma_size); | ||
mtk_w32(eth, next_idx, MT7628_TX_CTX_IDX0); | ||
} | ||
|
102 changes: 102 additions & 0 deletions
102
...ric/backport-5.15/702-v5.19-23-net-ethernet-mtk_eth_soc-add-rxd_size-to-mtk_soc_dat.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:32 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: add rxd_size to mtk_soc_data | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -1775,7 +1775,7 @@ static int mtk_rx_alloc(struct mtk_eth * | ||
} | ||
|
||
ring->dma = dma_alloc_coherent(eth->dma_dev, | ||
- rx_dma_size * sizeof(*ring->dma), | ||
+ rx_dma_size * eth->soc->txrx.rxd_size, | ||
&ring->phys, GFP_KERNEL); | ||
if (!ring->dma) | ||
return -ENOMEM; | ||
@@ -1833,9 +1833,8 @@ static void mtk_rx_clean(struct mtk_eth | ||
|
||
if (ring->dma) { | ||
dma_free_coherent(eth->dma_dev, | ||
- ring->dma_size * sizeof(*ring->dma), | ||
- ring->dma, | ||
- ring->phys); | ||
+ ring->dma_size * eth->soc->txrx.rxd_size, | ||
+ ring->dma, ring->phys); | ||
ring->dma = NULL; | ||
} | ||
} | ||
@@ -3403,6 +3402,7 @@ static const struct mtk_soc_data mt2701_ | ||
.required_pctl = true, | ||
.txrx = { | ||
.txd_size = sizeof(struct mtk_tx_dma), | ||
+ .rxd_size = sizeof(struct mtk_rx_dma), | ||
}, | ||
}; | ||
|
||
@@ -3414,6 +3414,7 @@ static const struct mtk_soc_data mt7621_ | ||
.offload_version = 2, | ||
.txrx = { | ||
.txd_size = sizeof(struct mtk_tx_dma), | ||
+ .rxd_size = sizeof(struct mtk_rx_dma), | ||
}, | ||
}; | ||
|
||
@@ -3426,6 +3427,7 @@ static const struct mtk_soc_data mt7622_ | ||
.offload_version = 2, | ||
.txrx = { | ||
.txd_size = sizeof(struct mtk_tx_dma), | ||
+ .rxd_size = sizeof(struct mtk_rx_dma), | ||
}, | ||
}; | ||
|
||
@@ -3437,6 +3439,7 @@ static const struct mtk_soc_data mt7623_ | ||
.offload_version = 2, | ||
.txrx = { | ||
.txd_size = sizeof(struct mtk_tx_dma), | ||
+ .rxd_size = sizeof(struct mtk_rx_dma), | ||
}, | ||
}; | ||
|
||
@@ -3448,6 +3451,7 @@ static const struct mtk_soc_data mt7629_ | ||
.required_pctl = false, | ||
.txrx = { | ||
.txd_size = sizeof(struct mtk_tx_dma), | ||
+ .rxd_size = sizeof(struct mtk_rx_dma), | ||
}, | ||
}; | ||
|
||
@@ -3458,6 +3462,7 @@ static const struct mtk_soc_data rt5350_ | ||
.required_pctl = false, | ||
.txrx = { | ||
.txd_size = sizeof(struct mtk_tx_dma), | ||
+ .rxd_size = sizeof(struct mtk_rx_dma), | ||
}, | ||
}; | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
@@ -864,6 +864,7 @@ struct mtk_tx_dma_desc_info { | ||
* @required_pctl A bool value to show whether the SoC requires | ||
* the extra setup for those pins used by GMAC. | ||
* @txd_size Tx DMA descriptor size. | ||
+ * @rxd_size Rx DMA descriptor size. | ||
*/ | ||
struct mtk_soc_data { | ||
u32 ana_rgc3; | ||
@@ -874,6 +875,7 @@ struct mtk_soc_data { | ||
netdev_features_t hw_features; | ||
struct { | ||
u32 txd_size; | ||
+ u32 rxd_size; | ||
} txrx; | ||
}; | ||
|
46 changes: 46 additions & 0 deletions
46
...ric/backport-5.15/702-v5.19-24-net-ethernet-mtk_eth_soc-rely-on-txd_size-field-in-m.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:33 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on txd_size field in | ||
mtk_poll_tx/mtk_poll_rx | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -1264,9 +1264,12 @@ static struct mtk_rx_ring *mtk_get_rx_ri | ||
return ð->rx_ring[0]; | ||
|
||
for (i = 0; i < MTK_MAX_RX_RING_NUM; i++) { | ||
+ struct mtk_rx_dma *rxd; | ||
+ | ||
ring = ð->rx_ring[i]; | ||
idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size); | ||
- if (ring->dma[idx].rxd2 & RX_DMA_DONE) { | ||
+ rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size; | ||
+ if (rxd->rxd2 & RX_DMA_DONE) { | ||
ring->calc_idx_update = true; | ||
return ring; | ||
} | ||
@@ -1317,7 +1320,7 @@ static int mtk_poll_rx(struct napi_struc | ||
goto rx_done; | ||
|
||
idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size); | ||
- rxd = &ring->dma[idx]; | ||
+ rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size; | ||
data = ring->data[idx]; | ||
|
||
if (!mtk_rx_get_desc(&trxd, rxd)) | ||
@@ -1509,7 +1512,7 @@ static int mtk_poll_tx_pdma(struct mtk_e | ||
|
||
mtk_tx_unmap(eth, tx_buf, true); | ||
|
||
- desc = &ring->dma[cpu]; | ||
+ desc = (void *)ring->dma + cpu * eth->soc->txrx.txd_size; | ||
ring->last_free = desc; | ||
atomic_inc(&ring->free_count); | ||
|
68 changes: 68 additions & 0 deletions
68
...ric/backport-5.15/702-v5.19-25-net-ethernet-mtk_eth_soc-rely-on-rxd_size-field-in-m.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:34 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: rely on rxd_size field in | ||
mtk_rx_alloc/mtk_rx_clean | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -1784,18 +1784,25 @@ static int mtk_rx_alloc(struct mtk_eth * | ||
return -ENOMEM; | ||
|
||
for (i = 0; i < rx_dma_size; i++) { | ||
+ struct mtk_rx_dma *rxd; | ||
+ | ||
dma_addr_t dma_addr = dma_map_single(eth->dma_dev, | ||
ring->data[i] + NET_SKB_PAD + eth->ip_align, | ||
ring->buf_size, | ||
DMA_FROM_DEVICE); | ||
if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr))) | ||
return -ENOMEM; | ||
- ring->dma[i].rxd1 = (unsigned int)dma_addr; | ||
+ | ||
+ rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; | ||
+ rxd->rxd1 = (unsigned int)dma_addr; | ||
|
||
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) | ||
- ring->dma[i].rxd2 = RX_DMA_LSO; | ||
+ rxd->rxd2 = RX_DMA_LSO; | ||
else | ||
- ring->dma[i].rxd2 = RX_DMA_PLEN0(ring->buf_size); | ||
+ rxd->rxd2 = RX_DMA_PLEN0(ring->buf_size); | ||
+ | ||
+ rxd->rxd3 = 0; | ||
+ rxd->rxd4 = 0; | ||
} | ||
ring->dma_size = rx_dma_size; | ||
ring->calc_idx_update = false; | ||
@@ -1820,14 +1827,17 @@ static void mtk_rx_clean(struct mtk_eth | ||
|
||
if (ring->data && ring->dma) { | ||
for (i = 0; i < ring->dma_size; i++) { | ||
+ struct mtk_rx_dma *rxd; | ||
+ | ||
if (!ring->data[i]) | ||
continue; | ||
- if (!ring->dma[i].rxd1) | ||
+ | ||
+ rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; | ||
+ if (!rxd->rxd1) | ||
continue; | ||
- dma_unmap_single(eth->dma_dev, | ||
- ring->dma[i].rxd1, | ||
- ring->buf_size, | ||
- DMA_FROM_DEVICE); | ||
+ | ||
+ dma_unmap_single(eth->dma_dev, rxd->rxd1, | ||
+ ring->buf_size, DMA_FROM_DEVICE); | ||
skb_free_frag(ring->data[i]); | ||
} | ||
kfree(ring->data); |
814 changes: 814 additions & 0 deletions
814
...ric/backport-5.15/702-v5.19-26-net-ethernet-mtk_eth_soc-introduce-device-register-m.patch
Large diffs are not rendered by default.
Oops, something went wrong.
917 changes: 917 additions & 0 deletions
917
...ric/backport-5.15/702-v5.19-27-net-ethernet-mtk_eth_soc-introduce-MTK_NETSYS_V2-sup.patch
Large diffs are not rendered by default.
Oops, something went wrong.
135 changes: 135 additions & 0 deletions
135
...ric/backport-5.15/702-v5.19-28-net-ethernet-mtk_eth_soc-convert-ring-dma-pointer-to.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:37 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: convert ring dma pointer to void | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -946,18 +946,15 @@ static int mtk_init_fq_dma(struct mtk_et | ||
return 0; | ||
} | ||
|
||
-static inline void *mtk_qdma_phys_to_virt(struct mtk_tx_ring *ring, u32 desc) | ||
+static void *mtk_qdma_phys_to_virt(struct mtk_tx_ring *ring, u32 desc) | ||
{ | ||
- void *ret = ring->dma; | ||
- | ||
- return ret + (desc - ring->phys); | ||
+ return ring->dma + (desc - ring->phys); | ||
} | ||
|
||
static struct mtk_tx_buf *mtk_desc_to_tx_buf(struct mtk_tx_ring *ring, | ||
- struct mtk_tx_dma *txd, | ||
- u32 txd_size) | ||
+ void *txd, u32 txd_size) | ||
{ | ||
- int idx = ((void *)txd - (void *)ring->dma) / txd_size; | ||
+ int idx = (txd - ring->dma) / txd_size; | ||
|
||
return &ring->buf[idx]; | ||
} | ||
@@ -965,13 +962,12 @@ static struct mtk_tx_buf *mtk_desc_to_tx | ||
static struct mtk_tx_dma *qdma_to_pdma(struct mtk_tx_ring *ring, | ||
struct mtk_tx_dma *dma) | ||
{ | ||
- return ring->dma_pdma - ring->dma + dma; | ||
+ return ring->dma_pdma - (struct mtk_tx_dma *)ring->dma + dma; | ||
} | ||
|
||
-static int txd_to_idx(struct mtk_tx_ring *ring, struct mtk_tx_dma *dma, | ||
- u32 txd_size) | ||
+static int txd_to_idx(struct mtk_tx_ring *ring, void *dma, u32 txd_size) | ||
{ | ||
- return ((void *)dma - (void *)ring->dma) / txd_size; | ||
+ return (dma - ring->dma) / txd_size; | ||
} | ||
|
||
static void mtk_tx_unmap(struct mtk_eth *eth, struct mtk_tx_buf *tx_buf, | ||
@@ -1388,7 +1384,7 @@ static struct mtk_rx_ring *mtk_get_rx_ri | ||
|
||
ring = ð->rx_ring[i]; | ||
idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size); | ||
- rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size; | ||
+ rxd = ring->dma + idx * eth->soc->txrx.rxd_size; | ||
if (rxd->rxd2 & RX_DMA_DONE) { | ||
ring->calc_idx_update = true; | ||
return ring; | ||
@@ -1440,7 +1436,7 @@ static int mtk_poll_rx(struct napi_struc | ||
goto rx_done; | ||
|
||
idx = NEXT_DESP_IDX(ring->calc_idx, ring->dma_size); | ||
- rxd = (void *)ring->dma + idx * eth->soc->txrx.rxd_size; | ||
+ rxd = ring->dma + idx * eth->soc->txrx.rxd_size; | ||
data = ring->data[idx]; | ||
|
||
if (!mtk_rx_get_desc(eth, &trxd, rxd)) | ||
@@ -1647,7 +1643,7 @@ static int mtk_poll_tx_pdma(struct mtk_e | ||
|
||
mtk_tx_unmap(eth, tx_buf, true); | ||
|
||
- desc = (void *)ring->dma + cpu * eth->soc->txrx.txd_size; | ||
+ desc = ring->dma + cpu * eth->soc->txrx.txd_size; | ||
ring->last_free = desc; | ||
atomic_inc(&ring->free_count); | ||
|
||
@@ -1792,7 +1788,7 @@ static int mtk_tx_alloc(struct mtk_eth * | ||
int next = (i + 1) % MTK_DMA_SIZE; | ||
u32 next_ptr = ring->phys + next * sz; | ||
|
||
- txd = (void *)ring->dma + i * sz; | ||
+ txd = ring->dma + i * sz; | ||
txd->txd2 = next_ptr; | ||
txd->txd3 = TX_DMA_LS0 | TX_DMA_OWNER_CPU; | ||
txd->txd4 = 0; | ||
@@ -1822,7 +1818,7 @@ static int mtk_tx_alloc(struct mtk_eth * | ||
|
||
ring->dma_size = MTK_DMA_SIZE; | ||
atomic_set(&ring->free_count, MTK_DMA_SIZE - 2); | ||
- ring->next_free = &ring->dma[0]; | ||
+ ring->next_free = ring->dma; | ||
ring->last_free = (void *)txd; | ||
ring->last_free_ptr = (u32)(ring->phys + ((MTK_DMA_SIZE - 1) * sz)); | ||
ring->thresh = MAX_SKB_FRAGS; | ||
@@ -1937,7 +1933,7 @@ static int mtk_rx_alloc(struct mtk_eth * | ||
if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr))) | ||
return -ENOMEM; | ||
|
||
- rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; | ||
+ rxd = ring->dma + i * eth->soc->txrx.rxd_size; | ||
rxd->rxd1 = (unsigned int)dma_addr; | ||
|
||
if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628)) | ||
@@ -1999,7 +1995,7 @@ static void mtk_rx_clean(struct mtk_eth | ||
if (!ring->data[i]) | ||
continue; | ||
|
||
- rxd = (void *)ring->dma + i * eth->soc->txrx.rxd_size; | ||
+ rxd = ring->dma + i * eth->soc->txrx.rxd_size; | ||
if (!rxd->rxd1) | ||
continue; | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
@@ -688,7 +688,7 @@ struct mtk_tx_buf { | ||
* are present | ||
*/ | ||
struct mtk_tx_ring { | ||
- struct mtk_tx_dma *dma; | ||
+ void *dma; | ||
struct mtk_tx_buf *buf; | ||
dma_addr_t phys; | ||
struct mtk_tx_dma *next_free; | ||
@@ -718,7 +718,7 @@ enum mtk_rx_flags { | ||
* @calc_idx: The current head of ring | ||
*/ | ||
struct mtk_rx_ring { | ||
- struct mtk_rx_dma *dma; | ||
+ void *dma; | ||
u8 **data; | ||
dma_addr_t phys; | ||
u16 frag_size; |
33 changes: 33 additions & 0 deletions
33
...ric/backport-5.15/702-v5.19-29-net-ethernet-mtk_eth_soc-convert-scratch_ring-pointe.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:38 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: convert scratch_ring pointer to | ||
void | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -922,7 +922,7 @@ static int mtk_init_fq_dma(struct mtk_et | ||
for (i = 0; i < cnt; i++) { | ||
struct mtk_tx_dma_v2 *txd; | ||
|
||
- txd = (void *)eth->scratch_ring + i * soc->txrx.txd_size; | ||
+ txd = eth->scratch_ring + i * soc->txrx.txd_size; | ||
txd->txd1 = dma_addr + i * MTK_QDMA_PAGE_SIZE; | ||
if (i < cnt - 1) | ||
txd->txd2 = eth->phy_scratch_ring + | ||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
@@ -1028,7 +1028,7 @@ struct mtk_eth { | ||
struct mtk_rx_ring rx_ring_qdma; | ||
struct napi_struct tx_napi; | ||
struct napi_struct rx_napi; | ||
- struct mtk_tx_dma *scratch_ring; | ||
+ void *scratch_ring; | ||
dma_addr_t phy_scratch_ring; | ||
void *scratch_head; | ||
struct clk *clks[MTK_CLK_MAX]; |
138 changes: 138 additions & 0 deletions
138
...ric/backport-5.15/702-v5.19-30-net-ethernet-mtk_eth_soc-introduce-support-for-mt798.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Fri, 20 May 2022 20:11:39 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: introduce support for mt7986 | ||
chipset | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -87,6 +87,43 @@ static const struct mtk_reg_map mt7628_r | ||
}, | ||
}; | ||
|
||
+static const struct mtk_reg_map mt7986_reg_map = { | ||
+ .tx_irq_mask = 0x461c, | ||
+ .tx_irq_status = 0x4618, | ||
+ .pdma = { | ||
+ .rx_ptr = 0x6100, | ||
+ .rx_cnt_cfg = 0x6104, | ||
+ .pcrx_ptr = 0x6108, | ||
+ .glo_cfg = 0x6204, | ||
+ .rst_idx = 0x6208, | ||
+ .delay_irq = 0x620c, | ||
+ .irq_status = 0x6220, | ||
+ .irq_mask = 0x6228, | ||
+ .int_grp = 0x6250, | ||
+ }, | ||
+ .qdma = { | ||
+ .qtx_cfg = 0x4400, | ||
+ .rx_ptr = 0x4500, | ||
+ .rx_cnt_cfg = 0x4504, | ||
+ .qcrx_ptr = 0x4508, | ||
+ .glo_cfg = 0x4604, | ||
+ .rst_idx = 0x4608, | ||
+ .delay_irq = 0x460c, | ||
+ .fc_th = 0x4610, | ||
+ .int_grp = 0x4620, | ||
+ .hred = 0x4644, | ||
+ .ctx_ptr = 0x4700, | ||
+ .dtx_ptr = 0x4704, | ||
+ .crx_ptr = 0x4710, | ||
+ .drx_ptr = 0x4714, | ||
+ .fq_head = 0x4720, | ||
+ .fq_tail = 0x4724, | ||
+ .fq_count = 0x4728, | ||
+ .fq_blen = 0x472c, | ||
+ }, | ||
+ .gdm1_cnt = 0x1c00, | ||
+}; | ||
+ | ||
/* strings used by ethtool */ | ||
static const struct mtk_ethtool_stats { | ||
char str[ETH_GSTRING_LEN]; | ||
@@ -110,7 +147,7 @@ static const char * const mtk_clks_sourc | ||
"ethif", "sgmiitop", "esw", "gp0", "gp1", "gp2", "fe", "trgpll", | ||
"sgmii_tx250m", "sgmii_rx250m", "sgmii_cdr_ref", "sgmii_cdr_fb", | ||
"sgmii2_tx250m", "sgmii2_rx250m", "sgmii2_cdr_ref", "sgmii2_cdr_fb", | ||
- "sgmii_ck", "eth2pll", | ||
+ "sgmii_ck", "eth2pll", "wocpu0", "wocpu1", "netsys0", "netsys1" | ||
}; | ||
|
||
void mtk_w32(struct mtk_eth *eth, u32 val, unsigned reg) | ||
@@ -3709,6 +3746,21 @@ static const struct mtk_soc_data mt7629_ | ||
}, | ||
}; | ||
|
||
+static const struct mtk_soc_data mt7986_data = { | ||
+ .reg_map = &mt7986_reg_map, | ||
+ .ana_rgc3 = 0x128, | ||
+ .caps = MT7986_CAPS, | ||
+ .required_clks = MT7986_CLKS_BITMAP, | ||
+ .required_pctl = false, | ||
+ .txrx = { | ||
+ .txd_size = sizeof(struct mtk_tx_dma_v2), | ||
+ .rxd_size = sizeof(struct mtk_rx_dma_v2), | ||
+ .rx_irq_done_mask = MTK_RX_DONE_INT_V2, | ||
+ .dma_max_len = MTK_TX_DMA_BUF_LEN_V2, | ||
+ .dma_len_offset = 8, | ||
+ }, | ||
+}; | ||
+ | ||
static const struct mtk_soc_data rt5350_data = { | ||
.reg_map = &mt7628_reg_map, | ||
.caps = MT7628_CAPS, | ||
@@ -3731,6 +3783,7 @@ const struct of_device_id of_mtk_match[] | ||
{ .compatible = "mediatek,mt7622-eth", .data = &mt7622_data}, | ||
{ .compatible = "mediatek,mt7623-eth", .data = &mt7623_data}, | ||
{ .compatible = "mediatek,mt7629-eth", .data = &mt7629_data}, | ||
+ { .compatible = "mediatek,mt7986-eth", .data = &mt7986_data}, | ||
{ .compatible = "ralink,rt5350-eth", .data = &rt5350_data}, | ||
{}, | ||
}; | ||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h | ||
@@ -623,6 +623,10 @@ enum mtk_clks_map { | ||
MTK_CLK_SGMII2_CDR_FB, | ||
MTK_CLK_SGMII_CK, | ||
MTK_CLK_ETH2PLL, | ||
+ MTK_CLK_WOCPU0, | ||
+ MTK_CLK_WOCPU1, | ||
+ MTK_CLK_NETSYS0, | ||
+ MTK_CLK_NETSYS1, | ||
MTK_CLK_MAX | ||
}; | ||
|
||
@@ -653,6 +657,16 @@ enum mtk_clks_map { | ||
BIT(MTK_CLK_SGMII2_CDR_FB) | \ | ||
BIT(MTK_CLK_SGMII_CK) | \ | ||
BIT(MTK_CLK_ETH2PLL) | BIT(MTK_CLK_SGMIITOP)) | ||
+#define MT7986_CLKS_BITMAP (BIT(MTK_CLK_FE) | BIT(MTK_CLK_GP2) | BIT(MTK_CLK_GP1) | \ | ||
+ BIT(MTK_CLK_WOCPU1) | BIT(MTK_CLK_WOCPU0) | \ | ||
+ BIT(MTK_CLK_SGMII_TX_250M) | \ | ||
+ BIT(MTK_CLK_SGMII_RX_250M) | \ | ||
+ BIT(MTK_CLK_SGMII_CDR_REF) | \ | ||
+ BIT(MTK_CLK_SGMII_CDR_FB) | \ | ||
+ BIT(MTK_CLK_SGMII2_TX_250M) | \ | ||
+ BIT(MTK_CLK_SGMII2_RX_250M) | \ | ||
+ BIT(MTK_CLK_SGMII2_CDR_REF) | \ | ||
+ BIT(MTK_CLK_SGMII2_CDR_FB)) | ||
|
||
enum mtk_dev_state { | ||
MTK_HW_INIT, | ||
@@ -851,6 +865,10 @@ enum mkt_eth_capabilities { | ||
MTK_MUX_U3_GMAC2_TO_QPHY | \ | ||
MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA) | ||
|
||
+#define MT7986_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | \ | ||
+ MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \ | ||
+ MTK_NETSYS_V2 | MTK_RSTCTRL_PPE1) | ||
+ | ||
struct mtk_tx_dma_desc_info { | ||
dma_addr_t addr; | ||
u32 size; |
25 changes: 25 additions & 0 deletions
25
...ric/backport-5.15/702-v5.19-31-net-ethernet-mtk_eth_soc-fix-error-code-in-mtk_flow_.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
From: Dan Carpenter <dan.carpenter@oracle.com> | ||
Date: Thu, 19 May 2022 17:08:00 +0300 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: fix error code in | ||
mtk_flow_offload_replace() | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c | ||
@@ -434,7 +434,8 @@ mtk_flow_offload_replace(struct mtk_eth | ||
memcpy(&entry->data, &foe, sizeof(entry->data)); | ||
entry->wed_index = wed_index; | ||
|
||
- if (mtk_foe_entry_commit(eth->ppe, entry) < 0) | ||
+ err = mtk_foe_entry_commit(eth->ppe, entry); | ||
+ if (err < 0) | ||
goto free; | ||
|
||
err = rhashtable_insert_fast(ð->flow_table, &entry->node, |
47 changes: 47 additions & 0 deletions
47
...ric/backport-5.15/702-v5.19-33-net-ethernet-mtk_eth_soc-enable-rx-cksum-offload-for.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
From: Lorenzo Bianconi <lorenzo@kernel.org> | ||
Date: Mon, 6 Jun 2022 21:49:00 +0200 | ||
Subject: [PATCH] net: ethernet: mtk_eth_soc: enable rx cksum offload for | ||
MTK_NETSYS_V2 | ||
|
||
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> | ||
--- | ||
|
||
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c | ||
@@ -1462,8 +1462,8 @@ static int mtk_poll_rx(struct napi_struc | ||
int done = 0, bytes = 0; | ||
|
||
while (done < budget) { | ||
+ unsigned int pktlen, *rxdcsum; | ||
struct net_device *netdev; | ||
- unsigned int pktlen; | ||
dma_addr_t dma_addr; | ||
u32 hash, reason; | ||
int mac = 0; | ||
@@ -1530,7 +1530,13 @@ static int mtk_poll_rx(struct napi_struc | ||
pktlen = RX_DMA_GET_PLEN0(trxd.rxd2); | ||
skb->dev = netdev; | ||
skb_put(skb, pktlen); | ||
- if (trxd.rxd4 & eth->soc->txrx.rx_dma_l4_valid) | ||
+ | ||
+ if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) | ||
+ rxdcsum = &trxd.rxd3; | ||
+ else | ||
+ rxdcsum = &trxd.rxd4; | ||
+ | ||
+ if (*rxdcsum & eth->soc->txrx.rx_dma_l4_valid) | ||
skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
else | ||
skb_checksum_none_assert(skb); | ||
@@ -3756,6 +3762,7 @@ static const struct mtk_soc_data mt7986_ | ||
.txd_size = sizeof(struct mtk_tx_dma_v2), | ||
.rxd_size = sizeof(struct mtk_rx_dma_v2), | ||
.rx_irq_done_mask = MTK_RX_DONE_INT_V2, | ||
+ .rx_dma_l4_valid = RX_DMA_L4_VALID_V2, | ||
.dma_max_len = MTK_TX_DMA_BUF_LEN_V2, | ||
.dma_len_offset = 8, | ||
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
target/linux/mediatek/patches-5.15/704-net-ethernet-mtk_eth_soc-announce-2500baseT.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters