@@ -728,7 +728,7 @@ struct airoha_queue_entry {
728
728
};
729
729
730
730
struct airoha_queue {
731
- struct airoha_eth * eth ;
731
+ struct airoha_qdma * qdma ;
732
732
733
733
/* protect concurrent queue accesses */
734
734
spinlock_t lock ;
@@ -747,7 +747,7 @@ struct airoha_queue {
747
747
};
748
748
749
749
struct airoha_tx_irq_queue {
750
- struct airoha_eth * eth ;
750
+ struct airoha_qdma * qdma ;
751
751
752
752
struct napi_struct napi ;
753
753
u32 * q ;
@@ -784,6 +784,7 @@ struct airoha_hw_stats {
784
784
};
785
785
786
786
struct airoha_qdma {
787
+ struct airoha_eth * eth ;
787
788
void __iomem * regs ;
788
789
789
790
/* protect concurrent irqmask accesses */
@@ -1388,8 +1389,8 @@ static int airoha_fe_init(struct airoha_eth *eth)
1388
1389
static int airoha_qdma_fill_rx_queue (struct airoha_queue * q )
1389
1390
{
1390
1391
enum dma_data_direction dir = page_pool_get_dma_dir (q -> page_pool );
1391
- struct airoha_qdma * qdma = & q -> eth -> qdma [ 0 ] ;
1392
- struct airoha_eth * eth = q -> eth ;
1392
+ struct airoha_qdma * qdma = q -> qdma ;
1393
+ struct airoha_eth * eth = qdma -> eth ;
1393
1394
int qid = q - & qdma -> q_rx [0 ];
1394
1395
int nframes = 0 ;
1395
1396
@@ -1457,8 +1458,8 @@ static int airoha_qdma_get_gdm_port(struct airoha_eth *eth,
1457
1458
static int airoha_qdma_rx_process (struct airoha_queue * q , int budget )
1458
1459
{
1459
1460
enum dma_data_direction dir = page_pool_get_dma_dir (q -> page_pool );
1460
- struct airoha_qdma * qdma = & q -> eth -> qdma [ 0 ] ;
1461
- struct airoha_eth * eth = q -> eth ;
1461
+ struct airoha_qdma * qdma = q -> qdma ;
1462
+ struct airoha_eth * eth = qdma -> eth ;
1462
1463
int qid = q - & qdma -> q_rx [0 ];
1463
1464
int done = 0 ;
1464
1465
@@ -1521,7 +1522,6 @@ static int airoha_qdma_rx_process(struct airoha_queue *q, int budget)
1521
1522
static int airoha_qdma_rx_napi_poll (struct napi_struct * napi , int budget )
1522
1523
{
1523
1524
struct airoha_queue * q = container_of (napi , struct airoha_queue , napi );
1524
- struct airoha_qdma * qdma = & q -> eth -> qdma [0 ];
1525
1525
int cur , done = 0 ;
1526
1526
1527
1527
do {
@@ -1530,14 +1530,13 @@ static int airoha_qdma_rx_napi_poll(struct napi_struct *napi, int budget)
1530
1530
} while (cur && done < budget );
1531
1531
1532
1532
if (done < budget && napi_complete (napi ))
1533
- airoha_qdma_irq_enable (qdma , QDMA_INT_REG_IDX1 ,
1533
+ airoha_qdma_irq_enable (q -> qdma , QDMA_INT_REG_IDX1 ,
1534
1534
RX_DONE_INT_MASK );
1535
1535
1536
1536
return done ;
1537
1537
}
1538
1538
1539
- static int airoha_qdma_init_rx_queue (struct airoha_eth * eth ,
1540
- struct airoha_queue * q ,
1539
+ static int airoha_qdma_init_rx_queue (struct airoha_queue * q ,
1541
1540
struct airoha_qdma * qdma , int ndesc )
1542
1541
{
1543
1542
const struct page_pool_params pp_params = {
@@ -1547,15 +1546,16 @@ static int airoha_qdma_init_rx_queue(struct airoha_eth *eth,
1547
1546
.dma_dir = DMA_FROM_DEVICE ,
1548
1547
.max_len = PAGE_SIZE ,
1549
1548
.nid = NUMA_NO_NODE ,
1550
- .dev = eth -> dev ,
1549
+ .dev = qdma -> eth -> dev ,
1551
1550
.napi = & q -> napi ,
1552
1551
};
1552
+ struct airoha_eth * eth = qdma -> eth ;
1553
1553
int qid = q - & qdma -> q_rx [0 ], thr ;
1554
1554
dma_addr_t dma_addr ;
1555
1555
1556
1556
q -> buf_size = PAGE_SIZE / 2 ;
1557
1557
q -> ndesc = ndesc ;
1558
- q -> eth = eth ;
1558
+ q -> qdma = qdma ;
1559
1559
1560
1560
q -> entry = devm_kzalloc (eth -> dev , q -> ndesc * sizeof (* q -> entry ),
1561
1561
GFP_KERNEL );
@@ -1595,7 +1595,7 @@ static int airoha_qdma_init_rx_queue(struct airoha_eth *eth,
1595
1595
1596
1596
static void airoha_qdma_cleanup_rx_queue (struct airoha_queue * q )
1597
1597
{
1598
- struct airoha_eth * eth = q -> eth ;
1598
+ struct airoha_eth * eth = q -> qdma -> eth ;
1599
1599
1600
1600
while (q -> queued ) {
1601
1601
struct airoha_queue_entry * e = & q -> entry [q -> tail ];
@@ -1609,8 +1609,7 @@ static void airoha_qdma_cleanup_rx_queue(struct airoha_queue *q)
1609
1609
}
1610
1610
}
1611
1611
1612
- static int airoha_qdma_init_rx (struct airoha_eth * eth ,
1613
- struct airoha_qdma * qdma )
1612
+ static int airoha_qdma_init_rx (struct airoha_qdma * qdma )
1614
1613
{
1615
1614
int i ;
1616
1615
@@ -1622,8 +1621,8 @@ static int airoha_qdma_init_rx(struct airoha_eth *eth,
1622
1621
continue ;
1623
1622
}
1624
1623
1625
- err = airoha_qdma_init_rx_queue (eth , & qdma -> q_rx [i ],
1626
- qdma , RX_DSCP_NUM (i ));
1624
+ err = airoha_qdma_init_rx_queue (& qdma -> q_rx [i ], qdma ,
1625
+ RX_DSCP_NUM (i ));
1627
1626
if (err )
1628
1627
return err ;
1629
1628
}
@@ -1639,9 +1638,9 @@ static int airoha_qdma_tx_napi_poll(struct napi_struct *napi, int budget)
1639
1638
int id , done = 0 ;
1640
1639
1641
1640
irq_q = container_of (napi , struct airoha_tx_irq_queue , napi );
1642
- eth = irq_q -> eth ;
1643
- qdma = & eth -> qdma [0 ];
1641
+ qdma = irq_q -> qdma ;
1644
1642
id = irq_q - & qdma -> q_tx_irq [0 ];
1643
+ eth = qdma -> eth ;
1645
1644
1646
1645
while (irq_q -> queued > 0 && done < budget ) {
1647
1646
u32 qid , last , val = irq_q -> q [irq_q -> head ];
@@ -1723,16 +1722,16 @@ static int airoha_qdma_tx_napi_poll(struct napi_struct *napi, int budget)
1723
1722
return done ;
1724
1723
}
1725
1724
1726
- static int airoha_qdma_init_tx_queue (struct airoha_eth * eth ,
1727
- struct airoha_queue * q ,
1725
+ static int airoha_qdma_init_tx_queue (struct airoha_queue * q ,
1728
1726
struct airoha_qdma * qdma , int size )
1729
1727
{
1728
+ struct airoha_eth * eth = qdma -> eth ;
1730
1729
int i , qid = q - & qdma -> q_tx [0 ];
1731
1730
dma_addr_t dma_addr ;
1732
1731
1733
1732
spin_lock_init (& q -> lock );
1734
1733
q -> ndesc = size ;
1735
- q -> eth = eth ;
1734
+ q -> qdma = qdma ;
1736
1735
q -> free_thr = 1 + MAX_SKB_FRAGS ;
1737
1736
1738
1737
q -> entry = devm_kzalloc (eth -> dev , q -> ndesc * sizeof (* q -> entry ),
@@ -1761,11 +1760,11 @@ static int airoha_qdma_init_tx_queue(struct airoha_eth *eth,
1761
1760
return 0 ;
1762
1761
}
1763
1762
1764
- static int airoha_qdma_tx_irq_init (struct airoha_eth * eth ,
1765
- struct airoha_tx_irq_queue * irq_q ,
1763
+ static int airoha_qdma_tx_irq_init (struct airoha_tx_irq_queue * irq_q ,
1766
1764
struct airoha_qdma * qdma , int size )
1767
1765
{
1768
1766
int id = irq_q - & qdma -> q_tx_irq [0 ];
1767
+ struct airoha_eth * eth = qdma -> eth ;
1769
1768
dma_addr_t dma_addr ;
1770
1769
1771
1770
netif_napi_add_tx (eth -> napi_dev , & irq_q -> napi ,
@@ -1777,7 +1776,7 @@ static int airoha_qdma_tx_irq_init(struct airoha_eth *eth,
1777
1776
1778
1777
memset (irq_q -> q , 0xff , size * sizeof (u32 ));
1779
1778
irq_q -> size = size ;
1780
- irq_q -> eth = eth ;
1779
+ irq_q -> qdma = qdma ;
1781
1780
1782
1781
airoha_qdma_wr (qdma , REG_TX_IRQ_BASE (id ), dma_addr );
1783
1782
airoha_qdma_rmw (qdma , REG_TX_IRQ_CFG (id ), TX_IRQ_DEPTH_MASK ,
@@ -1788,21 +1787,20 @@ static int airoha_qdma_tx_irq_init(struct airoha_eth *eth,
1788
1787
return 0 ;
1789
1788
}
1790
1789
1791
- static int airoha_qdma_init_tx (struct airoha_eth * eth ,
1792
- struct airoha_qdma * qdma )
1790
+ static int airoha_qdma_init_tx (struct airoha_qdma * qdma )
1793
1791
{
1794
1792
int i , err ;
1795
1793
1796
1794
for (i = 0 ; i < ARRAY_SIZE (qdma -> q_tx_irq ); i ++ ) {
1797
- err = airoha_qdma_tx_irq_init (eth , & qdma -> q_tx_irq [i ],
1798
- qdma , IRQ_QUEUE_LEN (i ));
1795
+ err = airoha_qdma_tx_irq_init (& qdma -> q_tx_irq [i ], qdma ,
1796
+ IRQ_QUEUE_LEN (i ));
1799
1797
if (err )
1800
1798
return err ;
1801
1799
}
1802
1800
1803
1801
for (i = 0 ; i < ARRAY_SIZE (qdma -> q_tx ); i ++ ) {
1804
- err = airoha_qdma_init_tx_queue (eth , & qdma -> q_tx [i ],
1805
- qdma , TX_DSCP_NUM );
1802
+ err = airoha_qdma_init_tx_queue (& qdma -> q_tx [i ], qdma ,
1803
+ TX_DSCP_NUM );
1806
1804
if (err )
1807
1805
return err ;
1808
1806
}
@@ -1812,7 +1810,7 @@ static int airoha_qdma_init_tx(struct airoha_eth *eth,
1812
1810
1813
1811
static void airoha_qdma_cleanup_tx_queue (struct airoha_queue * q )
1814
1812
{
1815
- struct airoha_eth * eth = q -> eth ;
1813
+ struct airoha_eth * eth = q -> qdma -> eth ;
1816
1814
1817
1815
spin_lock_bh (& q -> lock );
1818
1816
while (q -> queued ) {
@@ -1829,9 +1827,9 @@ static void airoha_qdma_cleanup_tx_queue(struct airoha_queue *q)
1829
1827
spin_unlock_bh (& q -> lock );
1830
1828
}
1831
1829
1832
- static int airoha_qdma_init_hfwd_queues (struct airoha_eth * eth ,
1833
- struct airoha_qdma * qdma )
1830
+ static int airoha_qdma_init_hfwd_queues (struct airoha_qdma * qdma )
1834
1831
{
1832
+ struct airoha_eth * eth = qdma -> eth ;
1835
1833
dma_addr_t dma_addr ;
1836
1834
u32 status ;
1837
1835
int size ;
@@ -1869,8 +1867,7 @@ static int airoha_qdma_init_hfwd_queues(struct airoha_eth *eth,
1869
1867
REG_LMGR_INIT_CFG );
1870
1868
}
1871
1869
1872
- static void airoha_qdma_init_qos (struct airoha_eth * eth ,
1873
- struct airoha_qdma * qdma )
1870
+ static void airoha_qdma_init_qos (struct airoha_qdma * qdma )
1874
1871
{
1875
1872
airoha_qdma_clear (qdma , REG_TXWRR_MODE_CFG , TWRR_WEIGHT_SCALE_MASK );
1876
1873
airoha_qdma_set (qdma , REG_TXWRR_MODE_CFG , TWRR_WEIGHT_BASE_MASK );
@@ -1920,8 +1917,7 @@ static void airoha_qdma_init_qos(struct airoha_eth *eth,
1920
1917
FIELD_PREP (SLA_SLOW_TICK_RATIO_MASK , 40 ));
1921
1918
}
1922
1919
1923
- static int airoha_qdma_hw_init (struct airoha_eth * eth ,
1924
- struct airoha_qdma * qdma )
1920
+ static int airoha_qdma_hw_init (struct airoha_qdma * qdma )
1925
1921
{
1926
1922
int i ;
1927
1923
@@ -1958,7 +1954,7 @@ static int airoha_qdma_hw_init(struct airoha_eth *eth,
1958
1954
GLOBAL_CFG_TX_WB_DONE_MASK |
1959
1955
FIELD_PREP (GLOBAL_CFG_MAX_ISSUE_NUM_MASK , 2 ));
1960
1956
1961
- airoha_qdma_init_qos (eth , qdma );
1957
+ airoha_qdma_init_qos (qdma );
1962
1958
1963
1959
/* disable qdma rx delay interrupt */
1964
1960
for (i = 0 ; i < ARRAY_SIZE (qdma -> q_rx ); i ++ ) {
@@ -2034,6 +2030,8 @@ static int airoha_qdma_init(struct platform_device *pdev,
2034
2030
int err ;
2035
2031
2036
2032
spin_lock_init (& qdma -> irq_lock );
2033
+ qdma -> eth = eth ;
2034
+
2037
2035
qdma -> irq = platform_get_irq (pdev , 0 );
2038
2036
if (qdma -> irq < 0 )
2039
2037
return qdma -> irq ;
@@ -2043,19 +2041,19 @@ static int airoha_qdma_init(struct platform_device *pdev,
2043
2041
if (err )
2044
2042
return err ;
2045
2043
2046
- err = airoha_qdma_init_rx (eth , qdma );
2044
+ err = airoha_qdma_init_rx (qdma );
2047
2045
if (err )
2048
2046
return err ;
2049
2047
2050
- err = airoha_qdma_init_tx (eth , qdma );
2048
+ err = airoha_qdma_init_tx (qdma );
2051
2049
if (err )
2052
2050
return err ;
2053
2051
2054
- err = airoha_qdma_init_hfwd_queues (eth , qdma );
2052
+ err = airoha_qdma_init_hfwd_queues (qdma );
2055
2053
if (err )
2056
2054
return err ;
2057
2055
2058
- err = airoha_qdma_hw_init (eth , qdma );
2056
+ err = airoha_qdma_hw_init (qdma );
2059
2057
if (err )
2060
2058
return err ;
2061
2059
0 commit comments