From b53330e242e6c7cdaff3c2edb7e2a8389af537d3 Mon Sep 17 00:00:00 2001 From: Dong Yibo Date: Tue, 12 Nov 2024 16:21:36 +0800 Subject: [PATCH] net: mucse: sync rnpgbe driver updates: 1. optimz link status time 2. fix 'ethtool -C rx-frame N' errors 3. set vlan-filter-on[fixed] 4. fix remove vlan error in sriov mode 5. rx-pause reg define error 6. rename mbx_ops_generic to rnpgbe_mbx_ops_generic 7. fix register hwmon error 8. fix mdix show if in autoneg off 1000M Signed-off-by: Dong Yibo --- drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h | 6 +-- .../net/ethernet/mucse/rnpgbe/rnpgbe_chip.c | 53 ++++++++++++++++--- .../net/ethernet/mucse/rnpgbe/rnpgbe_main.c | 13 ++--- .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c | 2 +- .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx.h | 2 +- .../net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c | 1 + .../net/ethernet/mucse/rnpgbe/rnpgbe_sysfs.c | 6 +-- .../net/ethernet/mucse/rnpgbe/rnpgbe_type.h | 12 ++--- 8 files changed, 63 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h index 07b5eb98d8459..f0c801e482875 100644 --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe.h @@ -504,8 +504,8 @@ struct hwmon_attr { struct hwmon_buff { struct attribute_group group; const struct attribute_group *groups[2]; - struct attribute *attrs[RNP_MAX_SENSORS * 4 + 1]; - struct hwmon_attr hwmon_list[RNP_MAX_SENSORS * 4]; + struct attribute *attrs[RNPGBE_MAX_SENSORS * 4 + 1]; + struct hwmon_attr hwmon_list[RNPGBE_MAX_SENSORS * 4]; unsigned int n_hwmon; }; #endif /* RNPGBE_HWMON */ @@ -1173,7 +1173,7 @@ int rnp500_fw_update(struct rnpgbe_hw *hw, int partition, const u8 *fw_bin, int rnpgbe_fw_update(struct rnpgbe_hw *hw, int partition, const u8 *fw_bin, int bytes); #define RNPM_FW_VERSION_NEW_ETHTOOL 0x00050010 - +void rnpgbe_service_event_schedule(struct rnpgbe_adapter *adapter); static inline bool rnpgbe_fw_is_old_ethtool(struct rnpgbe_hw *hw) { return hw->fw_version >= RNPM_FW_VERSION_NEW_ETHTOOL ? false : true; diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c index 140d6f8b67459..eb87d01f05796 100644 --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c @@ -2251,7 +2251,7 @@ rnpgbe_update_hw_status_hw_ops_n500(struct rnpgbe_hw *hw, mac_rd32(mac, GMAC_MANAGEMENT_RX_UNDERSIZE); hw_stats->jumbo_cnt += mac_rd32(mac, RNP500_MAC_GLEN_ERR_NUM); hw_stats->tx_pause += mac_rd32(mac, GMAC_MANAGEMENT_TX_PAUSE); - hw_stats->rx_pause += mac_rd32(mac, GMAC_MANAGEMENT_RX_UNDERSIZE); + hw_stats->rx_pause += mac_rd32(mac, GMAC_MANAGEMENT_RX_PAUSE); } const struct rnpgbe_stats rnp500_gstrings_net_stats[] = { @@ -2386,11 +2386,7 @@ static int rnp500_get_link_ksettings(struct net_device *netdev, else cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID; - if (hw->fake_autoneg) - cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID; cmd->base.eth_tp_mdix_ctrl = hw->tp_mdix_ctrl; - if (hw->fake_autoneg) - cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_INVALID; } else { if (supported_link & RNP_LINK_SPEED_1GB_FULL) { ethtool_link_ksettings_add_link_mode(cmd, supported, @@ -3358,7 +3354,9 @@ static const struct ethtool_ops rnp500_ethtool_ops = { .get_ethtool_stats = rnp500_get_ethtool_stats, .get_coalesce = rnpgbe_get_coalesce, .set_coalesce = rnpgbe_set_coalesce, - .supported_coalesce_params = ETHTOOL_COALESCE_USECS, + .supported_coalesce_params = ETHTOOL_COALESCE_USECS | + ETHTOOL_COALESCE_MAX_FRAMES_IRQ | + ETHTOOL_COALESCE_MAX_FRAMES, .get_rxnfc = rnpgbe_get_rxnfc, .set_rxnfc = rnpgbe_set_rxnfc, .get_eee = rnpgbe_get_eee, @@ -3383,6 +3381,42 @@ void rnpgbe_set_ethtool_hw_ops_n500(struct net_device *netdev) netdev->ethtool_ops = &rnp500_ethtool_ops; } +/** + * rnpgbe_get_thermal_sensor_data_hw_ops_n500 - Gathers thermal sensor data + * @hw: pointer to hardware structure + * Returns the thermal sensor data structure + **/ +static s32 rnpgbe_get_thermal_sensor_data_hw_ops_n500(struct rnpgbe_hw *hw) +{ + int voltage = 0; + struct rnpgbe_thermal_sensor_data *data = &hw->thermal_sensor_data; + + voltage = voltage; + data->sensor[0].temp = rnpgbe_mbx_get_temp(hw, &voltage); + + return 0; +} + +/** + * rnpgbe_init_thermal_sensor_thresh_hw_ops_n500 - Inits thermal sensor thresholds + * @hw: pointer to hardware structure + * Inits the thermal sensor thresholds according to the NVM map + * and save off the threshold and location values into mac.thermal_sensor_data + **/ +static s32 rnpgbe_init_thermal_sensor_thresh_hw_ops_n500(struct rnpgbe_hw *hw) +{ + u8 i; + struct rnpgbe_thermal_sensor_data *data = &hw->thermal_sensor_data; + + for (i = 0; i < RNPGBE_MAX_SENSORS; i++) { + data->sensor[i].location = i + 1; + data->sensor[i].caution_thresh = 90; + data->sensor[i].max_op_thresh = 100; + } + + return 0; +} + static struct rnpgbe_hw_operations hw_ops_n500 = { .init_hw = &rnpgbe_init_hw_ops_n500, .reset_hw = &rnpgbe_reset_hw_ops_n500, @@ -3435,6 +3469,9 @@ static struct rnpgbe_hw_operations hw_ops_n500 = { .set_rx_skip = &rnpgbe_set_rx_skip_hw_ops_n500, .set_outer_vlan_type = &rnpgbe_set_outer_vlan_type_hw_ops_n500, .setup_ethtool = &rnpgbe_set_ethtool_hw_ops_n500, + .get_thermal_sensor_data = &rnpgbe_get_thermal_sensor_data_hw_ops_n500, + .init_thermal_sensor_thresh = + &rnpgbe_init_thermal_sensor_thresh_hw_ops_n500, .phy_read_reg = &rnpgbe_phy_read_reg_hw_ops_n500, .phy_write_reg = &rnpgbe_phy_write_reg_hw_ops_n500, .setup_wol = &rnpgbe_setup_wol_hw_ops_n500, @@ -4113,7 +4150,7 @@ struct rnpgbe_info rnpgbe_n500_info = { .get_invariants = &rnpgbe_get_invariants_n500, .mac_ops = &mac_ops_n500, .eeprom_ops = NULL, - .mbx_ops = &mbx_ops_generic, + .mbx_ops = &rnpgbe_mbx_ops_generic, }; struct rnpgbe_info rnpgbe_n210_info = { @@ -4125,5 +4162,5 @@ struct rnpgbe_info rnpgbe_n210_info = { .get_invariants = &rnpgbe_get_invariants_n210, .mac_ops = &mac_ops_n500, .eeprom_ops = NULL, - .mbx_ops = &mbx_ops_generic, + .mbx_ops = &rnpgbe_mbx_ops_generic, }; diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c index 21ddd2fb37465..d67f1bc4c7204 100644 --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c @@ -45,8 +45,8 @@ char rnpgbe_driver_name[] = "rnpgbe"; static const char rnpgbe_driver_string[] = "mucse 1 Gigabit PCI Express Network Driver"; -#define DRV_VERSION "0.2.3-rc3" -static u32 driver_version = 0x00020303; +#define DRV_VERSION "0.2.3-rc10" +static u32 driver_version = 0x0002030a; #include "version.h" const char rnpgbe_driver_version[] = DRV_VERSION; @@ -118,7 +118,7 @@ static int enable_hi_dma; static void rnpgbe_service_timer(struct timer_list *t); static void rnpgbe_setup_eee_mode(struct rnpgbe_adapter *adapter, bool status); -static void rnpgbe_service_event_schedule(struct rnpgbe_adapter *adapter) +void rnpgbe_service_event_schedule(struct rnpgbe_adapter *adapter) { if (!test_bit(__RNP_DOWN, &adapter->state) && !test_and_set_bit(__RNP_SERVICE_SCHED, &adapter->state)) @@ -3134,9 +3134,6 @@ static int rnpgbe_vlan_rx_kill_vid(struct net_device *netdev, } /* if no other tags use this vid */ if (true_remove) { - if ((adapter->flags2 & - RNP_FLAG2_VLAN_STAGS_ENABLED) && - (vid != adapter->stags_vid)) hw->ops.set_vlan_filter( hw, vid, false, veb_setup); @@ -7228,10 +7225,6 @@ static int rnpgbe_add_adpater(struct pci_dev *pdev, struct rnpgbe_info *ii, netdev->hw_features |= netdev->features; - if (hw->feature_flags & RNP_NET_FEATURE_VLAN_FILTER) - netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; - if (hw->feature_flags & RNP_NET_FEATURE_STAG_FILTER) - netdev->hw_features |= NETIF_F_HW_VLAN_STAG_FILTER; if (hw->feature_flags & RNP_NET_FEATURE_VLAN_OFFLOAD) { if (!hw->ncsi_en) { netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX; diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c index 68fe9b15eecc0..63a62a697b7a4 100644 --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.c @@ -631,7 +631,7 @@ s32 rnpgbe_init_mbx_params_pf(struct rnpgbe_hw *hw) return 0; } -struct rnpgbe_mbx_operations mbx_ops_generic = { +struct rnpgbe_mbx_operations rnpgbe_mbx_ops_generic = { .init_params = rnpgbe_init_mbx_params_pf, .read = rnpgbe_read_mbx_pf, .write = rnpgbe_write_mbx_pf, diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.h b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.h index 1c8c18dd1f930..e0a2ca9abb168 100644 --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.h +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx.h @@ -175,7 +175,7 @@ s32 rnpgbe_check_for_msg(struct rnpgbe_hw *hw, enum MBX_ID); s32 rnpgbe_check_for_ack(struct rnpgbe_hw *hw, enum MBX_ID); s32 rnpgbe_check_for_rst(struct rnpgbe_hw *hw, enum MBX_ID); s32 rnpgbe_init_mbx_params_pf(struct rnpgbe_hw *hw); -extern struct rnpgbe_mbx_operations mbx_ops_generic; +extern struct rnpgbe_mbx_operations rnpgbe_mbx_ops_generic; int rnpgbe_fw_get_macaddr(struct rnpgbe_hw *hw, int pfvfnum, u8 *mac_addr, int lane); int rnpgbe_mbx_fw_reset_phy(struct rnpgbe_hw *hw); diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c index 4de533ac59a81..ae17b1f964c87 100644 --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c @@ -1426,6 +1426,7 @@ static inline int rnpgbe_mbx_fw_req_handler(struct rnpgbe_adapter *adapter, adapter->flags |= RNP_FLAG_NEED_LINK_UPDATE; break; } + rnpgbe_service_event_schedule(adapter); return 0; } diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_sysfs.c b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_sysfs.c index 0da4d61aef359..cf5afa5d2a7ba 100644 --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_sysfs.c +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_sysfs.c @@ -74,7 +74,7 @@ static ssize_t rnpgbe_hwmon_show_location(struct device __always_unused *dev, static ssize_t rnpgbe_hwmon_show_name(struct device __always_unused *dev, struct device_attribute *attr, char *buf) { - return snprintf(buf, PAGE_SIZE, "rnp\n"); + return snprintf(buf, PAGE_SIZE, "rnpgbe\n"); } static ssize_t rnpgbe_hwmon_show_temp(struct device __always_unused *dev, @@ -1202,7 +1202,7 @@ int rnpgbe_sysfs_init(struct rnpgbe_adapter *adapter) adapter->rnpgbe_hwmon_buff = rnpgbe_hwmon; - for (i = 0; i < RNP_MAX_SENSORS; i++) { + for (i = 0; i < RNPGBE_MAX_SENSORS; i++) { /* * Only create hwmon sysfs entries for sensors that have * meaningful data for. @@ -1230,7 +1230,7 @@ int rnpgbe_sysfs_init(struct rnpgbe_adapter *adapter) rnpgbe_hwmon->group.attrs = rnpgbe_hwmon->attrs; hwmon_dev = devm_hwmon_device_register_with_groups( - &adapter->pdev->dev, "rnp", rnpgbe_hwmon, rnpgbe_hwmon->groups); + &adapter->pdev->dev, "rnpgbe", rnpgbe_hwmon, rnpgbe_hwmon->groups); if (IS_ERR(hwmon_dev)) { rc = PTR_ERR(hwmon_dev); diff --git a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_type.h b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_type.h index 5d69505fc8df7..2d81885bda4aa 100644 --- a/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_type.h +++ b/drivers/net/ethernet/mucse/rnpgbe/rnpgbe_type.h @@ -107,16 +107,16 @@ static inline struct device *pci_dev_to_dev(struct pci_dev *pdev) #define ADVERTISE_2500_HALF 0x0040 /* NOT used, just FYI */ #define ADVERTISE_2500_FULL 0x0080 -#define RNP_MAX_SENSORS 1 +#define RNPGBE_MAX_SENSORS 1 struct rnpgbe_thermal_diode_data { - u8 location; - u8 temp; - u8 caution_thresh; - u8 max_op_thresh; + unsigned int location; + unsigned int temp; + unsigned int caution_thresh; + unsigned int max_op_thresh; }; struct rnpgbe_thermal_sensor_data { - struct rnpgbe_thermal_diode_data sensor[RNP_MAX_SENSORS]; + struct rnpgbe_thermal_diode_data sensor[RNPGBE_MAX_SENSORS]; }; /* Proxy Status */