Skip to content

Commit 20767b2

Browse files
committed
Merge branch 'bnxt_en-hwmon-SRIOV'
Michael Chan says: ==================== bnxt_en: hwmon and SRIOV updates The first 7 patches are v2 of the hwmon patches posted about 6 weeks ago on Aug 14. The last 2 patches are SRIOV related updates. Link to v1 hwmon patches: https://lore.kernel.org/netdev/[email protected]/ ==================== Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2 parents 20f7cce + cbdbf0a commit 20767b2

File tree

7 files changed

+747
-269
lines changed

7 files changed

+747
-269
lines changed

drivers/net/ethernet/broadcom/bnxt/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ obj-$(CONFIG_BNXT) += bnxt_en.o
44
bnxt_en-y := bnxt.o bnxt_hwrm.o bnxt_sriov.o bnxt_ethtool.o bnxt_dcb.o bnxt_ulp.o bnxt_xdp.o bnxt_ptp.o bnxt_vfr.o bnxt_devlink.o bnxt_dim.o bnxt_coredump.o
55
bnxt_en-$(CONFIG_BNXT_FLOWER_OFFLOAD) += bnxt_tc.o
66
bnxt_en-$(CONFIG_DEBUG_FS) += bnxt_debugfs.o
7+
bnxt_en-$(CONFIG_BNXT_HWMON) += bnxt_hwmon.o

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 75 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@
5252
#include <linux/cpu_rmap.h>
5353
#include <linux/cpumask.h>
5454
#include <net/pkt_cls.h>
55-
#include <linux/hwmon.h>
56-
#include <linux/hwmon-sysfs.h>
5755
#include <net/page_pool/helpers.h>
5856
#include <linux/align.h>
5957
#include <net/netdev_queues.h>
@@ -71,6 +69,7 @@
7169
#include "bnxt_tc.h"
7270
#include "bnxt_devlink.h"
7371
#include "bnxt_debugfs.h"
72+
#include "bnxt_hwmon.h"
7473

7574
#define BNXT_TX_TIMEOUT (5 * HZ)
7675
#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)
21302129
return INVALID_HW_RING_ID;
21312130
}
21322131

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+
21332150
static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)
21342151
{
21352152
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)
21452162
case ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_DOORBELL_DROP_THRESHOLD:
21462163
netdev_warn(bp->dev, "One or more MMIO doorbells dropped by the device!\n");
21472164
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+
}
21482199
default:
21492200
netdev_err(bp->dev, "FW reported unknown error type %u\n",
21502201
err_type);
@@ -7699,6 +7750,8 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
76997750
bp->fw_cap |= BNXT_FW_CAP_HOT_RESET_IF;
77007751
if (BNXT_PF(bp) && (flags_ext & FUNC_QCAPS_RESP_FLAGS_EXT_FW_LIVEPATCH_SUPPORTED))
77017752
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;
77027755

77037756
flags_ext2 = le32_to_cpu(resp->flags_ext2);
77047757
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)
1025010303
} while (handle && handle != 0xffff);
1025110304
}
1025210305

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-
1032610306
static bool bnxt_eee_config_ok(struct bnxt *bp)
1032710307
{
1032810308
struct ethtool_eee *eee = &bp->eee;
@@ -10651,7 +10631,6 @@ static int bnxt_open(struct net_device *dev)
1065110631
bnxt_reenable_sriov(bp);
1065210632
}
1065310633
}
10654-
bnxt_hwmon_open(bp);
1065510634
}
1065610635

