52
52
#include <linux/cpu_rmap.h>
53
53
#include <linux/cpumask.h>
54
54
#include <net/pkt_cls.h>
55
- #include <linux/hwmon.h>
56
- #include <linux/hwmon-sysfs.h>
57
55
#include <net/page_pool/helpers.h>
58
56
#include <linux/align.h>
59
57
#include <net/netdev_queues.h>
71
69
#include "bnxt_tc.h"
72
70
#include "bnxt_devlink.h"
73
71
#include "bnxt_debugfs.h"
72
+ #include "bnxt_hwmon.h"
74
73
75
74
#define BNXT_TX_TIMEOUT (5 * HZ)
76
75
#define BNXT_DEF_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_HW | \
@@ -2130,6 +2129,24 @@ static u16 bnxt_agg_ring_id_to_grp_idx(struct bnxt *bp, u16 ring_id)
2130
2129
return INVALID_HW_RING_ID ;
2131
2130
}
2132
2131
2132
+ #define BNXT_EVENT_THERMAL_CURRENT_TEMP (data2 ) \
2133
+ ((data2) & \
2134
+ ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_CURRENT_TEMP_MASK)
2135
+
2136
+ #define BNXT_EVENT_THERMAL_THRESHOLD_TEMP (data2 ) \
2137
+ (((data2) & \
2138
+ ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_THRESHOLD_TEMP_MASK) >>\
2139
+ ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_THRESHOLD_TEMP_SFT)
2140
+
2141
+ #define EVENT_DATA1_THERMAL_THRESHOLD_TYPE (data1 ) \
2142
+ ((data1) & \
2143
+ ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_MASK)
2144
+
2145
+ #define EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING (data1 ) \
2146
+ (((data1) & \
2147
+ ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR) ==\
2148
+ ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_INCREASING)
2149
+
2133
2150
static void bnxt_event_error_report (struct bnxt * bp , u32 data1 , u32 data2 )
2134
2151
{
2135
2152
u32 err_type = BNXT_EVENT_ERROR_REPORT_TYPE (data1 );
@@ -2145,6 +2162,40 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)
2145
2162
case ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_DOORBELL_DROP_THRESHOLD :
2146
2163
netdev_warn (bp -> dev , "One or more MMIO doorbells dropped by the device!\n" );
2147
2164
break ;
2165
+ case ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_THERMAL_THRESHOLD : {
2166
+ u32 type = EVENT_DATA1_THERMAL_THRESHOLD_TYPE (data1 );
2167
+ char * threshold_type ;
2168
+ char * dir_str ;
2169
+
2170
+ switch (type ) {
2171
+ case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_WARN :
2172
+ threshold_type = "warning" ;
2173
+ break ;
2174
+ case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_CRITICAL :
2175
+ threshold_type = "critical" ;
2176
+ break ;
2177
+ case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_FATAL :
2178
+ threshold_type = "fatal" ;
2179
+ break ;
2180
+ case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_SHUTDOWN :
2181
+ threshold_type = "shutdown" ;
2182
+ break ;
2183
+ default :
2184
+ netdev_err (bp -> dev , "Unknown Thermal threshold type event\n" );
2185
+ return ;
2186
+ }
2187
+ if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING (data1 ))
2188
+ dir_str = "above" ;
2189
+ else
2190
+ dir_str = "below" ;
2191
+ netdev_warn (bp -> dev , "Chip temperature has gone %s the %s thermal threshold!\n" ,
2192
+ dir_str , threshold_type );
2193
+ netdev_warn (bp -> dev , "Temperature (In Celsius), Current: %lu, threshold: %lu\n" ,
2194
+ BNXT_EVENT_THERMAL_CURRENT_TEMP (data2 ),
2195
+ BNXT_EVENT_THERMAL_THRESHOLD_TEMP (data2 ));
2196
+ bnxt_hwmon_notify_event (bp , type );
2197
+ break ;
2198
+ }
2148
2199
default :
2149
2200
netdev_err (bp -> dev , "FW reported unknown error type %u\n" ,
2150
2201
err_type );
@@ -7699,6 +7750,8 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
7699
7750
bp -> fw_cap |= BNXT_FW_CAP_HOT_RESET_IF ;
7700
7751
if (BNXT_PF (bp ) && (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_FW_LIVEPATCH_SUPPORTED ))
7701
7752
bp -> fw_cap |= BNXT_FW_CAP_LIVEPATCH ;
7753
+ if (BNXT_PF (bp ) && (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_DFLT_VLAN_TPID_PCP_SUPPORTED ))
7754
+ bp -> fw_cap |= BNXT_FW_CAP_DFLT_VLAN_TPID_PCP ;
7702
7755
7703
7756
flags_ext2 = le32_to_cpu (resp -> flags_ext2 );
7704
7757
if (flags_ext2 & FUNC_QCAPS_RESP_FLAGS_EXT2_RX_ALL_PKTS_TIMESTAMPS_SUPPORTED )
@@ -10250,79 +10303,6 @@ static void bnxt_get_wol_settings(struct bnxt *bp)
10250
10303
} while (handle && handle != 0xffff );
10251
10304
}
10252
10305
10253
- #ifdef CONFIG_BNXT_HWMON
10254
- static ssize_t bnxt_show_temp (struct device * dev ,
10255
- struct device_attribute * devattr , char * buf )
10256
- {
10257
- struct hwrm_temp_monitor_query_output * resp ;
10258
- struct hwrm_temp_monitor_query_input * req ;
10259
- struct bnxt * bp = dev_get_drvdata (dev );
10260
- u32 len = 0 ;
10261
- int rc ;
10262
-
10263
- rc = hwrm_req_init (bp , req , HWRM_TEMP_MONITOR_QUERY );
10264
- if (rc )
10265
- return rc ;
10266
- resp = hwrm_req_hold (bp , req );
10267
- rc = hwrm_req_send (bp , req );
10268
- if (!rc )
10269
- len = sprintf (buf , "%u\n" , resp -> temp * 1000 ); /* display millidegree */
10270
- hwrm_req_drop (bp , req );
10271
- if (rc )
10272
- return rc ;
10273
- return len ;
10274
- }
10275
- static SENSOR_DEVICE_ATTR (temp1_input , 0444 , bnxt_show_temp , NULL , 0 );
10276
-
10277
- static struct attribute * bnxt_attrs [] = {
10278
- & sensor_dev_attr_temp1_input .dev_attr .attr ,
10279
- NULL
10280
- };
10281
- ATTRIBUTE_GROUPS (bnxt );
10282
-
10283
- static void bnxt_hwmon_close (struct bnxt * bp )
10284
- {
10285
- if (bp -> hwmon_dev ) {
10286
- hwmon_device_unregister (bp -> hwmon_dev );
10287
- bp -> hwmon_dev = NULL ;
10288
- }
10289
- }
10290
-
10291
- static void bnxt_hwmon_open (struct bnxt * bp )
10292
- {
10293
- struct hwrm_temp_monitor_query_input * req ;
10294
- struct pci_dev * pdev = bp -> pdev ;
10295
- int rc ;
10296
-
10297
- rc = hwrm_req_init (bp , req , HWRM_TEMP_MONITOR_QUERY );
10298
- if (!rc )
10299
- rc = hwrm_req_send_silent (bp , req );
10300
- if (rc == - EACCES || rc == - EOPNOTSUPP ) {
10301
- bnxt_hwmon_close (bp );
10302
- return ;
10303
- }
10304
-
10305
- if (bp -> hwmon_dev )
10306
- return ;
10307
-
10308
- bp -> hwmon_dev = hwmon_device_register_with_groups (& pdev -> dev ,
10309
- DRV_MODULE_NAME , bp ,
10310
- bnxt_groups );
10311
- if (IS_ERR (bp -> hwmon_dev )) {
10312
- bp -> hwmon_dev = NULL ;
10313
- dev_warn (& pdev -> dev , "Cannot register hwmon device\n" );
10314
- }
10315
- }
10316
- #else
10317
- static void bnxt_hwmon_close (struct bnxt * bp )
10318
- {
10319
- }
10320
-
10321
- static void bnxt_hwmon_open (struct bnxt * bp )
10322
- {
10323
- }
10324
- #endif
10325
-
10326
10306
static bool bnxt_eee_config_ok (struct bnxt * bp )
10327
10307
{
10328
10308
struct ethtool_eee * eee = & bp -> eee ;
@@ -10651,7 +10631,6 @@ static int bnxt_open(struct net_device *dev)
10651
10631
bnxt_reenable_sriov (bp );
10652
10632
}
10653
10633
}
10654
- bnxt_hwmon_open (bp );
10655
10634
}
10656
10635
10657
10636
return rc ;
@@ -10736,7 +10715,6 @@ static int bnxt_close(struct net_device *dev)
10736
10715
{
10737
10716
struct bnxt * bp = netdev_priv (dev );
10738
10717
10739
- bnxt_hwmon_close (bp );
10740
10718
bnxt_close_nic (bp , true, true);
10741
10719
bnxt_hwrm_shutdown_link (bp );
10742
10720
bnxt_hwrm_if_change (bp , false);
@@ -12237,6 +12215,20 @@ static void bnxt_init_dflt_coal(struct bnxt *bp)
12237
12215
bp -> stats_coal_ticks = BNXT_DEF_STATS_COAL_TICKS ;
12238
12216
}
12239
12217
12218
+ /* FW that pre-reserves 1 VNIC per function */
12219
+ static bool bnxt_fw_pre_resv_vnics (struct bnxt * bp )
12220
+ {
12221
+ u16 fw_maj = BNXT_FW_MAJ (bp ), fw_bld = BNXT_FW_BLD (bp );
12222
+
12223
+ if (!(bp -> flags & BNXT_FLAG_CHIP_P5 ) &&
12224
+ (fw_maj > 218 || (fw_maj == 218 && fw_bld >= 18 )))
12225
+ return true;
12226
+ if ((bp -> flags & BNXT_FLAG_CHIP_P5 ) &&
12227
+ (fw_maj > 216 || (fw_maj == 216 && fw_bld >= 172 )))
12228
+ return true;
12229
+ return false;
12230
+ }
12231
+
12240
12232
static int bnxt_fw_init_one_p1 (struct bnxt * bp )
12241
12233
{
12242
12234
int rc ;
@@ -12293,13 +12285,17 @@ static int bnxt_fw_init_one_p2(struct bnxt *bp)
12293
12285
if (rc )
12294
12286
return - ENODEV ;
12295
12287
12288
+ if (bnxt_fw_pre_resv_vnics (bp ))
12289
+ bp -> fw_cap |= BNXT_FW_CAP_PRE_RESV_VNICS ;
12290
+
12296
12291
bnxt_hwrm_func_qcfg (bp );
12297
12292
bnxt_hwrm_vnic_qcaps (bp );
12298
12293
bnxt_hwrm_port_led_qcaps (bp );
12299
12294
bnxt_ethtool_init (bp );
12300
12295
if (bp -> fw_cap & BNXT_FW_CAP_PTP )
12301
12296
__bnxt_hwrm_ptp_qcfg (bp );
12302
12297
bnxt_dcb_init (bp );
12298
+ bnxt_hwmon_init (bp );
12303
12299
return 0 ;
12304
12300
}
12305
12301
@@ -13205,6 +13201,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
13205
13201
bnxt_clear_int_mode (bp );
13206
13202
bnxt_hwrm_func_drv_unrgtr (bp );
13207
13203
bnxt_free_hwrm_resources (bp );
13204
+ bnxt_hwmon_uninit (bp );
13208
13205
bnxt_ethtool_free (bp );
13209
13206
bnxt_dcb_free (bp );
13210
13207
kfree (bp -> ptp_cfg );
@@ -13801,6 +13798,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
13801
13798
init_err_pci_clean :
13802
13799
bnxt_hwrm_func_drv_unrgtr (bp );
13803
13800
bnxt_free_hwrm_resources (bp );
13801
+ bnxt_hwmon_uninit (bp );
13804
13802
bnxt_ethtool_free (bp );
13805
13803
bnxt_ptp_clear (bp );
13806
13804
kfree (bp -> ptp_cfg );
0 commit comments