Skip to content

Commit 83d6371

Browse files
LorenzoBianconigregkh
authored andcommitted
net: airoha: Generalize airoha_ppe2_is_enabled routine
[ Upstream commit ef9449f ] Rename airoha_ppe2_is_enabled() in airoha_ppe_is_enabled() and generalize it in order to check if each PPE module is enabled. Rely on airoha_ppe_is_enabled routine to properly initialize PPE for AN7583 SoC since AN7583 does not support PPE2. Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://patch.msgid.link/20251017-an7583-eth-support-v3-5-f28319666667@kernel.org Signed-off-by: Paolo Abeni <pabeni@redhat.com> Stable-dep-of: 02f7296 ("net: airoha: Fix FE_PSE_BUF_SET configuration if PPE2 is available") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4ea17f5 commit 83d6371

3 files changed

Lines changed: 32 additions & 18 deletions

File tree

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,11 @@ static void airoha_fe_pse_ports_init(struct airoha_eth *eth)
297297
int q;
298298

299299
all_rsv = airoha_fe_get_pse_all_rsv(eth);
300-
/* hw misses PPE2 oq rsv */
301-
all_rsv += PSE_RSV_PAGES * pse_port_num_queues[FE_PSE_PORT_PPE2];
300+
if (airoha_ppe_is_enabled(eth, 1)) {
301+
/* hw misses PPE2 oq rsv */
302+
all_rsv += PSE_RSV_PAGES *
303+
pse_port_num_queues[FE_PSE_PORT_PPE2];
304+
}
302305
airoha_fe_set(eth, REG_FE_PSE_BUF_SET, all_rsv);
303306

304307
/* CMD1 */
@@ -335,13 +338,17 @@ static void airoha_fe_pse_ports_init(struct airoha_eth *eth)
335338
for (q = 4; q < pse_port_num_queues[FE_PSE_PORT_CDM4]; q++)
336339
airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_CDM4, q,
337340
PSE_QUEUE_RSV_PAGES);
338-
/* PPE2 */
339-
for (q = 0; q < pse_port_num_queues[FE_PSE_PORT_PPE2]; q++) {
340-
if (q < pse_port_num_queues[FE_PSE_PORT_PPE2] / 2)
341-
airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE2, q,
342-
PSE_QUEUE_RSV_PAGES);
343-
else
344-
airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE2, q, 0);
341+
if (airoha_ppe_is_enabled(eth, 1)) {
342+
/* PPE2 */
343+
for (q = 0; q < pse_port_num_queues[FE_PSE_PORT_PPE2]; q++) {
344+
if (q < pse_port_num_queues[FE_PSE_PORT_PPE2] / 2)
345+
airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE2,
346+
q,
347+
PSE_QUEUE_RSV_PAGES);
348+
else
349+
airoha_fe_set_pse_oq_rsv(eth, FE_PSE_PORT_PPE2,
350+
q, 0);
351+
}
345352
}
346353
/* GMD4 */
347354
for (q = 0; q < pse_port_num_queues[FE_PSE_PORT_GDM4]; q++)
@@ -1781,8 +1788,11 @@ static int airoha_dev_init(struct net_device *dev)
17811788
airhoha_set_gdm2_loopback(port);
17821789
fallthrough;
17831790
case 2:
1784-
pse_port = FE_PSE_PORT_PPE2;
1785-
break;
1791+
if (airoha_ppe_is_enabled(eth, 1)) {
1792+
pse_port = FE_PSE_PORT_PPE2;
1793+
break;
1794+
}
1795+
fallthrough;
17861796
default:
17871797
pse_port = FE_PSE_PORT_PPE1;
17881798
break;

drivers/net/ethernet/airoha/airoha_eth.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ static inline bool airoha_is_7581(struct airoha_eth *eth)
627627
bool airoha_is_valid_gdm_port(struct airoha_eth *eth,
628628
struct airoha_gdm_port *port);
629629

