ramips: ralink-eth: add support for 5.4 kernel
authorChuanhong Guo <gch981213@gmail.com>
Thu, 9 Apr 2020 09:59:09 +0000 (17:59 +0800)
committerChuanhong Guo <gch981213@gmail.com>
Sun, 12 Apr 2020 14:27:18 +0000 (22:27 +0800)
Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
target/linux/ramips/files/drivers/net/ethernet/ralink/mdio.c
target/linux/ramips/files/drivers/net/ethernet/ralink/mtk_eth_soc.c

index 28c92501627c5317b492cd27f3b58b013632e792..74babc59a029b2017445005d37eb0c857ba193d8 100644 (file)
@@ -88,8 +88,13 @@ int fe_connect_phy_node(struct fe_priv *priv, struct device_node *phy_node, int
                return -ENODEV;
        }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
        phydev->supported &= PHY_GBIT_FEATURES;
        phydev->advertising = phydev->supported;
+#else
+       phy_set_max_speed(phydev, SPEED_1000);
+       linkmode_copy(phydev->advertising, phydev->supported);
+#endif
        phydev->no_auto_carrier_off = 1;
 
        dev_info(priv->dev,
@@ -110,9 +115,18 @@ static void phy_init(struct fe_priv *priv, struct phy_device *phy)
        phy->autoneg = AUTONEG_ENABLE;
        phy->speed = 0;
        phy->duplex = 0;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
        phy->supported &= IS_ENABLED(CONFIG_NET_RALINK_MDIO_MT7620) ?
                        PHY_GBIT_FEATURES : PHY_BASIC_FEATURES;
        phy->advertising = phy->supported | ADVERTISED_Autoneg;
+#else
+       phy_set_max_speed(phy, IS_ENABLED(CONFIG_NET_RALINK_MDIO_MT7620) ?
+                                      SPEED_1000 :
+                                      SPEED_100);
+       linkmode_copy(phy->advertising, phy->supported);
+       linkmode_set_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, phy->advertising);
+#endif
 
        phy_start_aneg(phy);
 }
index a088fe7fd594ec27f8b8a53abf5b18f27ea08adc..7f09bb10de8940f3713ede4f4ee8d77770672146 100644 (file)
@@ -715,11 +715,19 @@ next_frag:
        /* TX SG offload */
        nr_frags = skb_shinfo(skb)->nr_frags;
        for (i = 0; i < nr_frags; i++) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
                struct skb_frag_struct *frag;
+#else
+               skb_frag_t *frag;
+#endif
 
                frag = &skb_shinfo(skb)->frags[i];
                if (fe_tx_dma_map_page(ring, &st, skb_frag_page(frag),
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
                                       frag->page_offset, skb_frag_size(frag)))
+#else
+                                      skb_frag_off(frag), skb_frag_size(frag)))
+#endif
                        goto err_dma;
        }
 
@@ -754,7 +762,11 @@ next_frag:
                        netif_wake_queue(dev);
        }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)
        if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || !head->xmit_more)
+#else
+       if (netif_xmit_stopped(netdev_get_tx_queue(dev, 0)) || !netdev_xmit_more())
+#endif
                fe_reg_w32(ring->tx_next_idx, FE_REG_TX_CTX_IDX0);
 
        return 0;
@@ -813,14 +825,22 @@ static inline int fe_cal_txd_req(struct sk_buff *skb)
 {
        struct sk_buff *head = skb;
        int i, nfrags = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
        struct skb_frag_struct *frag;
+#else
+       skb_frag_t *frag;
+#endif
 
 next_frag:
        nfrags++;
        if (skb_is_gso(skb)) {
                for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
                        frag = &skb_shinfo(skb)->frags[i];
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
                        nfrags += DIV_ROUND_UP(frag->size, TX_DMA_BUF_LEN);
+#else
+                       nfrags += DIV_ROUND_UP(skb_frag_size(frag), TX_DMA_BUF_LEN);
+#endif
                }
        } else {
                nfrags += skb_shinfo(skb)->nr_frags;