1065710636
return rc;
@@ -10736,7 +10715,6 @@ static int bnxt_close(struct net_device *dev)
1073610715
{
1073710716
struct bnxt *bp = netdev_priv(dev);
1073810717

10739-
bnxt_hwmon_close(bp);
1074010718
bnxt_close_nic(bp, true, true);
1074110719
bnxt_hwrm_shutdown_link(bp);
1074210720
bnxt_hwrm_if_change(bp, false);
@@ -12237,6 +12215,20 @@ static void bnxt_init_dflt_coal(struct bnxt *bp)
1223712215
bp->stats_coal_ticks = BNXT_DEF_STATS_COAL_TICKS;
1223812216
}
1223912217

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+
1224012232
static int bnxt_fw_init_one_p1(struct bnxt *bp)
1224112233
{
1224212234
int rc;
@@ -12293,13 +12285,17 @@ static int bnxt_fw_init_one_p2(struct bnxt *bp)
1229312285
if (rc)
1229412286
return -ENODEV;
1229512287

12288+
if (bnxt_fw_pre_resv_vnics(bp))
12289+
bp->fw_cap |= BNXT_FW_CAP_PRE_RESV_VNICS;
12290+
1229612291
bnxt_hwrm_func_qcfg(bp);
1229712292
bnxt_hwrm_vnic_qcaps(bp);
1229812293
bnxt_hwrm_port_led_qcaps(bp);
1229912294
bnxt_ethtool_init(bp);
1230012295
if (bp->fw_cap & BNXT_FW_CAP_PTP)
1230112296
__bnxt_hwrm_ptp_qcfg(bp);
1230212297
bnxt_dcb_init(bp);
12298+
bnxt_hwmon_init(bp);
1230312299
return 0;
1230412300
}
1230512301

@@ -13205,6 +13201,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
1320513201
bnxt_clear_int_mode(bp);
1320613202
bnxt_hwrm_func_drv_unrgtr(bp);
1320713203
bnxt_free_hwrm_resources(bp);
13204+
bnxt_hwmon_uninit(bp);
1320813205
bnxt_ethtool_free(bp);
1320913206
bnxt_dcb_free(bp);
1321013207
kfree(bp->ptp_cfg);
@@ -13801,6 +13798,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1380113798
init_err_pci_clean:
1380213799
bnxt_hwrm_func_drv_unrgtr(bp);
1380313800
bnxt_free_hwrm_resources(bp);
13801+
bnxt_hwmon_uninit(bp);
1380413802
bnxt_ethtool_free(bp);
1380513803
bnxt_ptp_clear(bp);
1380613804
kfree(bp->ptp_cfg);

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,6 @@ struct bnxt_vf_info {
11351135
u16 vlan;
11361136
u16 func_qcfg_flags;
11371137
u32 flags;
1138-
#define BNXT_VF_QOS 0x1
11391138
#define BNXT_VF_SPOOFCHK 0x2
11401139
#define BNXT_VF_LINK_FORCED 0x4
11411140
#define BNXT_VF_LINK_UP 0x8
@@ -2013,6 +2012,9 @@ struct bnxt {
20132012
#define BNXT_FW_CAP_RING_MONITOR BIT_ULL(30)
20142013
#define BNXT_FW_CAP_DBG_QCAPS BIT_ULL(31)
20152014
#define BNXT_FW_CAP_PTP BIT_ULL(32)
2015+
#define BNXT_FW_CAP_THRESHOLD_TEMP_SUPPORTED BIT_ULL(33)
2016+
#define BNXT_FW_CAP_DFLT_VLAN_TPID_PCP BIT_ULL(34)
2017+
#define BNXT_FW_CAP_PRE_RESV_VNICS BIT_ULL(35)
20162018

20172019
u32 fw_dbg_cap;
20182020

@@ -2053,6 +2055,7 @@ struct bnxt {
20532055
#define BNXT_FW_VER_CODE(maj, min, bld, rsv) \
20542056
((u64)(maj) << 48 | (u64)(min) << 32 | (u64)(bld) << 16 | (rsv))
20552057
#define BNXT_FW_MAJ(bp) ((bp)->fw_ver_code >> 48)
2058+
#define BNXT_FW_BLD(bp) (((bp)->fw_ver_code >> 16) & 0xffff)
20562059

20572060
u16 vxlan_fw_dst_port_id;
20582061
u16 nge_fw_dst_port_id;
@@ -2185,7 +2188,13 @@ struct bnxt {
21852188
struct bnxt_tc_info *tc_info;
21862189
struct list_head tc_indr_block_list;
21872190
struct dentry *debugfs_pdev;
2191+
#ifdef CONFIG_BNXT_HWMON
21882192
struct device *hwmon_dev;
2193+
u8 warn_thresh_temp;
2194+
u8 crit_thresh_temp;
2195+
u8 fatal_thresh_temp;
2196+
u8 shutdown_thresh_temp;
2197+
#endif
21892198
enum board_idx board_idx;
21902199
};
21912200

0 commit comments

Comments
 (0)