630+
bool airoha_ppe_is_enabled(struct airoha_eth *eth, int index);
630631
void airoha_ppe_check_skb(struct airoha_ppe_dev *dev, struct sk_buff *skb,
631632
u16 hash, bool rx_wlan);
632633
int airoha_ppe_setup_tc_block_cb(struct airoha_ppe_dev *dev, void *type_data);

drivers/net/ethernet/airoha/airoha_ppe.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ static int airoha_ppe_get_total_num_stats_entries(struct airoha_ppe *ppe)
5050
return num_stats;
5151
}
5252

53-
static bool airoha_ppe2_is_enabled(struct airoha_eth *eth)
53+
bool airoha_ppe_is_enabled(struct airoha_eth *eth, int index)
5454
{
55-
return airoha_fe_rr(eth, REG_PPE_GLO_CFG(1)) & PPE_GLO_CFG_EN_MASK;
55+
if (index >= eth->soc->num_ppe)
56+
return false;
57+
58+
return airoha_fe_rr(eth, REG_PPE_GLO_CFG(index)) & PPE_GLO_CFG_EN_MASK;
5659
}
5760

5861
static u32 airoha_ppe_get_timestamp(struct airoha_ppe *ppe)
@@ -120,7 +123,7 @@ static void airoha_ppe_hw_init(struct airoha_ppe *ppe)
120123
AIROHA_MAX_MTU));
121124
}
122125

123-
if (airoha_ppe2_is_enabled(eth)) {
126+
if (airoha_ppe_is_enabled(eth, 1)) {
124127
sram_num_entries = PPE1_SRAM_NUM_ENTRIES;
125128
sram_num_stats_entries =
126129
airoha_ppe_get_num_stats_entries(ppe);
@@ -520,7 +523,7 @@ static int airoha_ppe_foe_get_flow_stats_index(struct airoha_ppe *ppe,
520523
return ppe_num_stats_entries;
521524

522525
*index = hash;
523-
if (airoha_ppe2_is_enabled(ppe->eth) &&
526+
if (airoha_ppe_is_enabled(ppe->eth, 1) &&
524527
hash >= ppe_num_stats_entries)
525528
*index = *index - PPE_STATS_NUM_ENTRIES;
526529

@@ -615,7 +618,7 @@ airoha_ppe_foe_get_entry_locked(struct airoha_ppe *ppe, u32 hash)
615618
u32 val;
616619
int i;
617620

618-
ppe2 = airoha_ppe2_is_enabled(ppe->eth) &&
621+
ppe2 = airoha_ppe_is_enabled(ppe->eth, 1) &&
619622
hash >= PPE1_SRAM_NUM_ENTRIES;
620623
airoha_fe_wr(ppe->eth, REG_PPE_RAM_CTRL(ppe2),
621624
FIELD_PREP(PPE_SRAM_CTRL_ENTRY_MASK, hash) |
@@ -693,7 +696,7 @@ static int airoha_ppe_foe_commit_entry(struct airoha_ppe *ppe,
693696

694697
if (hash < PPE_SRAM_NUM_ENTRIES) {
695698
dma_addr_t addr = ppe->foe_dma + hash * sizeof(*hwe);
696-
bool ppe2 = airoha_ppe2_is_enabled(eth) &&
699+
bool ppe2 = airoha_ppe_is_enabled(eth, 1) &&
697700
hash >= PPE1_SRAM_NUM_ENTRIES;
698701

699702
err = npu->ops.ppe_foe_commit_entry(npu, addr, sizeof(*hwe),
@@ -1288,7 +1291,7 @@ static int airoha_ppe_flush_sram_entries(struct airoha_ppe *ppe,
12881291
int i, sram_num_entries = PPE_SRAM_NUM_ENTRIES;
12891292
struct airoha_foe_entry *hwe = ppe->foe;
12901293

1291-
if (airoha_ppe2_is_enabled(ppe->eth))
1294+
if (airoha_ppe_is_enabled(ppe->eth, 1))
12921295
sram_num_entries = sram_num_entries / 2;
12931296

12941297
for (i = 0; i < sram_num_entries; i++)

0 commit comments

Comments
 (0)