@@ -367,6 +367,8 @@ static inline void slave_write(struct cpsw_slave *slave, u32 val, u32 offset)
367
367
struct cpsw_common {
368
368
struct device * dev ;
369
369
struct cpsw_platform_data data ;
370
+ struct napi_struct napi_rx ;
371
+ struct napi_struct napi_tx ;
370
372
struct cpsw_ss_regs __iomem * regs ;
371
373
struct cpsw_wr_regs __iomem * wr_regs ;
372
374
u8 __iomem * hw_stats ;
@@ -382,8 +384,6 @@ struct cpsw_common {
382
384
383
385
struct cpsw_priv {
384
386
struct net_device * ndev ;
385
- struct napi_struct napi_rx ;
386
- struct napi_struct napi_tx ;
387
387
struct device * dev ;
388
388
u32 msg_enable ;
389
389
u32 version ;
@@ -488,7 +488,7 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = {
488
488
#define CPSW_STATS_LEN ARRAY_SIZE(cpsw_gstrings_stats)
489
489
490
490
#define ndev_to_cpsw (ndev ) (((struct cpsw_priv *)netdev_priv(ndev))->cpsw)
491
- #define napi_to_priv (napi ) container_of(napi, struct cpsw_priv , napi)
491
+ #define napi_to_cpsw (napi ) container_of(napi, struct cpsw_common , napi)
492
492
#define for_each_slave (priv , func , arg ...) \
493
493
do { \
494
494
struct cpsw_slave *slave; \
@@ -752,8 +752,7 @@ static void cpsw_rx_handler(void *token, int len, int status)
752
752
753
753
static irqreturn_t cpsw_tx_interrupt (int irq , void * dev_id )
754
754
{
755
- struct cpsw_priv * priv = dev_id ;
756
- struct cpsw_common * cpsw = priv -> cpsw ;
755
+ struct cpsw_common * cpsw = dev_id ;
757
756
758
757
writel (0 , & cpsw -> wr_regs -> tx_en );
759
758
cpdma_ctlr_eoi (cpsw -> dma , CPDMA_EOI_TX );
@@ -763,14 +762,13 @@ static irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id)
763
762
cpsw -> tx_irq_disabled = true;
764
763
}
765
764
766
- napi_schedule (& priv -> napi_tx );
765
+ napi_schedule (& cpsw -> napi_tx );
767
766
return IRQ_HANDLED ;
768
767
}
769
768
770
769
static irqreturn_t cpsw_rx_interrupt (int irq , void * dev_id )
771
770
{
772
- struct cpsw_priv * priv = dev_id ;
773
- struct cpsw_common * cpsw = priv -> cpsw ;
771
+ struct cpsw_common * cpsw = dev_id ;
774
772
775
773
cpdma_ctlr_eoi (cpsw -> dma , CPDMA_EOI_RX );
776
774
writel (0 , & cpsw -> wr_regs -> rx_en );
@@ -780,15 +778,14 @@ static irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
780
778
cpsw -> rx_irq_disabled = true;
781
779
}
782
780
783
- napi_schedule (& priv -> napi_rx );
781
+ napi_schedule (& cpsw -> napi_rx );
784
782
return IRQ_HANDLED ;
785
783
}
786
784
787
785
static int cpsw_tx_poll (struct napi_struct * napi_tx , int budget )
788
786
{
789
- struct cpsw_priv * priv = napi_to_priv (napi_tx );
787
+ struct cpsw_common * cpsw = napi_to_cpsw (napi_tx );
790
788
int num_tx ;
791
- struct cpsw_common * cpsw = priv -> cpsw ;
792
789
793
790
num_tx = cpdma_chan_process (cpsw -> txch , budget );
794
791
if (num_tx < budget ) {
@@ -805,9 +802,8 @@ static int cpsw_tx_poll(struct napi_struct *napi_tx, int budget)
805
802
806
803
static int cpsw_rx_poll (struct napi_struct * napi_rx , int budget )
807
804
{
808
- struct cpsw_priv * priv = napi_to_priv (napi_rx );
805
+ struct cpsw_common * cpsw = napi_to_cpsw (napi_rx );
809
806
int num_rx ;
810
- struct cpsw_common * cpsw = priv -> cpsw ;
811
807
812
808
num_rx = cpdma_chan_process (cpsw -> rxch , budget );
813
809
if (num_rx < budget ) {
@@ -1283,7 +1279,6 @@ static int cpsw_ndo_open(struct net_device *ndev)
1283
1279
ALE_ALL_PORTS , ALE_ALL_PORTS , 0 , 0 );
1284
1280
1285
1281
if (!cpsw_common_res_usage_state (cpsw )) {
1286
- struct cpsw_priv * priv_sl0 = cpsw_get_slave_priv (cpsw , 0 );
1287
1282
int buf_num ;
1288
1283
1289
1284
/* setup tx dma to fixed prio and zero offset */
@@ -1299,8 +1294,8 @@ static int cpsw_ndo_open(struct net_device *ndev)
1299
1294
/* Enable internal fifo flow control */
1300
1295
writel (0x7 , & cpsw -> regs -> flow_control );
1301
1296
1302
- napi_enable (& priv_sl0 -> napi_rx );
1303
- napi_enable (& priv_sl0 -> napi_tx );
1297
+ napi_enable (& cpsw -> napi_rx );
1298
+ napi_enable (& cpsw -> napi_tx );
1304
1299
1305
1300
if (cpsw -> tx_irq_disabled ) {
1306
1301
cpsw -> tx_irq_disabled = false;
@@ -1373,10 +1368,8 @@ static int cpsw_ndo_stop(struct net_device *ndev)
1373
1368
netif_carrier_off (priv -> ndev );
1374
1369
1375
1370
if (cpsw_common_res_usage_state (cpsw ) <= 1 ) {
1376
- struct cpsw_priv * priv_sl0 = cpsw_get_slave_priv (cpsw , 0 );
1377
-
1378
- napi_disable (& priv_sl0 -> napi_rx );
1379
- napi_disable (& priv_sl0 -> napi_tx );
1371
+ napi_disable (& cpsw -> napi_rx );
1372
+ napi_disable (& cpsw -> napi_tx );
1380
1373
cpts_unregister (priv -> cpts );
1381
1374
cpsw_intr_disable (cpsw );
1382
1375
cpdma_ctlr_stop (cpsw -> dma );
@@ -1656,13 +1649,12 @@ static int cpsw_ndo_set_mac_address(struct net_device *ndev, void *p)
1656
1649
#ifdef CONFIG_NET_POLL_CONTROLLER
1657
1650
static void cpsw_ndo_poll_controller (struct net_device * ndev )
1658
1651
{
1659
- struct cpsw_priv * priv = netdev_priv (ndev );
1660
- struct cpsw_common * cpsw = priv -> cpsw ;
1652
+ struct cpsw_common * cpsw = ndev_to_cpsw (ndev );
1661
1653
1662
- cpsw_intr_disable (priv -> cpsw );
1663
- cpsw_rx_interrupt (cpsw -> irqs_table [0 ], priv );
1664
- cpsw_tx_interrupt (cpsw -> irqs_table [1 ], priv );
1665
- cpsw_intr_enable (priv -> cpsw );
1654
+ cpsw_intr_disable (cpsw );
1655
+ cpsw_rx_interrupt (cpsw -> irqs_table [0 ], cpsw );
1656
+ cpsw_tx_interrupt (cpsw -> irqs_table [1 ], cpsw );
1657
+ cpsw_intr_enable (cpsw );
1666
1658
}
1667
1659
#endif
1668
1660
@@ -2512,7 +2504,7 @@ static int cpsw_probe(struct platform_device *pdev)
2512
2504
2513
2505
cpsw -> irqs_table [0 ] = irq ;
2514
2506
ret = devm_request_irq (& pdev -> dev , irq , cpsw_rx_interrupt ,
2515
- 0 , dev_name (& pdev -> dev ), priv );
2507
+ 0 , dev_name (& pdev -> dev ), cpsw );
2516
2508
if (ret < 0 ) {
2517
2509
dev_err (priv -> dev , "error attaching irq (%d)\n" , ret );
2518
2510
goto clean_ale_ret ;
@@ -2527,7 +2519,7 @@ static int cpsw_probe(struct platform_device *pdev)
2527
2519
2528
2520
cpsw -> irqs_table [1 ] = irq ;
2529
2521
ret = devm_request_irq (& pdev -> dev , irq , cpsw_tx_interrupt ,
2530
- 0 , dev_name (& pdev -> dev ), priv );
2522
+ 0 , dev_name (& pdev -> dev ), cpsw );
2531
2523
if (ret < 0 ) {
2532
2524
dev_err (priv -> dev , "error attaching irq (%d)\n" , ret );
2533
2525
goto clean_ale_ret ;
@@ -2537,8 +2529,8 @@ static int cpsw_probe(struct platform_device *pdev)
2537
2529
2538
2530
ndev -> netdev_ops = & cpsw_netdev_ops ;
2539
2531
ndev -> ethtool_ops = & cpsw_ethtool_ops ;
2540
- netif_napi_add (ndev , & priv -> napi_rx , cpsw_rx_poll , CPSW_POLL_WEIGHT );
2541
- netif_tx_napi_add (ndev , & priv -> napi_tx , cpsw_tx_poll , CPSW_POLL_WEIGHT );
2532
+ netif_napi_add (ndev , & cpsw -> napi_rx , cpsw_rx_poll , CPSW_POLL_WEIGHT );
2533
+ netif_tx_napi_add (ndev , & cpsw -> napi_tx , cpsw_tx_poll , CPSW_POLL_WEIGHT );
2542
2534
2543
2535
/* register the network device */
2544
2536
SET_NETDEV_DEV (ndev , & pdev -> dev );
0 commit comments