Skip to content

Commit 9304640

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: airoha: Link the gdm port to the selected qdma controller
Link the running gdm port to the qdma controller used to connect with the CPU. Moreover, load all QDMA controllers available on EN7581 SoC. Signed-off-by: Lorenzo Bianconi <[email protected]> Link: https://patch.msgid.link/95b515df34ba4727f7ae5b14a1d0462cceec84ff.1722522582.git.lorenzo@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 160231e commit 9304640

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

drivers/net/ethernet/mediatek/airoha_eth.c

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <uapi/linux/ppp_defs.h>
1919

2020
#define AIROHA_MAX_NUM_GDM_PORTS 1
21-
#define AIROHA_MAX_NUM_QDMA 1
21+
#define AIROHA_MAX_NUM_QDMA 2
2222
#define AIROHA_MAX_NUM_RSTS 3
2323
#define AIROHA_MAX_NUM_XSI_RSTS 5
2424
#define AIROHA_MAX_MTU 2000
@@ -805,8 +805,8 @@ struct airoha_qdma {
805805
};
806806

807807
struct airoha_gdm_port {
808+
struct airoha_qdma *qdma;
808809
struct net_device *dev;
809-
struct airoha_eth *eth;
810810
int id;
811811

812812
struct airoha_hw_stats stats;
@@ -2138,7 +2138,7 @@ static void airoha_qdma_start_napi(struct airoha_qdma *qdma)
21382138

21392139
static void airoha_update_hw_stats(struct airoha_gdm_port *port)
21402140
{
2141-
struct airoha_eth *eth = port->eth;
2141+
struct airoha_eth *eth = port->qdma->eth;
21422142
u32 val, i = 0;
21432143

21442144
spin_lock(&port->stats.lock);
@@ -2283,22 +2283,22 @@ static void airoha_update_hw_stats(struct airoha_gdm_port *port)
22832283
static int airoha_dev_open(struct net_device *dev)
22842284
{
22852285
struct airoha_gdm_port *port = netdev_priv(dev);
2286-
struct airoha_eth *eth = port->eth;
2286+
struct airoha_qdma *qdma = port->qdma;
22872287
int err;
22882288

22892289
netif_tx_start_all_queues(dev);
2290-
err = airoha_set_gdm_ports(eth, true);
2290+
err = airoha_set_gdm_ports(qdma->eth, true);
22912291
if (err)
22922292
return err;
22932293

22942294
if (netdev_uses_dsa(dev))
2295-
airoha_fe_set(eth, REG_GDM_INGRESS_CFG(port->id),
2295+
airoha_fe_set(qdma->eth, REG_GDM_INGRESS_CFG(port->id),
22962296
GDM_STAG_EN_MASK);
22972297
else
2298-
airoha_fe_clear(eth, REG_GDM_INGRESS_CFG(port->id),
2298+
airoha_fe_clear(qdma->eth, REG_GDM_INGRESS_CFG(port->id),
22992299
GDM_STAG_EN_MASK);
23002300

2301-
airoha_qdma_set(&eth->qdma[0], REG_QDMA_GLOBAL_CFG,
2301+
airoha_qdma_set(qdma, REG_QDMA_GLOBAL_CFG,
23022302
GLOBAL_CFG_TX_DMA_EN_MASK |
23032303
GLOBAL_CFG_RX_DMA_EN_MASK);
23042304

@@ -2308,15 +2308,15 @@ static int airoha_dev_open(struct net_device *dev)
23082308
static int airoha_dev_stop(struct net_device *dev)
23092309
{
23102310
struct airoha_gdm_port *port = netdev_priv(dev);
2311-
struct airoha_eth *eth = port->eth;
2311+
struct airoha_qdma *qdma = port->qdma;
23122312
int err;
23132313

23142314
netif_tx_disable(dev);
2315-
err = airoha_set_gdm_ports(eth, false);
2315+
err = airoha_set_gdm_ports(qdma->eth, false);
23162316
if (err)
23172317
return err;
23182318

2319-
airoha_qdma_clear(&eth->qdma[0], REG_QDMA_GLOBAL_CFG,
2319+
airoha_qdma_clear(qdma, REG_QDMA_GLOBAL_CFG,
23202320
GLOBAL_CFG_TX_DMA_EN_MASK |
23212321
GLOBAL_CFG_RX_DMA_EN_MASK);
23222322

@@ -2332,7 +2332,7 @@ static int airoha_dev_set_macaddr(struct net_device *dev, void *p)
23322332
if (err)
23332333
return err;
23342334

2335-
airoha_set_macaddr(port->eth, dev->dev_addr);
2335+
airoha_set_macaddr(port->qdma->eth, dev->dev_addr);
23362336

23372337
return 0;
23382338
}
@@ -2341,7 +2341,7 @@ static int airoha_dev_init(struct net_device *dev)
23412341
{
23422342
struct airoha_gdm_port *port = netdev_priv(dev);
23432343

2344-
airoha_set_macaddr(port->eth, dev->dev_addr);
2344+
airoha_set_macaddr(port->qdma->eth, dev->dev_addr);
23452345

23462346
return 0;
23472347
}
@@ -2375,10 +2375,9 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
23752375
struct airoha_gdm_port *port = netdev_priv(dev);
23762376
u32 msg0 = 0, msg1, len = skb_headlen(skb);
23772377
int i, qid = skb_get_queue_mapping(skb);
2378-
struct airoha_eth *eth = port->eth;
2378+
struct airoha_qdma *qdma = port->qdma;
23792379
u32 nr_frags = 1 + sinfo->nr_frags;
23802380
struct netdev_queue *txq;
2381-
struct airoha_qdma *qdma;
23822381
struct airoha_queue *q;
23832382
void *data = skb->data;
23842383
u16 index;
@@ -2406,7 +2405,6 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
24062405
msg1 = FIELD_PREP(QDMA_ETH_TXMSG_FPORT_MASK, fport) |
24072406
FIELD_PREP(QDMA_ETH_TXMSG_METER_MASK, 0x7f);
24082407

2409-
qdma = &eth->qdma[0];
24102408
q = &qdma->q_tx[qid];
24112409
if (WARN_ON_ONCE(!q->ndesc))
24122410
goto error;
@@ -2489,7 +2487,7 @@ static void airoha_ethtool_get_drvinfo(struct net_device *dev,
24892487
struct ethtool_drvinfo *info)
24902488
{
24912489
struct airoha_gdm_port *port = netdev_priv(dev);
2492-
struct airoha_eth *eth = port->eth;
2490+
struct airoha_eth *eth = port->qdma->eth;
24932491

24942492
strscpy(info->driver, eth->dev->driver->name, sizeof(info->driver));
24952493
strscpy(info->bus_info, dev_name(eth->dev), sizeof(info->bus_info));
@@ -2570,6 +2568,7 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
25702568
{
25712569
const __be32 *id_ptr = of_get_property(np, "reg", NULL);
25722570
struct airoha_gdm_port *port;
2571+
struct airoha_qdma *qdma;
25732572
struct net_device *dev;
25742573
int err, index;
25752574
u32 id;
@@ -2599,6 +2598,7 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
25992598
return -ENOMEM;
26002599
}
26012600

2601+
qdma = &eth->qdma[index % AIROHA_MAX_NUM_QDMA];
26022602
dev->netdev_ops = &airoha_netdev_ops;
26032603
dev->ethtool_ops = &airoha_ethtool_ops;
26042604
dev->max_mtu = AIROHA_MAX_MTU;
@@ -2608,6 +2608,7 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
26082608
NETIF_F_SG | NETIF_F_TSO;
26092609
dev->features |= dev->hw_features;
26102610
dev->dev.of_node = np;
2611+
dev->irq = qdma->irq;
26112612
SET_NETDEV_DEV(dev, eth->dev);
26122613

26132614
err = of_get_ethdev_address(np, dev);
@@ -2623,8 +2624,8 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
26232624
port = netdev_priv(dev);
26242625
u64_stats_init(&port->stats.syncp);
26252626
spin_lock_init(&port->stats.lock);
2627+
port->qdma = qdma;
26262628
port->dev = dev;
2627-
port->eth = eth;
26282629
port->id = id;
26292630
eth->ports[index] = port;
26302631

0 commit comments

Comments
 (0)