737-03-net-ethernet-mtk_eth_soc-rely-on-num_devs-and-remove.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. From 4e35e80750b33727e606be9e7ce447bde2e0deb7 Mon Sep 17 00:00:00 2001
  2. From: Lorenzo Bianconi <[email protected]>
  3. Date: Tue, 7 Mar 2023 15:55:35 +0000
  4. Subject: [PATCH 3/7] net: ethernet: mtk_eth_soc: rely on num_devs and remove
  5. MTK_MAC_COUNT
  6. Get rid of MTK_MAC_COUNT since it is a duplicated of eth->soc->num_devs.
  7. Signed-off-by: Lorenzo Bianconi <[email protected]>
  8. Signed-off-by: Daniel Golle <[email protected]>
  9. ---
  10. drivers/net/ethernet/mediatek/mtk_eth_soc.c | 30 ++++++++++-----------
  11. drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 -
  12. 2 files changed, 15 insertions(+), 16 deletions(-)
  13. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  14. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
  15. @@ -900,7 +900,7 @@ static void mtk_stats_update(struct mtk_
  16. {
  17. int i;
  18. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  19. + for (i = 0; i < eth->soc->num_devs; i++) {
  20. if (!eth->mac[i] || !eth->mac[i]->hw_stats)
  21. continue;
  22. if (spin_trylock(&eth->mac[i]->hw_stats->stats_lock)) {
  23. @@ -1403,7 +1403,7 @@ static int mtk_queue_stopped(struct mtk_
  24. {
  25. int i;
  26. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  27. + for (i = 0; i < eth->soc->num_devs; i++) {
  28. if (!eth->netdev[i])
  29. continue;
  30. if (netif_queue_stopped(eth->netdev[i]))
  31. @@ -1417,7 +1417,7 @@ static void mtk_wake_queue(struct mtk_et
  32. {
  33. int i;
  34. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  35. + for (i = 0; i < eth->soc->num_devs; i++) {
  36. if (!eth->netdev[i])
  37. continue;
  38. netif_tx_wake_all_queues(eth->netdev[i]);
  39. @@ -1908,7 +1908,7 @@ static int mtk_poll_rx(struct napi_struc
  40. !(trxd.rxd4 & RX_DMA_SPECIAL_TAG))
  41. mac = RX_DMA_GET_SPORT(trxd.rxd4) - 1;
  42. - if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT ||
  43. + if (unlikely(mac < 0 || mac >= eth->soc->num_devs ||
  44. !eth->netdev[mac]))
  45. goto release_desc;
  46. @@ -2937,7 +2937,7 @@ static void mtk_dma_free(struct mtk_eth
  47. const struct mtk_soc_data *soc = eth->soc;
  48. int i;
  49. - for (i = 0; i < MTK_MAC_COUNT; i++)
  50. + for (i = 0; i < soc->num_devs; i++)
  51. if (eth->netdev[i])
  52. netdev_reset_queue(eth->netdev[i]);
  53. if (eth->scratch_ring) {
  54. @@ -3091,7 +3091,7 @@ static void mtk_gdm_config(struct mtk_et
  55. if (MTK_HAS_CAPS(eth->soc->caps, MTK_SOC_MT7628))
  56. return;
  57. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  58. + for (i = 0; i < eth->soc->num_devs; i++) {
  59. u32 val = mtk_r32(eth, MTK_GDMA_FWD_CFG(i));
  60. /* default setup the forward port to send frame to PDMA */
  61. @@ -3704,7 +3704,7 @@ static int mtk_hw_init(struct mtk_eth *e
  62. * up with the more appropriate value when mtk_mac_config call is being
  63. * invoked.
  64. */
  65. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  66. + for (i = 0; i < eth->soc->num_devs; i++) {
  67. struct net_device *dev = eth->netdev[i];
  68. mtk_w32(eth, MAC_MCR_FORCE_LINK_DOWN, MTK_MAC_MCR(i));
  69. @@ -3892,7 +3892,7 @@ static void mtk_pending_work(struct work
  70. mtk_prepare_for_reset(eth);
  71. /* stop all devices to make sure that dma is properly shut down */
  72. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  73. + for (i = 0; i < eth->soc->num_devs; i++) {
  74. if (!eth->netdev[i] || !netif_running(eth->netdev[i]))
  75. continue;
  76. @@ -3908,7 +3908,7 @@ static void mtk_pending_work(struct work
  77. mtk_hw_init(eth, true);
  78. /* restart DMA and enable IRQs */
  79. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  80. + for (i = 0; i < eth->soc->num_devs; i++) {
  81. if (!test_bit(i, &restart))
  82. continue;
  83. @@ -3936,7 +3936,7 @@ static int mtk_free_dev(struct mtk_eth *
  84. {
  85. int i;
  86. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  87. + for (i = 0; i < eth->soc->num_devs; i++) {
  88. if (!eth->netdev[i])
  89. continue;
  90. free_netdev(eth->netdev[i]);
  91. @@ -3955,7 +3955,7 @@ static int mtk_unreg_dev(struct mtk_eth
  92. {
  93. int i;
  94. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  95. + for (i = 0; i < eth->soc->num_devs; i++) {
  96. struct mtk_mac *mac;
  97. if (!eth->netdev[i])
  98. continue;
  99. @@ -4259,7 +4259,7 @@ static int mtk_add_mac(struct mtk_eth *e
  100. }
  101. id = be32_to_cpup(_id);
  102. - if (id >= MTK_MAC_COUNT) {
  103. + if (id >= eth->soc->num_devs) {
  104. dev_err(eth->dev, "%d is not a valid mac id\n", id);
  105. return -EINVAL;
  106. }
  107. @@ -4400,7 +4400,7 @@ void mtk_eth_set_dma_device(struct mtk_e
  108. rtnl_lock();
  109. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  110. + for (i = 0; i < eth->soc->num_devs; i++) {
  111. dev = eth->netdev[i];
  112. if (!dev || !(dev->flags & IFF_UP))
  113. @@ -4727,7 +4727,7 @@ static int mtk_remove(struct platform_de
  114. int i;
  115. /* stop all devices to make sure that dma is properly shut down */
  116. - for (i = 0; i < MTK_MAC_COUNT; i++) {
  117. + for (i = 0; i < eth->soc->num_devs; i++) {
  118. if (!eth->netdev[i])
  119. continue;
  120. mtk_stop(eth->netdev[i]);
  121. --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
  122. +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
  123. @@ -33,7 +33,6 @@
  124. #define MTK_TX_DMA_BUF_LEN_V2 0xffff
  125. #define MTK_QDMA_RING_SIZE 2048
  126. #define MTK_DMA_SIZE 512
  127. -#define MTK_MAC_COUNT 2
  128. #define MTK_RX_ETH_HLEN (VLAN_ETH_HLEN + ETH_FCS_LEN)
  129. #define MTK_RX_HLEN (NET_SKB_PAD + MTK_RX_ETH_HLEN + NET_IP_ALIGN)
  130. #define MTK_DMA_DUMMY_DESC 0xffffffff