net: txgbe: Distinguish between 40G and 25G devices
authorJiawen Wu <jiawenwu@trustnetic.com>
Wed, 21 May 2025 06:43:56 +0000 (14:43 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Mon, 26 May 2025 15:25:42 +0000 (17:25 +0200)
For the following patches to support PHYLINK for AML 25G devices,
separate MAC type wx_mac_aml40 to maintain the driver of 40G devices.
Because 40G devices will complete support later, not now.

And this patch makes the 25G devices use some PHYLINK interfaces, but it
is not yet create PHYLINK and cannot be used on its own. It is just
preparation for the next patches.

Signed-off-by: Jiawen Wu <jiawenwu@trustnetic.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/592B1A6920867D0C+20250521064402.22348-4-jiawenwu@trustnetic.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/wangxun/libwx/wx_ethtool.c
drivers/net/ethernet/wangxun/libwx/wx_hw.c
drivers/net/ethernet/wangxun/libwx/wx_lib.c
drivers/net/ethernet/wangxun/libwx/wx_type.h
drivers/net/ethernet/wangxun/txgbe/txgbe_irq.c
drivers/net/ethernet/wangxun/txgbe/txgbe_main.c
drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c
drivers/net/ethernet/wangxun/txgbe/txgbe_type.h

index d58d7a8..86c0159 100644 (file)
@@ -219,7 +219,7 @@ int wx_nway_reset(struct net_device *netdev)
 {
        struct wx *wx = netdev_priv(netdev);
 
-       if (wx->mac.type == wx_mac_aml)
+       if (wx->mac.type == wx_mac_aml40)
                return -EOPNOTSUPP;
 
        return phylink_ethtool_nway_reset(wx->phylink);
@@ -231,7 +231,7 @@ int wx_get_link_ksettings(struct net_device *netdev,
 {
        struct wx *wx = netdev_priv(netdev);
 
-       if (wx->mac.type == wx_mac_aml)
+       if (wx->mac.type == wx_mac_aml40)
                return -EOPNOTSUPP;
 
        return phylink_ethtool_ksettings_get(wx->phylink, cmd);
@@ -243,7 +243,7 @@ int wx_set_link_ksettings(struct net_device *netdev,
 {
        struct wx *wx = netdev_priv(netdev);
 
-       if (wx->mac.type == wx_mac_aml)
+       if (wx->mac.type == wx_mac_aml40)
                return -EOPNOTSUPP;
 
        return phylink_ethtool_ksettings_set(wx->phylink, cmd);
@@ -255,7 +255,7 @@ void wx_get_pauseparam(struct net_device *netdev,
 {
        struct wx *wx = netdev_priv(netdev);
 
-       if (wx->mac.type == wx_mac_aml)
+       if (wx->mac.type == wx_mac_aml40)
                return;
 
        phylink_ethtool_get_pauseparam(wx->phylink, pause);
@@ -267,7 +267,7 @@ int wx_set_pauseparam(struct net_device *netdev,
 {
        struct wx *wx = netdev_priv(netdev);
 
-       if (wx->mac.type == wx_mac_aml)
+       if (wx->mac.type == wx_mac_aml40)
                return -EOPNOTSUPP;
 
        return phylink_ethtool_set_pauseparam(wx->phylink, pause);
@@ -345,6 +345,7 @@ int wx_set_coalesce(struct net_device *netdev,
                max_eitr = WX_SP_MAX_EITR;
                break;
        case wx_mac_aml:
+       case wx_mac_aml40:
                max_eitr = WX_AML_MAX_EITR;
                break;
        default:
@@ -375,6 +376,7 @@ int wx_set_coalesce(struct net_device *netdev,
                switch (wx->mac.type) {
                case wx_mac_sp:
                case wx_mac_aml:
+               case wx_mac_aml40:
                        tx_itr_param = WX_12K_ITR;
                        break;
                default:
index 1c5c14a..7a3467b 100644 (file)
@@ -695,6 +695,7 @@ void wx_init_eeprom_params(struct wx *wx)
        switch (wx->mac.type) {
        case wx_mac_sp:
        case wx_mac_aml:
+       case wx_mac_aml40:
                if (wx_read_ee_hostif(wx, WX_SW_REGION_PTR, &data)) {
                        wx_err(wx, "NVM Read Error\n");
                        return;
index eab16c5..68e7cfe 100644 (file)
@@ -1959,6 +1959,7 @@ static int wx_alloc_q_vector(struct wx *wx,
        switch (wx->mac.type) {
        case wx_mac_sp:
        case wx_mac_aml:
+       case wx_mac_aml40:
                default_itr = WX_12K_ITR;
                break;
        default:
@@ -2327,6 +2328,7 @@ void wx_write_eitr(struct wx_q_vector *q_vector)
                itr_reg = q_vector->itr & WX_SP_MAX_EITR;
                break;
        case wx_mac_aml:
+       case wx_mac_aml40:
                itr_reg = (q_vector->itr >> 3) & WX_AML_MAX_EITR;
                break;
        default:
index 6563d30..b4275ba 100644 (file)
@@ -838,6 +838,7 @@ enum wx_mac_type {
        wx_mac_sp,
        wx_mac_em,
        wx_mac_aml,
+       wx_mac_aml40,
 };
 
 enum wx_media_type {
index 19878f0..f53a5d0 100644 (file)
@@ -176,7 +176,7 @@ static void txgbe_del_irq_domain(struct txgbe *txgbe)
 
 void txgbe_free_misc_irq(struct txgbe *txgbe)
 {
-       if (txgbe->wx->mac.type == wx_mac_aml)
+       if (txgbe->wx->mac.type == wx_mac_aml40)
                return;
 
        free_irq(txgbe->link_irq, txgbe);
@@ -190,7 +190,7 @@ int txgbe_setup_misc_irq(struct txgbe *txgbe)
        struct wx *wx = txgbe->wx;
        int hwirq, err;
 
-       if (wx->mac.type == wx_mac_aml)
+       if (wx->mac.type == wx_mac_aml40)
                goto skip_sp_irq;
 
        txgbe->misc.nirqs = TXGBE_IRQ_MAX;
index 0c81d8f..ca3dbc4 100644 (file)
@@ -91,6 +91,7 @@ static int txgbe_enumerate_functions(struct wx *wx)
 static void txgbe_up_complete(struct wx *wx)
 {
        struct net_device *netdev = wx->netdev;
+       u32 reg;
 
        wx_control_hw(wx, true);
        wx_configure_vectors(wx);
@@ -99,17 +100,21 @@ static void txgbe_up_complete(struct wx *wx)
        smp_mb__before_atomic();
        wx_napi_enable_all(wx);
 
-       if (wx->mac.type == wx_mac_aml) {
-               u32 reg;
-
+       switch (wx->mac.type) {
+       case wx_mac_aml40:
                reg = rd32(wx, TXGBE_AML_MAC_TX_CFG);
                reg &= ~TXGBE_AML_MAC_TX_CFG_SPEED_MASK;
-               reg |= TXGBE_AML_MAC_TX_CFG_SPEED_25G;
+               reg |= TXGBE_AML_MAC_TX_CFG_SPEED_40G;
                wr32(wx, WX_MAC_TX_CFG, reg);
                txgbe_enable_sec_tx_path(wx);
                netif_carrier_on(wx->netdev);
-       } else {
+               break;
+       case wx_mac_aml:
+       case wx_mac_sp:
                phylink_start(wx->phylink);
+               break;
+       default:
+               break;
        }
 
        /* clear any pending interrupts, may auto mask */
@@ -207,10 +212,18 @@ void txgbe_down(struct wx *wx)
 {
        txgbe_disable_device(wx);
        txgbe_reset(wx);
-       if (wx->mac.type == wx_mac_aml)
+
+       switch (wx->mac.type) {
+       case wx_mac_aml40:
                netif_carrier_off(wx->netdev);
-       else
+               break;
+       case wx_mac_aml:
+       case wx_mac_sp:
                phylink_stop(wx->phylink);
+               break;
+       default:
+               break;
+       }
 
        wx_clean_all_tx_rings(wx);
        wx_clean_all_rx_rings(wx);
@@ -240,9 +253,11 @@ static void txgbe_init_type_code(struct wx *wx)
        case TXGBE_DEV_ID_AML5110:
        case TXGBE_DEV_ID_AML5025:
        case TXGBE_DEV_ID_AML5125:
+               wx->mac.type = wx_mac_aml;
+               break;
        case TXGBE_DEV_ID_AML5040:
        case TXGBE_DEV_ID_AML5140:
-               wx->mac.type = wx_mac_aml;
+               wx->mac.type = wx_mac_aml40;
                break;
        default:
                wx->mac.type = wx_mac_unknown;
@@ -341,6 +356,7 @@ static int txgbe_sw_init(struct wx *wx)
        case wx_mac_sp:
                break;
        case wx_mac_aml:
+       case wx_mac_aml40:
                set_bit(WX_FLAG_SWFW_RING, wx->flags);
                wx->swfw_index = 0;
                break;
index b5ae7c2..ece378f 100644 (file)
@@ -573,11 +573,17 @@ int txgbe_init_phy(struct txgbe *txgbe)
        struct wx *wx = txgbe->wx;
        int ret;
 
-       if (wx->mac.type == wx_mac_aml)
+       switch (wx->mac.type) {
+       case wx_mac_aml40:
+       case wx_mac_aml:
                return 0;
-
-       if (txgbe->wx->media_type == wx_media_copper)
-               return txgbe_ext_phy_init(txgbe);
+       case wx_mac_sp:
+               if (wx->media_type == wx_media_copper)
+                       return txgbe_ext_phy_init(txgbe);
+               break;
+       default:
+               break;
+       }
 
        ret = txgbe_swnodes_register(txgbe);
        if (ret) {
@@ -640,13 +646,19 @@ err_unregister_swnode:
 
 void txgbe_remove_phy(struct txgbe *txgbe)
 {
-       if (txgbe->wx->mac.type == wx_mac_aml)
-               return;
-
-       if (txgbe->wx->media_type == wx_media_copper) {
-               phylink_disconnect_phy(txgbe->wx->phylink);
-               phylink_destroy(txgbe->wx->phylink);
+       switch (txgbe->wx->mac.type) {
+       case wx_mac_aml40:
+       case wx_mac_aml:
                return;
+       case wx_mac_sp:
+               if (txgbe->wx->media_type == wx_media_copper) {
+                       phylink_disconnect_phy(txgbe->wx->phylink);
+                       phylink_destroy(txgbe->wx->phylink);
+                       return;
+               }
+               break;
+       default:
+               break;
        }
 
        platform_device_unregister(txgbe->sfp_dev);
index 8376248..3b4e436 100644 (file)
 #define TXGBE_PX_PF_BME                         0x4B8
 #define TXGBE_AML_MAC_TX_CFG                    0x11000
 #define TXGBE_AML_MAC_TX_CFG_SPEED_MASK         GENMASK(30, 27)
-#define TXGBE_AML_MAC_TX_CFG_SPEED_25G          BIT(28)
+#define TXGBE_AML_MAC_TX_CFG_SPEED_40G          FIELD_PREP(GENMASK(30, 27), 0)
+#define TXGBE_AML_MAC_TX_CFG_SPEED_25G          FIELD_PREP(GENMASK(30, 27), 2)
 #define TXGBE_RDM_RSC_CTL                       0x1200C
 #define TXGBE_RDM_RSC_CTL_FREE_CTL              BIT(7)