18
18
#include <uapi/linux/ppp_defs.h>
19
19
20
20
#define AIROHA_MAX_NUM_GDM_PORTS 1
21
- #define AIROHA_MAX_NUM_QDMA 1
21
+ #define AIROHA_MAX_NUM_QDMA 2
22
22
#define AIROHA_MAX_NUM_RSTS 3
23
23
#define AIROHA_MAX_NUM_XSI_RSTS 5
24
24
#define AIROHA_MAX_MTU 2000
@@ -805,8 +805,8 @@ struct airoha_qdma {
805
805
};
806
806
807
807
struct airoha_gdm_port {
808
+ struct airoha_qdma * qdma ;
808
809
struct net_device * dev ;
809
- struct airoha_eth * eth ;
810
810
int id ;
811
811
812
812
struct airoha_hw_stats stats ;
@@ -2138,7 +2138,7 @@ static void airoha_qdma_start_napi(struct airoha_qdma *qdma)
2138
2138
2139
2139
static void airoha_update_hw_stats (struct airoha_gdm_port * port )
2140
2140
{
2141
- struct airoha_eth * eth = port -> eth ;
2141
+ struct airoha_eth * eth = port -> qdma -> eth ;
2142
2142
u32 val , i = 0 ;
2143
2143
2144
2144
spin_lock (& port -> stats .lock );
@@ -2283,22 +2283,22 @@ static void airoha_update_hw_stats(struct airoha_gdm_port *port)
2283
2283
static int airoha_dev_open (struct net_device * dev )
2284
2284
{
2285
2285
struct airoha_gdm_port * port = netdev_priv (dev );
2286
- struct airoha_eth * eth = port -> eth ;
2286
+ struct airoha_qdma * qdma = port -> qdma ;
2287
2287
int err ;
2288
2288
2289
2289
netif_tx_start_all_queues (dev );
2290
- err = airoha_set_gdm_ports (eth , true);
2290
+ err = airoha_set_gdm_ports (qdma -> eth , true);
2291
2291
if (err )
2292
2292
return err ;
2293
2293
2294
2294
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 ),
2296
2296
GDM_STAG_EN_MASK );
2297
2297
else
2298
- airoha_fe_clear (eth , REG_GDM_INGRESS_CFG (port -> id ),
2298
+ airoha_fe_clear (qdma -> eth , REG_GDM_INGRESS_CFG (port -> id ),
2299
2299
GDM_STAG_EN_MASK );
2300
2300
2301
- airoha_qdma_set (& eth -> qdma [ 0 ] , REG_QDMA_GLOBAL_CFG ,
2301
+ airoha_qdma_set (qdma , REG_QDMA_GLOBAL_CFG ,
2302
2302
GLOBAL_CFG_TX_DMA_EN_MASK |
2303
2303
GLOBAL_CFG_RX_DMA_EN_MASK );
2304
2304
@@ -2308,15 +2308,15 @@ static int airoha_dev_open(struct net_device *dev)
2308
2308
static int airoha_dev_stop (struct net_device * dev )
2309
2309
{
2310
2310
struct airoha_gdm_port * port = netdev_priv (dev );
2311
- struct airoha_eth * eth = port -> eth ;
2311
+ struct airoha_qdma * qdma = port -> qdma ;
2312
2312
int err ;
2313
2313
2314
2314
netif_tx_disable (dev );
2315
- err = airoha_set_gdm_ports (eth , false);
2315
+ err = airoha_set_gdm_ports (qdma -> eth , false);
2316
2316
if (err )
2317
2317
return err ;
2318
2318
2319
- airoha_qdma_clear (& eth -> qdma [ 0 ] , REG_QDMA_GLOBAL_CFG ,
2319
+ airoha_qdma_clear (qdma , REG_QDMA_GLOBAL_CFG ,
2320
2320
GLOBAL_CFG_TX_DMA_EN_MASK |
2321
2321
GLOBAL_CFG_RX_DMA_EN_MASK );
2322
2322
@@ -2332,7 +2332,7 @@ static int airoha_dev_set_macaddr(struct net_device *dev, void *p)
2332
2332
if (err )
2333
2333
return err ;
2334
2334
2335
- airoha_set_macaddr (port -> eth , dev -> dev_addr );
2335
+ airoha_set_macaddr (port -> qdma -> eth , dev -> dev_addr );
2336
2336
2337
2337
return 0 ;
2338
2338
}
@@ -2341,7 +2341,7 @@ static int airoha_dev_init(struct net_device *dev)
2341
2341
{
2342
2342
struct airoha_gdm_port * port = netdev_priv (dev );
2343
2343
2344
- airoha_set_macaddr (port -> eth , dev -> dev_addr );
2344
+ airoha_set_macaddr (port -> qdma -> eth , dev -> dev_addr );
2345
2345
2346
2346
return 0 ;
2347
2347
}
@@ -2375,10 +2375,9 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
2375
2375
struct airoha_gdm_port * port = netdev_priv (dev );
2376
2376
u32 msg0 = 0 , msg1 , len = skb_headlen (skb );
2377
2377
int i , qid = skb_get_queue_mapping (skb );
2378
- struct airoha_eth * eth = port -> eth ;
2378
+ struct airoha_qdma * qdma = port -> qdma ;
2379
2379
u32 nr_frags = 1 + sinfo -> nr_frags ;
2380
2380
struct netdev_queue * txq ;
2381
- struct airoha_qdma * qdma ;
2382
2381
struct airoha_queue * q ;
2383
2382
void * data = skb -> data ;
2384
2383
u16 index ;
@@ -2406,7 +2405,6 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
2406
2405
msg1 = FIELD_PREP (QDMA_ETH_TXMSG_FPORT_MASK , fport ) |
2407
2406
FIELD_PREP (QDMA_ETH_TXMSG_METER_MASK , 0x7f );
2408
2407
2409
- qdma = & eth -> qdma [0 ];
2410
2408
q = & qdma -> q_tx [qid ];
2411
2409
if (WARN_ON_ONCE (!q -> ndesc ))
2412
2410
goto error ;
@@ -2489,7 +2487,7 @@ static void airoha_ethtool_get_drvinfo(struct net_device *dev,
2489
2487
struct ethtool_drvinfo * info )
2490
2488
{
2491
2489
struct airoha_gdm_port * port = netdev_priv (dev );
2492
- struct airoha_eth * eth = port -> eth ;
2490
+ struct airoha_eth * eth = port -> qdma -> eth ;
2493
2491
2494
2492
strscpy (info -> driver , eth -> dev -> driver -> name , sizeof (info -> driver ));
2495
2493
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)
2570
2568
{
2571
2569
const __be32 * id_ptr = of_get_property (np , "reg" , NULL );
2572
2570
struct airoha_gdm_port * port ;
2571
+ struct airoha_qdma * qdma ;
2573
2572
struct net_device * dev ;
2574
2573
int err , index ;
2575
2574
u32 id ;
@@ -2599,6 +2598,7 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
2599
2598
return - ENOMEM ;
2600
2599
}
2601
2600
2601
+ qdma = & eth -> qdma [index % AIROHA_MAX_NUM_QDMA ];
2602
2602
dev -> netdev_ops = & airoha_netdev_ops ;
2603
2603
dev -> ethtool_ops = & airoha_ethtool_ops ;
2604
2604
dev -> max_mtu = AIROHA_MAX_MTU ;
@@ -2608,6 +2608,7 @@ static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
2608
2608
NETIF_F_SG | NETIF_F_TSO ;
2609
2609
dev -> features |= dev -> hw_features ;
2610
2610
dev -> dev .of_node = np ;
2611
+ dev -> irq = qdma -> irq ;
2611
2612
SET_NETDEV_DEV (dev , eth -> dev );
2612
2613
2613
2614
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)
2623
2624
port = netdev_priv (dev );
2624
2625
u64_stats_init (& port -> stats .syncp );
2625
2626
spin_lock_init (& port -> stats .lock );
2627
+ port -> qdma = qdma ;
2626
2628
port -> dev = dev ;
2627
- port -> eth = eth ;
2628
2629
port -> id = id ;
2629
2630
eth -> ports [index ] = port ;
2630
2631
0 commit comments