bnxt_en: Update for net-next
Michael Chan
maintainercover bnxt_en: Update for net-next
The first 2 patches are fixes for the recently added hwmon changes. The next 6 patches are enhancements to support ethtool lanes and all the proper supported and advertised link modes. Before these patches, the driver was only supporting the link modes for copper media.
Edwin Peer (5):
bnxt_en: add infrastructure to lookup ethtool link mode
bnxt_en: support lane configuration via ethtool
bnxt_en: refactor speed independent ethtool modes
bnxt_en: convert to linkmode_set_bit() API
bnxt_en: extend media types to supported and autoneg modes
Kalesh AP (2):
bnxt_en: Do not call sleeping hwmon_notify_event() from NAPI
bnxt_en: Fix invoking hwmon_notify_event
Michael Chan (1):
bnxt_en: Refactor NRZ/PAM4 link speed related logic
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 125 +++- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 650 +++++++++++++----- .../net/ethernet/broadcom/bnxt/bnxt_hwmon.c | 4 +- .../net/ethernet/broadcom/bnxt/bnxt_hwmon.h | 4 +- 5 files changed, 564 insertions(+), 222 deletions(-)
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 1/8 bnxt_en: Do not call sleeping hwmon_notify_event() from NAPI
From: Kalesh AP <[email protected]>
Defer hwmon_notify_event() to bnxt_sp_task() workqueue because hwmon_notify_event() can try to acquire a mutex shown in the stack trace below. Modify bnxt_event_error_report() to return true if we need to schedule bnxt_sp_task() to notify hwmon.
__schedule+0x68/0x520 hwmon_notify_event+0xe8/0x114 schedule+0x60/0xe0 schedule_preempt_disabled+0x28/0x40 __mutex_lock.constprop.0+0x534/0x550 __mutex_lock_slowpath+0x18/0x20 mutex_lock+0x5c/0x70 kobject_uevent_env+0x2f4/0x3d0 kobject_uevent+0x10/0x20 hwmon_notify_event+0x94/0x114 bnxt_hwmon_notify_event+0x40/0x70 [bnxt_en] bnxt_event_error_report+0x260/0x290 [bnxt_en] bnxt_async_event_process.isra.0+0x250/0x850 [bnxt_en] bnxt_hwrm_handler.isra.0+0xc8/0x120 [bnxt_en] bnxt_poll_p5+0x150/0x350 [bnxt_en] __napi_poll+0x3c/0x210 net_rx_action+0x308/0x3b0 __do_softirq+0x120/0x3e0
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 ++++++++++++----- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c | 4 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h | 4 ++-- 4 files changed, 18 insertions(+), 9 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +12 -5
@@ -2147,7 +2147,8 @@ static u16 bnxt_agg_ring_id_to_grp_idx(struct bnxt *bp, u16 ring_id) ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR) ==\ ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_INCREASING) -static void bnxt_event_error_report (struct bnxt *bp,u32 data1,u32 data2) +/* Return true if the workqueue has to be scheduled */ +static bool bnxt_event_error_report (struct bnxt *bp,u32 data1,u32 data2) {u32 err_type =BNXT_EVENT_ERROR_REPORT_TYPE (data1);
@@ -2182,7 +2183,7 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)break ;default :netdev_err (bp->dev,"Unknown Thermal threshold type event\n" ); -return ; +return false; }if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING (data1)) dir_str ="above" ;
@@ -2193,14 +2194,16 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)netdev_warn (bp->dev,"Temperature (In Celsius), Current: %lu, threshold: %lu\n" ,BNXT_EVENT_THERMAL_CURRENT_TEMP (data2),BNXT_EVENT_THERMAL_THRESHOLD_TEMP (data2)); -bnxt_hwmon_notify_event (bp, type); -break ; + bp->thermal_threshold_type = type; +set_bit (BNXT_THERMAL_THRESHOLD_SP_EVENT , &bp->sp_event); +return true; }default :netdev_err (bp->dev,"FW reported unknown error type %u\n" , err_type);break ; } +return false; }#define BNXT_GET_EVENT_PORT (data) \
@@ -2401,7 +2404,8 @@ static int bnxt_async_event_process(struct bnxt *bp, goto async_event_process_exit; }case ASYNC_EVENT_CMPL_EVENT_ID_ERROR_REPORT : { -bnxt_event_error_report (bp, data1, data2); +if (bnxt_event_error_report (bp, data1, data2)) +break ; goto async_event_process_exit; }case ASYNC_EVENT_CMPL_EVENT_ID_PHC_UPDATE : {
@@ -12085,6 +12089,9 @@ static void bnxt_sp_task(struct work_struct *work)if (test_and_clear_bit (BNXT_FW_ECHO_REQUEST_SP_EVENT , &bp->sp_event))bnxt_fw_echo_reply (bp); +if (test_and_clear_bit (BNXT_THERMAL_THRESHOLD_SP_EVENT , &bp->sp_event)) +bnxt_hwmon_notify_event (bp); +/* These functions below will clear BNXT_STATE_IN_SP_TASK. They * must be the last functions to be called before exiting. */
drivers/net/ethernet/broadcom/bnxt/bnxt.h +2 -0
@@ -2094,6 +2094,7 @@ struct bnxt {#define BNXT_FW_RESET_NOTIFY_SP_EVENT 18#define BNXT_FW_EXCEPTION_SP_EVENT 19#define BNXT_LINK_CFG_CHANGE_SP_EVENT 21 +#define BNXT_THERMAL_THRESHOLD_SP_EVENT 22#define BNXT_FW_ECHO_REQUEST_SP_EVENT 23struct delayed_work fw_reset_task;
@@ -2196,6 +2197,7 @@ struct bnxt {u8 fatal_thresh_temp;u8 shutdown_thresh_temp;#endif +u32 thermal_threshold_type;enum board_idx board_idx; };
drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c +2 -2
@@ -18,14 +18,14 @@#include "bnxt_hwrm.h" #include "bnxt_hwmon.h" -void bnxt_hwmon_notify_event (struct bnxt *bp,u32 type) +void bnxt_hwmon_notify_event (struct bnxt *bp) {u32 attr;if (!bp->hwmon_dev)return ; -switch (type) { +switch (bp->thermal_threshold_type) {case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_WARN : attr = hwmon_temp_max_alarm;break ;
drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h +2 -2
@@ -11,11 +11,11 @@#define BNXT_HWMON_H #ifdef CONFIG_BNXT_HWMON -void bnxt_hwmon_notify_event (struct bnxt *bp,u32 type); +void bnxt_hwmon_notify_event (struct bnxt *bp);void bnxt_hwmon_uninit (struct bnxt *bp);void bnxt_hwmon_init (struct bnxt *bp);#else -static inline void bnxt_hwmon_notify_event (struct bnxt *bp,u32 type) +static inline void bnxt_hwmon_notify_event (struct bnxt *bp) { }
Signature · 1 line
2.30.1
Re: [PATCH net-next 1/8] bnxt_en: Do not call sleeping hwmon_notify_event() from NAPI
Quoted 26 lines · Michael Chan
From: Kalesh AP <[email protected]>
Defer
hwmon_notify_event()tobnxt_sp_task()workqueue becausehwmon_notify_event()can try to acquire a mutex shown in the stack trace below. Modifybnxt_event_error_report()to return true if we need to schedulebnxt_sp_task()to notify hwmon.__schedule+0x68/0x520 hwmon_notify_event+0xe8/0x114 schedule+0x60/0xe0 schedule_preempt_disabled+0x28/0x40 __mutex_lock.constprop.0+0x534/0x550 __mutex_lock_slowpath+0x18/0x20 mutex_lock+0x5c/0x70 kobject_uevent_env+0x2f4/0x3d0 kobject_uevent+0x10/0x20 hwmon_notify_event+0x94/0x114 bnxt_hwmon_notify_event+0x40/0x70 [bnxt_en] bnxt_event_error_report+0x260/0x290 [bnxt_en] bnxt_async_event_process.isra.0+0x250/0x850 [bnxt_en] bnxt_hwrm_handler.isra.0+0xc8/0x120 [bnxt_en] bnxt_poll_p5+0x150/0x350 [bnxt_en] __napi_poll+0x3c/0x210 net_rx_action+0x308/0x3b0 __do_softirq+0x120/0x3e0
Quoted 4 lines
Cc Guenter Roeck <[email protected]>Fixes a19b4801457b ("bnxt_en: Event handler for Thermal event")Signed-off-by Kalesh AP <[email protected]>Signed-off-by Michael Chan <[email protected]>
Quoted 128 lines
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 ++++++++++++----- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c | 4 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h | 4 ++-- 4 files changed, 18 insertions(+), 9 deletions(-)drivers/net/ethernet/broadcom/bnxt/bnxt.c +12
-5@@ -2147,7 +2147,8 @@ static u16 bnxt_agg_ring_id_to_grp_idx(struct bnxt *bp, u16 ring_id) ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR) ==\ ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_TRANSITION_DIR_INCREASING) -static void bnxt_event_error_report (struct bnxt *bp,u32 data1,u32 data2) +/* Return true if the workqueue has to be scheduled */ +static bool bnxt_event_error_report (struct bnxt *bp,u32 data1,u32 data2) {u32 err_type =BNXT_EVENT_ERROR_REPORT_TYPE (data1);@@ -2182,7 +2183,7 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)break ;default :netdev_err (bp->dev,"Unknown Thermal threshold type event\n" ); -return ; +return false; }if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING (data1)) dir_str ="above" ;@@ -2193,14 +2194,16 @@ static void bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)netdev_warn (bp->dev,"Temperature (In Celsius), Current: %lu, threshold: %lu\n" ,BNXT_EVENT_THERMAL_CURRENT_TEMP (data2),BNXT_EVENT_THERMAL_THRESHOLD_TEMP (data2)); -bnxt_hwmon_notify_event (bp, type); -break ; + bp->thermal_threshold_type = type; +set_bit (BNXT_THERMAL_THRESHOLD_SP_EVENT , &bp->sp_event); +return true; }default :netdev_err (bp->dev,"FW reported unknown error type %u\n" , err_type);break ; } +return false; }#define BNXT_GET_EVENT_PORT (data) \@@ -2401,7 +2404,8 @@ static int bnxt_async_event_process(struct bnxt *bp, goto async_event_process_exit; }case ASYNC_EVENT_CMPL_EVENT_ID_ERROR_REPORT : { -bnxt_event_error_report (bp, data1, data2); +if (bnxt_event_error_report (bp, data1, data2)) +break ; goto async_event_process_exit; }case ASYNC_EVENT_CMPL_EVENT_ID_PHC_UPDATE : {@@ -12085,6 +12089,9 @@ static void bnxt_sp_task(struct work_struct *work)if (test_and_clear_bit (BNXT_FW_ECHO_REQUEST_SP_EVENT , &bp->sp_event))bnxt_fw_echo_reply (bp); +if (test_and_clear_bit (BNXT_THERMAL_THRESHOLD_SP_EVENT , &bp->sp_event)) +bnxt_hwmon_notify_event (bp); +/* These functions below will clear BNXT_STATE_IN_SP_TASK. They * must be the last functions to be called before exiting. */ drivers/net/ethernet/broadcom/bnxt/bnxt.h +2
-0@@ -2094,6 +2094,7 @@ struct bnxt {#define BNXT_FW_RESET_NOTIFY_SP_EVENT 18#define BNXT_FW_EXCEPTION_SP_EVENT 19#define BNXT_LINK_CFG_CHANGE_SP_EVENT 21 +#define BNXT_THERMAL_THRESHOLD_SP_EVENT 22#define BNXT_FW_ECHO_REQUEST_SP_EVENT 23struct delayed_work fw_reset_task;@@ -2196,6 +2197,7 @@ struct bnxt {u8 fatal_thresh_temp;u8 shutdown_thresh_temp;#endif +u32 thermal_threshold_type;enum board_idx board_idx; };drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.c +2
-2@@ -18,14 +18,14 @@#include "bnxt_hwrm.h" #include "bnxt_hwmon.h" -void bnxt_hwmon_notify_event (struct bnxt *bp,u32 type) +void bnxt_hwmon_notify_event (struct bnxt *bp) {u32 attr;if (!bp->hwmon_dev)return ; -switch (type) { +switch (bp->thermal_threshold_type) {case ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA1_THRESHOLD_TYPE_WARN : attr = hwmon_temp_max_alarm;break ;drivers/net/ethernet/broadcom/bnxt/bnxt_hwmon.h +2
-2@@ -11,11 +11,11 @@#define BNXT_HWMON_H #ifdef CONFIG_BNXT_HWMON -void bnxt_hwmon_notify_event (struct bnxt *bp,u32 type); +void bnxt_hwmon_notify_event (struct bnxt *bp);void bnxt_hwmon_uninit (struct bnxt *bp);void bnxt_hwmon_init (struct bnxt *bp);#else -static inline void bnxt_hwmon_notify_event (struct bnxt *bp,u32 type) +static inline void bnxt_hwmon_notify_event (struct bnxt *bp) { }
Michael Chan
maintainerPATCH 2/8 bnxt_en: Fix invoking hwmon_notify_event
In reply to Michael ChanFrom: Kalesh AP <[email protected]>
FW sends the async event to the driver when the device temperature goes above or below the threshold values. Only notify hwmon if the temperature is increasing to the next alert level, not when it is decreasing.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +11 -5
@@ -2166,6 +2166,7 @@ static bool bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)case ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_THERMAL_THRESHOLD : {u32 type =EVENT_DATA1_THERMAL_THRESHOLD_TYPE (data1);char *threshold_type; +bool notify = false;char *dir_str;switch (type) {
@@ -2185,18 +2186,23 @@ static bool bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)netdev_err (bp->dev,"Unknown Thermal threshold type event\n" );return false; } -if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING (data1)) +if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING (data1)) { dir_str ="above" ; -else + notify = true; + }else { dir_str ="below" ; + }netdev_warn (bp->dev,"Chip temperature has gone %s the %s thermal threshold!\n" , dir_str, threshold_type);netdev_warn (bp->dev,"Temperature (In Celsius), Current: %lu, threshold: %lu\n" ,BNXT_EVENT_THERMAL_CURRENT_TEMP (data2),BNXT_EVENT_THERMAL_THRESHOLD_TEMP (data2)); - bp->thermal_threshold_type = type; -set_bit (BNXT_THERMAL_THRESHOLD_SP_EVENT , &bp->sp_event); -return true; +if (notify) { + bp->thermal_threshold_type = type; +set_bit (BNXT_THERMAL_THRESHOLD_SP_EVENT , &bp->sp_event); +return true; + } +return false; }default : netdev_err(bp->dev, "FW reported unknown error type %u\n",
Signature · 1 line
2.30.1
Re: [PATCH net-next 2/8] bnxt_en: Fix invoking hwmon_notify_event
Quoted 7 lines · Michael Chan
From: Kalesh AP <[email protected]>
FW sends the async event to the driver when the device temperature goes above or below the threshold values. Only notify hwmon if the temperature is increasing to the next alert level, not when it is decreasing.
Quoted 5 lines
Cc Guenter Roeck <[email protected]>Reviewed-by Kashyap Desai <[email protected]>Reviewed-by Somnath Kotur <[email protected]>Signed-off-by Kalesh AP <[email protected]>Signed-off-by Michael Chan <[email protected]>
Quoted 45 lines
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)drivers/net/ethernet/broadcom/bnxt/bnxt.c +11
-5@@ -2166,6 +2166,7 @@ static bool bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)case ASYNC_EVENT_CMPL_ERROR_REPORT_BASE_EVENT_DATA1_ERROR_TYPE_THERMAL_THRESHOLD : {u32 type =EVENT_DATA1_THERMAL_THRESHOLD_TYPE (data1);char *threshold_type; +bool notify = false;char *dir_str;switch (type) {@@ -2185,18 +2186,23 @@ static bool bnxt_event_error_report(struct bnxt *bp, u32 data1, u32 data2)netdev_err (bp->dev,"Unknown Thermal threshold type event\n" );return false; } -if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING (data1)) +if (EVENT_DATA1_THERMAL_THRESHOLD_DIR_INCREASING (data1)) { dir_str ="above" ; -else + notify = true; + }else { dir_str ="below" ; + }netdev_warn (bp->dev,"Chip temperature has gone %s the %s thermal threshold!\n" , dir_str, threshold_type);netdev_warn (bp->dev,"Temperature (In Celsius), Current: %lu, threshold: %lu\n" ,BNXT_EVENT_THERMAL_CURRENT_TEMP (data2),BNXT_EVENT_THERMAL_THRESHOLD_TEMP (data2)); - bp->thermal_threshold_type = type; -set_bit (BNXT_THERMAL_THRESHOLD_SP_EVENT , &bp->sp_event); -return true; +if (notify) { + bp->thermal_threshold_type = type; +set_bit (BNXT_THERMAL_THRESHOLD_SP_EVENT , &bp->sp_event); +return true; + } +return false; }default : netdev_err(bp->dev, "FW reported unknown error type %u\n",
Michael Chan
maintainerPATCH 3/8 bnxt_en: add infrastructure to lookup ethtool link mode
In reply to Michael ChanFrom: Edwin Peer <[email protected]>
Add infrastructure to look up the enum ethtool_link_mode_bit_indices from link information provided by the firmware. The link speed, signal mode, and media type returned by firmware will be used to look up the ethtool link mode.
The immediate benefit is that once the link mode is determined, we can now use ethtool_params_from_link_mode() to fill the basic ethtool parameters including the number of lanes. Lanes will be fully supported in the next patch.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 277 ++++++++++++++++-- 2 files changed, 258 insertions(+), 20 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.h +1 -0
@@ -1295,6 +1295,7 @@ struct bnxt_link_info {u8 req_signal_mode;#define BNXT_SIG_MODE_NRZ PORT_PHY_QCFG_RESP_SIGNAL_MODE_NRZ#define BNXT_SIG_MODE_PAM4 PORT_PHY_QCFG_RESP_SIGNAL_MODE_PAM4 +#define BNXT_SIG_MODE_MAX (PORT_PHY_QCFG_RESP_SIGNAL_MODE_LAST + 1)u8 req_duplex;u8 req_flow_ctrl;u16 req_link_speed;
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +257 -20
313 lines not on this page · raw message
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 4/8 bnxt_en: support lane configuration via ethtool
In reply to Michael ChanFrom: Edwin Peer <[email protected]>
Recent kernels support changing the number of link lanes via ethtool. This is useful for determining the appropriate signal mode to use when a given link speed can be achieved using different lane configurations.
Accept the ethtool lanes parameter when configuring forced speed. If there is no lanes parameter, select a default.
--- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +25 -7
@@ -2019,13 +2019,15 @@ static int bnxt_get_link_ksettings(struct net_device *dev,return 0 ; } -static int bnxt_force_link_speed (struct net_device *dev,u32 ethtool_speed) +static int +bnxt_force_link_speed (struct net_device *dev,u32 ethtool_speed,u32 lanes) {struct bnxt *bp =netdev_priv (dev);struct bnxt_link_info *link_info = &bp->link_info;u16 support_pam4_spds = link_info->support_pam4_speeds;u16 support_spds = link_info->support_speeds;u8 sig_mode =BNXT_SIG_MODE_NRZ ; +u32 lanes_needed =1 ;u16 fw_speed =0 ;switch (ethtool_speed) {
@@ -2046,37 +2048,46 @@ static int bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed) fw_speed =PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_10GB ;break ;case SPEED_20000 : -if (support_spds &BNXT_LINK_SPEED_MSK_20GB ) +if (support_spds &BNXT_LINK_SPEED_MSK_20GB ) { fw_speed =PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_20GB ; + lanes_needed =2 ; + }break ;case SPEED_25000 :if (support_spds &BNXT_LINK_SPEED_MSK_25GB ) fw_speed =PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_25GB ;break ;case SPEED_40000 : -if (support_spds &BNXT_LINK_SPEED_MSK_40GB ) +if (support_spds &BNXT_LINK_SPEED_MSK_40GB ) { fw_speed =PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_40GB ; + lanes_needed =4 ; + }break ;case SPEED_50000 : -if (support_spds &BNXT_LINK_SPEED_MSK_50GB ) { +if ((support_spds &BNXT_LINK_SPEED_MSK_50GB ) && lanes !=1 ) { fw_speed =PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_50GB ; + lanes_needed =2 ; }else if (support_pam4_spds &BNXT_LINK_PAM4_SPEED_MSK_50GB ) { fw_speed =PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_50GB ; sig_mode =BNXT_SIG_MODE_PAM4 ; }break ;case SPEED_100000 : -if (support_spds &BNXT_LINK_SPEED_MSK_100GB ) { +if ((support_spds &BNXT_LINK_SPEED_MSK_100GB ) && + lanes !=2 && lanes !=1 ) { fw_speed =PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_100GB ; + lanes_needed =4 ; }else if (support_pam4_spds &BNXT_LINK_PAM4_SPEED_MSK_100GB ) { fw_speed =PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_100GB ; sig_mode =BNXT_SIG_MODE_PAM4 ; + lanes_needed =2 ; }break ;case SPEED_200000 :if (support_pam4_spds &BNXT_LINK_PAM4_SPEED_MSK_200GB ) { fw_speed =PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_200GB ; sig_mode =BNXT_SIG_MODE_PAM4 ; + lanes_needed =4 ; }break ; }
@@ -2086,6 +2097,11 @@ static int bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed)return -EINVAL ; } +if (lanes && lanes != lanes_needed) { +netdev_err (dev,"unsupported number of lanes for speed\n" ); +return -EINVAL ; + } +if (link_info->req_link_speed == fw_speed && link_info->req_signal_mode == sig_mode && link_info->autoneg ==0 )
@@ -2130,7 +2146,7 @@ static int bnxt_set_link_ksettings(struct net_device *dev,struct bnxt_link_info *link_info = &bp->link_info;const struct ethtool_link_settings *base = &lk_ksettings->base;bool set_pause = false; -u32 speed; +u32 speed, lanes =0 ;int rc =0 ;if (!BNXT_PHY_CFG_ABLE (bp))
@@ -2171,7 +2187,8 @@ static int bnxt_set_link_ksettings(struct net_device *dev, goto set_setting_exit; } speed = base->speed; - rc =bnxt_force_link_speed (dev, speed); + lanes = lk_ksettings->lanes; + rc =bnxt_force_link_speed (dev, speed, lanes);if (rc) {if (rc == -EALREADY ) rc =0 ;
@@ -4377,6 +4394,7 @@ void bnxt_ethtool_free(struct bnxt *bp) }const struct ethtool_ops bnxt_ethtool_ops = { + .cap_link_lanes_supported =1 , .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USECS_IRQ |
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 5/8 bnxt_en: refactor speed independent ethtool modes
In reply to Michael ChanFrom: Edwin Peer <[email protected]>
A future patch in this series will change the algorithm used to determine ethtool speed and media modes. Extract the handling of the unrelated pause, autoneg modes into an independent function. Also separate FEC handling out of bnxt_fw_to_ethtool_*_spds().
No functional change.
--- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 78 ++++++++++--------- 1 file changed, 40 insertions(+), 38 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +40 -38
@@ -1730,7 +1730,7 @@ bnxt_get_link_mode(struct bnxt_link_info *link_info)return link_mode; } -#define BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, fw_pause, lk_ksettings, name)\ +#define BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, lk_ksettings, name) \ { \ if ((fw_speeds) & BNXT_LINK_SPEED_MSK_100MB) \ ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\
@@ -1753,16 +1753,6 @@ bnxt_get_link_mode(struct bnxt_link_info *link_info)if ((fw_speeds) &BNXT_LINK_SPEED_MSK_100GB ) \ethtool_link_ksettings_add_link_mode (lk_ksettings, name,\ 100000baseCR4_Full);\ -if ((fw_pause) &BNXT_LINK_PAUSE_RX ) { \ -ethtool_link_ksettings_add_link_mode (lk_ksettings, name,\ - Pause); \ -if (!((fw_pause) &BNXT_LINK_PAUSE_TX )) \ -ethtool_link_ksettings_add_link_mode ( \ - lk_ksettings, name, Asym_Pause);\ - }else if ((fw_pause) &BNXT_LINK_PAUSE_TX ) { \ -ethtool_link_ksettings_add_link_mode (lk_ksettings, name,\ - Asym_Pause); \ - } \ }#define BNXT_ETHTOOL_TO_FW_SPDS (fw_speeds, lk_ksettings, name) \
@@ -1820,6 +1810,39 @@ bnxt_get_link_mode(struct bnxt_link_info *link_info) (fw_speeds) |=BNXT_LINK_PAM4_SPEED_MSK_200GB ; \ } +static void bnxt_get_ethtool_modes (struct bnxt_link_info *link_info, +struct ethtool_link_ksettings *lk_ksettings) +{ + struct bnxt *bp = container_of(link_info, struct bnxt, link_info); + +if (!(bp->phy_flags &BNXT_PHY_FL_NO_PAUSE )) { +ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, + Pause); +ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, + Asym_Pause); + } + +if (link_info->support_auto_speeds || link_info->support_pam4_auto_speeds) +ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, + Autoneg); + +if (~link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL ) +return ; + +if (link_info->auto_pause_setting &BNXT_LINK_PAUSE_RX ) +ethtool_link_ksettings_add_link_mode (lk_ksettings, advertising, + Pause); +if (hweight8 (link_info->auto_pause_setting &BNXT_LINK_PAUSE_BOTH ) ==1 ) +ethtool_link_ksettings_add_link_mode (lk_ksettings, advertising, + Asym_Pause); +if (link_info->lp_pause &BNXT_LINK_PAUSE_RX ) +ethtool_link_ksettings_add_link_mode (lk_ksettings, + lp_advertising, Pause); +if (hweight8 (link_info->lp_pause &BNXT_LINK_PAUSE_BOTH ) ==1 ) +ethtool_link_ksettings_add_link_mode (lk_ksettings, + lp_advertising, Asym_Pause); +} +static void bnxt_fw_to_ethtool_advertised_fec (struct bnxt_link_info *link_info,struct ethtool_link_ksettings *lk_ksettings) {
@@ -1845,28 +1868,18 @@ static void bnxt_fw_to_ethtool_advertised_spds(struct bnxt_link_info *link_info, struct ethtool_link_ksettings *lk_ksettings) {u16 fw_speeds = link_info->advertising; -u8 fw_pause =0 ; -if (link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL ) - fw_pause = link_info->auto_pause_setting; - -BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, fw_pause, lk_ksettings, advertising); +BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, lk_ksettings, advertising); fw_speeds = link_info->advertising_pam4;BNXT_FW_TO_ETHTOOL_PAM4_SPDS (fw_speeds, lk_ksettings, advertising); -bnxt_fw_to_ethtool_advertised_fec (link_info, lk_ksettings); }static void bnxt_fw_to_ethtool_lp_adv (struct bnxt_link_info *link_info,struct ethtool_link_ksettings *lk_ksettings) {u16 fw_speeds = link_info->lp_auto_link_speeds; -u8 fw_pause =0 ; - -if (link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL ) - fw_pause = link_info->lp_pause; -BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, fw_pause, lk_ksettings, - lp_advertising); +BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, lk_ksettings, lp_advertising); fw_speeds = link_info->lp_auto_pam4_link_speeds;BNXT_FW_TO_ETHTOOL_PAM4_SPDS (fw_speeds, lk_ksettings, lp_advertising); }
@@ -1895,25 +1908,11 @@ static void bnxt_fw_to_ethtool_support_fec(struct bnxt_link_info *link_info,static void bnxt_fw_to_ethtool_support_spds (struct bnxt_link_info *link_info,struct ethtool_link_ksettings *lk_ksettings) { - struct bnxt *bp = container_of(link_info, struct bnxt, link_info);u16 fw_speeds = link_info->support_speeds; -BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds,0 , lk_ksettings, supported); +BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, lk_ksettings, supported); fw_speeds = link_info->support_pam4_speeds;BNXT_FW_TO_ETHTOOL_PAM4_SPDS (fw_speeds, lk_ksettings, supported); - -if (!(bp->phy_flags &BNXT_PHY_FL_NO_PAUSE )) { -ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, - Pause); -ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, - Asym_Pause); - } - -if (link_info->support_auto_speeds || - link_info->support_pam4_auto_speeds) -ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, - Autoneg); -bnxt_fw_to_ethtool_support_fec (link_info, lk_ksettings); }u32 bnxt_fw_to_ethtool_speed (u16 fw_link_speed)
@@ -1977,7 +1976,9 @@ static int bnxt_get_link_ksettings(struct net_device *dev, link_info = &bp->link_info;mutex_lock (&bp->link_lock); +bnxt_get_ethtool_modes (link_info, lk_ksettings);bnxt_fw_to_ethtool_support_spds (link_info, lk_ksettings); +bnxt_fw_to_ethtool_support_fec (link_info, lk_ksettings); link_mode =bnxt_get_link_mode (link_info);if (link_mode !=BNXT_LINK_MODE_UNKNOWN )ethtool_params_from_link_mode (lk_ksettings, link_mode);
@@ -1986,6 +1987,7 @@ static int bnxt_get_link_ksettings(struct net_device *dev,if (link_info->autoneg) {bnxt_fw_to_ethtool_advertised_spds (link_info, lk_ksettings); +bnxt_fw_to_ethtool_advertised_fec (link_info, lk_ksettings);ethtool_link_ksettings_add_link_mode (lk_ksettings, advertising, Autoneg); base->autoneg =AUTONEG_ENABLE ;
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 6/8 bnxt_en: Refactor NRZ/PAM4 link speed related logic
In reply to Michael ChanRefactor some NRZ/PAM4 link speed related logic into helper functions. The NRZ and PAM4 link parameters are stored in separate structure fields. The driver logic has to check whether it is in NRZ or PAM4 mode and then use the appropriate field.
Refactor this logic into helper functions for better readability.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 98 ++++++++++++++++------- 1 file changed, 67 insertions(+), 31 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +67 -31
@@ -2129,6 +2129,48 @@ static u16 bnxt_agg_ring_id_to_grp_idx(struct bnxt *bp, u16 ring_id)return INVALID_HW_RING_ID ; } +static u16 bnxt_get_force_speed (struct bnxt_link_info *link_info) +{ +if (link_info->req_signal_mode ==BNXT_SIG_MODE_PAM4 ) +return link_info->force_pam4_link_speed; +return link_info->force_link_speed; +} + +static void bnxt_set_force_speed (struct bnxt_link_info *link_info) +{ + link_info->req_link_speed = link_info->force_link_speed; + link_info->req_signal_mode =BNXT_SIG_MODE_NRZ ; +if (link_info->force_pam4_link_speed) { + link_info->req_link_speed = link_info->force_pam4_link_speed; + link_info->req_signal_mode =BNXT_SIG_MODE_PAM4 ; + } +} + +static void bnxt_set_auto_speed (struct bnxt_link_info *link_info) +{ + link_info->advertising = link_info->auto_link_speeds; + link_info->advertising_pam4 = link_info->auto_pam4_link_speeds; +} + +static bool bnxt_force_speed_updated (struct bnxt_link_info *link_info) +{ +if (link_info->req_signal_mode ==BNXT_SIG_MODE_NRZ && + link_info->req_link_speed != link_info->force_link_speed) +return true; +if (link_info->req_signal_mode ==BNXT_SIG_MODE_PAM4 && + link_info->req_link_speed != link_info->force_pam4_link_speed) +return true; +return false; +} + +static bool bnxt_auto_speed_updated (struct bnxt_link_info *link_info) +{ +if (link_info->advertising != link_info->auto_link_speeds || + link_info->advertising_pam4 != link_info->auto_pam4_link_speeds) +return true; +return false; +} +#define BNXT_EVENT_THERMAL_CURRENT_TEMP (data2) \ ((data2) & \ ASYNC_EVENT_CMPL_ERROR_REPORT_THERMAL_EVENT_DATA2_CURRENT_TEMP_MASK)
@@ -2255,7 +2297,7 @@ static int bnxt_async_event_process(struct bnxt *bp,/* print unsupported speed warning in forced speed mode only */ if (!(link_info->autoneg &BNXT_AUTONEG_SPEED ) && (data1 &0x20000 )) { -u16 fw_speed = link_info->force_link_speed; +u16 fw_speed =bnxt_get_force_speed (link_info);u32 speed =bnxt_fw_to_ethtool_speed (fw_speed);if (speed !=SPEED_UNKNOWN )
@@ -9689,13 +9731,31 @@ static bool bnxt_support_dropped(u16 advertising, u16 supported)return ((supported | diff) != supported); } +static bool bnxt_support_speed_dropped (struct bnxt_link_info *link_info) +{ +/* Check if any advertised speeds are no longer supported. The caller +* holds the link_lock mutex, so we can modify link_info settings. +*/ +if (bnxt_support_dropped (link_info->advertising, + link_info->support_auto_speeds)) { + link_info->advertising = link_info->support_auto_speeds; +return true; + } +if (bnxt_support_dropped (link_info->advertising_pam4, + link_info->support_pam4_auto_speeds)) { + link_info->advertising_pam4 = link_info->support_pam4_auto_speeds; +return true; + } +return false; +} +int bnxt_update_link (struct bnxt *bp,bool chng_link_state) {struct bnxt_link_info *link_info = &bp->link_info;struct hwrm_port_phy_qcfg_output *resp;struct hwrm_port_phy_qcfg_input *req;u8 link_state = link_info->link_state; -bool support_changed = false; +bool support_changed;int rc; rc =hwrm_req_init (bp, req,HWRM_PORT_PHY_QCFG );
@@ -9809,19 +9869,7 @@ int bnxt_update_link(struct bnxt *bp, bool chng_link_state)if (!BNXT_PHY_CFG_ABLE (bp))return 0 ; -/* Check if any advertised speeds are no longer supported. The caller -* holds the link_lock mutex, so we can modify link_info settings. -*/ -if (bnxt_support_dropped (link_info->advertising, - link_info->support_auto_speeds)) { - link_info->advertising = link_info->support_auto_speeds; - support_changed = true; - } -if (bnxt_support_dropped (link_info->advertising_pam4, - link_info->support_pam4_auto_speeds)) { - link_info->advertising_pam4 = link_info->support_pam4_auto_speeds; - support_changed = true; - } + support_changed =bnxt_support_speed_dropped (link_info);if (support_changed && (link_info->autoneg &BNXT_AUTONEG_SPEED ))bnxt_hwrm_set_link_setting (bp, true, false);return 0 ;
@@ -10362,19 +10410,14 @@ static int bnxt_update_phy_setting(struct bnxt *bp)if (!(link_info->autoneg &BNXT_AUTONEG_SPEED )) {if (BNXT_AUTO_MODE (link_info->auto_mode)) update_link = true; -if (link_info->req_signal_mode ==BNXT_SIG_MODE_NRZ && - link_info->req_link_speed != link_info->force_link_speed) - update_link = true; -else if (link_info->req_signal_mode ==BNXT_SIG_MODE_PAM4 && - link_info->req_link_speed != link_info->force_pam4_link_speed) +if (bnxt_force_speed_updated (link_info)) update_link = true;if (link_info->req_duplex != link_info->duplex_setting) update_link = true; }else {if (link_info->auto_mode ==BNXT_LINK_AUTO_NONE ) update_link = true; -if (link_info->advertising != link_info->auto_link_speeds || - link_info->advertising_pam4 != link_info->auto_pam4_link_speeds) +if (bnxt_auto_speed_updated (link_info)) update_link = true; }
@@ -11992,16 +12035,9 @@ static void bnxt_init_ethtool_link_settings(struct bnxt *bp) }else { link_info->autoneg |=BNXT_AUTONEG_FLOW_CTRL ; } - link_info->advertising = link_info->auto_link_speeds; - link_info->advertising_pam4 = link_info->auto_pam4_link_speeds; +bnxt_set_auto_speed (link_info); }else { - link_info->req_link_speed = link_info->force_link_speed; - link_info->req_signal_mode =BNXT_SIG_MODE_NRZ ; -if (link_info->force_pam4_link_speed) { - link_info->req_link_speed = - link_info->force_pam4_link_speed; - link_info->req_signal_mode =BNXT_SIG_MODE_PAM4 ; - } +bnxt_set_force_speed (link_info); link_info->req_duplex = link_info->duplex_setting; }if (link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL )
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 7/8 bnxt_en: convert to linkmode_set_bit() API
In reply to Michael ChanFrom: Edwin Peer <[email protected]>
Barring the BNXT_FW_TO_ETHTOOL speed macros, which will be removed in the next patch, update code to use the newer API.
No functional change.
--- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +24 -24
@@ -1816,31 +1816,31 @@ static void bnxt_get_ethtool_modes(struct bnxt_link_info *link_info, struct bnxt *bp = container_of(link_info, struct bnxt, link_info);if (!(bp->phy_flags &BNXT_PHY_FL_NO_PAUSE )) { -ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, - Pause); -ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, - Asym_Pause); +linkmode_set_bit (ETHTOOL_LINK_MODE_Pause_BIT, + lk_ksettings->link_modes.supported); +linkmode_set_bit (ETHTOOL_LINK_MODE_Asym_Pause_BIT, + lk_ksettings->link_modes.supported); }if (link_info->support_auto_speeds || link_info->support_pam4_auto_speeds) -ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, - Autoneg); +linkmode_set_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, + lk_ksettings->link_modes.supported);if (~link_info->autoneg &BNXT_AUTONEG_FLOW_CTRL )return ;if (link_info->auto_pause_setting &BNXT_LINK_PAUSE_RX ) -ethtool_link_ksettings_add_link_mode (lk_ksettings, advertising, - Pause); +linkmode_set_bit (ETHTOOL_LINK_MODE_Pause_BIT, + lk_ksettings->link_modes.advertising);if (hweight8 (link_info->auto_pause_setting &BNXT_LINK_PAUSE_BOTH ) ==1 ) -ethtool_link_ksettings_add_link_mode (lk_ksettings, advertising, - Asym_Pause); +linkmode_set_bit (ETHTOOL_LINK_MODE_Asym_Pause_BIT, + lk_ksettings->link_modes.advertising);if (link_info->lp_pause &BNXT_LINK_PAUSE_RX ) -ethtool_link_ksettings_add_link_mode (lk_ksettings, - lp_advertising, Pause); +linkmode_set_bit (ETHTOOL_LINK_MODE_Pause_BIT, + lk_ksettings->link_modes.lp_advertising);if (hweight8 (link_info->lp_pause &BNXT_LINK_PAUSE_BOTH ) ==1 ) -ethtool_link_ksettings_add_link_mode (lk_ksettings, - lp_advertising, Asym_Pause); +linkmode_set_bit (ETHTOOL_LINK_MODE_Asym_Pause_BIT, + lk_ksettings->link_modes.lp_advertising); } static void bnxt_fw_to_ethtool_advertised_fec(struct bnxt_link_info *link_info,
@@ -1988,8 +1988,8 @@ static int bnxt_get_link_ksettings(struct net_device *dev,if (link_info->autoneg) {bnxt_fw_to_ethtool_advertised_spds (link_info, lk_ksettings);bnxt_fw_to_ethtool_advertised_fec (link_info, lk_ksettings); -ethtool_link_ksettings_add_link_mode (lk_ksettings, - advertising, Autoneg); +linkmode_set_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, + lk_ksettings->link_modes.advertising); base->autoneg =AUTONEG_ENABLE ;if (link_info->phy_link_status ==BNXT_LINK_LINK )bnxt_fw_to_ethtool_lp_adv (link_info, lk_ksettings);
@@ -2000,15 +2000,15 @@ static int bnxt_get_link_ksettings(struct net_device *dev, base->port =PORT_NONE ;if (link_info->media_type ==PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP ) { base->port =PORT_TP ; -ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, -TP ); -ethtool_link_ksettings_add_link_mode (lk_ksettings, advertising, -TP ); +linkmode_set_bit (ETHTOOL_LINK_MODE_TP_BIT , + lk_ksettings->link_modes.supported); +linkmode_set_bit (ETHTOOL_LINK_MODE_TP_BIT , + lk_ksettings->link_modes.advertising); }else { -ethtool_link_ksettings_add_link_mode (lk_ksettings, supported, -FIBRE ); -ethtool_link_ksettings_add_link_mode (lk_ksettings, advertising, -FIBRE ); +linkmode_set_bit (ETHTOOL_LINK_MODE_FIBRE_BIT , + lk_ksettings->link_modes.supported); +linkmode_set_bit (ETHTOOL_LINK_MODE_FIBRE_BIT , + lk_ksettings->link_modes.advertising);if (link_info->media_type ==PORT_PHY_QCFG_RESP_MEDIA_TYPE_DAC ) base->port =PORT_DA ;
Signature · 1 line
2.30.1
Michael Chan
maintainerPATCH 8/8 bnxt_en: extend media types to supported and autoneg modes
In reply to Michael ChanFrom: Edwin Peer <[email protected]>
The current driver code does not accurately report the supported and advertised link modes. It basically always assumes the media type is copper for any particular speed. Utilize the recently added link mode mappings to accurately report fully qualified ethtool link modes for advertised and supported speeds.
If the media type is known, we will report the supported link modes for that media only. If the media is not known, we will report all possible supported link modes. The user can now specify any supported link modes (including NRZ and PAM4) to advertise for autoneg. It used to only accept copper NRZ modes.
--- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 273 ++++++++++-------- 1 file changed, 153 insertions(+), 120 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +153 -120
@@ -8,6 +8,7 @@* the Free Software Foundation. */ +#include <linux/bitops.h> #include <linux/ctype.h> #include <linux/stringify.h> #include <linux/ethtool.h>
@@ -1730,86 +1731,6 @@ bnxt_get_link_mode(struct bnxt_link_info *link_info)return link_mode; } -#define BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, lk_ksettings, name) \ -{ \ - if ((fw_speeds) & BNXT_LINK_SPEED_MSK_100MB) \ - ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\ - 100baseT_Full); \ - if ((fw_speeds) & BNXT_LINK_SPEED_MSK_1GB) \ - ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\ - 1000baseT_Full); \ - if ((fw_speeds) & BNXT_LINK_SPEED_MSK_10GB) \ - ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\ - 10000baseT_Full); \ - if ((fw_speeds) & BNXT_LINK_SPEED_MSK_25GB) \ - ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\ - 25000baseCR_Full); \ - if ((fw_speeds) & BNXT_LINK_SPEED_MSK_40GB) \ - ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\ - 40000baseCR4_Full);\ - if ((fw_speeds) & BNXT_LINK_SPEED_MSK_50GB) \ - ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\ - 50000baseCR2_Full);\ - if ((fw_speeds) & BNXT_LINK_SPEED_MSK_100GB) \ - ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\ - 100000baseCR4_Full);\ -} - -#define BNXT_ETHTOOL_TO_FW_SPDS (fw_speeds, lk_ksettings, name) \ -{ \ - if (ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 100baseT_Full) || \ - ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 100baseT_Half)) \ - (fw_speeds) |= BNXT_LINK_SPEED_MSK_100MB; \ - if (ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 1000baseT_Full) || \ - ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 1000baseT_Half)) \ - (fw_speeds) |= BNXT_LINK_SPEED_MSK_1GB; \ - if (ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 10000baseT_Full)) \ - (fw_speeds) |= BNXT_LINK_SPEED_MSK_10GB; \ - if (ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 25000baseCR_Full)) \ - (fw_speeds) |= BNXT_LINK_SPEED_MSK_25GB; \ - if (ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 40000baseCR4_Full)) \ - (fw_speeds) |= BNXT_LINK_SPEED_MSK_40GB; \ - if (ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 50000baseCR2_Full)) \ - (fw_speeds) |= BNXT_LINK_SPEED_MSK_50GB; \ - if (ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 100000baseCR4_Full)) \ - (fw_speeds) |= BNXT_LINK_SPEED_MSK_100GB; \ -} - -#define BNXT_FW_TO_ETHTOOL_PAM4_SPDS (fw_speeds, lk_ksettings, name) \ -{ \ - if ((fw_speeds) & BNXT_LINK_PAM4_SPEED_MSK_50GB) \ - ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\ - 50000baseCR_Full); \ - if ((fw_speeds) & BNXT_LINK_PAM4_SPEED_MSK_100GB) \ - ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\ - 100000baseCR2_Full);\ - if ((fw_speeds) & BNXT_LINK_PAM4_SPEED_MSK_200GB) \ - ethtool_link_ksettings_add_link_mode(lk_ksettings, name,\ - 200000baseCR4_Full);\ -} - -#define BNXT_ETHTOOL_TO_FW_PAM4_SPDS (fw_speeds, lk_ksettings, name) \ -{ \ - if (ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 50000baseCR_Full)) \ - (fw_speeds) |= BNXT_LINK_PAM4_SPEED_MSK_50GB; \ - if (ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 100000baseCR2_Full)) \ - (fw_speeds) |= BNXT_LINK_PAM4_SPEED_MSK_100GB; \ - if (ethtool_link_ksettings_test_link_mode(lk_ksettings, name, \ - 200000baseCR4_Full)) \ - (fw_speeds) |= BNXT_LINK_PAM4_SPEED_MSK_200GB; \ -} -static void bnxt_get_ethtool_modes (struct bnxt_link_info *link_info,struct ethtool_link_ksettings *lk_ksettings) {
@@ -1843,6 +1764,133 @@ static void bnxt_get_ethtool_modes(struct bnxt_link_info *link_info, lk_ksettings->link_modes.lp_advertising); } +static const u16 bnxt_nrz_speed_masks[] = { + [BNXT_LINK_SPEED_100MB_IDX ] =BNXT_LINK_SPEED_MSK_100MB , + [BNXT_LINK_SPEED_1GB_IDX ] =BNXT_LINK_SPEED_MSK_1GB , + [BNXT_LINK_SPEED_10GB_IDX ] =BNXT_LINK_SPEED_MSK_10GB , + [BNXT_LINK_SPEED_25GB_IDX ] =BNXT_LINK_SPEED_MSK_25GB , + [BNXT_LINK_SPEED_40GB_IDX ] =BNXT_LINK_SPEED_MSK_40GB , + [BNXT_LINK_SPEED_50GB_IDX ] =BNXT_LINK_SPEED_MSK_50GB , + [BNXT_LINK_SPEED_100GB_IDX ] =BNXT_LINK_SPEED_MSK_100GB , + [__BNXT_LINK_SPEED_END -1 ] =0 /* make any legal speed a valid index */ +}; + +static const u16 bnxt_pam4_speed_masks[] = { + [BNXT_LINK_SPEED_50GB_IDX ] =BNXT_LINK_PAM4_SPEED_MSK_50GB , + [BNXT_LINK_SPEED_100GB_IDX ] =BNXT_LINK_PAM4_SPEED_MSK_100GB , + [BNXT_LINK_SPEED_200GB_IDX ] =BNXT_LINK_PAM4_SPEED_MSK_200GB , +}; + +static enum bnxt_link_speed_indices +bnxt_encoding_speed_idx (u8 sig_mode,u16 speed_msk) +{ +const u16 *speeds; +int idx, len; + +switch (sig_mode) { +case BNXT_SIG_MODE_NRZ : + speeds = bnxt_nrz_speed_masks; + len =ARRAY_SIZE (bnxt_nrz_speed_masks); +break ; +case BNXT_SIG_MODE_PAM4 : + speeds = bnxt_pam4_speed_masks; + len =ARRAY_SIZE (bnxt_pam4_speed_masks); +break ; +default : +return BNXT_LINK_SPEED_UNKNOWN ; + } + +for (idx =0 ; idx < len; idx++) { +if (speeds[idx] == speed_msk) +return idx; + } + +return BNXT_LINK_SPEED_UNKNOWN ; +} + +#define BNXT_FW_SPEED_MSK_BITS 16 + +static void +__bnxt_get_ethtool_speeds (unsigned long fw_mask,enum bnxt_media_type media, +u8 sig_mode,unsigned long *et_mask) +{ +enum ethtool_link_mode_bit_indices link_mode; +enum bnxt_link_speed_indices speed; +u8 bit; + +for_each_set_bit (bit, &fw_mask,BNXT_FW_SPEED_MSK_BITS ) { + speed =bnxt_encoding_speed_idx (sig_mode,1 << bit); +if (!speed) +continue ; + + link_mode = bnxt_link_modes[speed][sig_mode][media]; +if (!link_mode) +continue ; + +linkmode_set_bit (link_mode, et_mask); + } +} + +static void +bnxt_get_ethtool_speeds (unsigned long fw_mask,enum bnxt_media_type media, +u8 sig_mode,unsigned long *et_mask) +{ +if (media) { +__bnxt_get_ethtool_speeds (fw_mask, media, sig_mode, et_mask); +return ; + } + +/* list speeds for all media if unknown */ +for (media =1 ; media < __BNXT_MEDIA_END; media++) +__bnxt_get_ethtool_speeds (fw_mask, media, sig_mode, et_mask); +} + +static void bnxt_update_speed (u32 *delta,bool installed_media,u16 *speeds, +u16 speed_msk,const unsigned long *et_mask, +enum ethtool_link_mode_bit_indices mode) +{ +bool mode_desired =linkmode_test_bit (mode, et_mask); + +if (!mode) +return ; + +/* enabled speeds for installed media should override */ +if (installed_media && mode_desired) { + *speeds |= speed_msk; + *delta |= speed_msk; +return ; + } + +/* many to one mapping, only allow one change per fw_speed bit */ +if (!(*delta & speed_msk) && (mode_desired == !(*speeds & speed_msk))) { + *speeds ^= speed_msk; + *delta |= speed_msk; + } +} + +static void bnxt_set_ethtool_speeds (struct bnxt_link_info *link_info, +const unsigned long *et_mask) +{ +enum bnxt_media_type media =bnxt_get_media (link_info); +u32 delta_pam4 =0 ; +u32 delta_nrz =0 ; +int i, m; + +for (i =1 ; i < __BNXT_LINK_SPEED_END; i++) { +/* accept any legal media from user */ +for (m =1 ; m < __BNXT_MEDIA_END; m++) { +bnxt_update_speed (&delta_nrz, m == media, + &link_info->advertising, + bnxt_nrz_speed_masks[i], et_mask, + bnxt_link_modes[i][BNXT_SIG_MODE_NRZ ][m]); +bnxt_update_speed (&delta_pam4, m == media, + &link_info->advertising_pam4, + bnxt_pam4_speed_masks[i], et_mask, + bnxt_link_modes[i][BNXT_SIG_MODE_PAM4 ][m]); + } + } +} +static void bnxt_fw_to_ethtool_advertised_fec (struct bnxt_link_info *link_info,struct ethtool_link_ksettings *lk_ksettings) {
@@ -1864,26 +1912,6 @@ static void bnxt_fw_to_ethtool_advertised_fec(struct bnxt_link_info *link_info, lk_ksettings->link_modes.advertising); } -static void bnxt_fw_to_ethtool_advertised_spds (struct bnxt_link_info *link_info, -struct ethtool_link_ksettings *lk_ksettings) -{ -u16 fw_speeds = link_info->advertising; - -BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, lk_ksettings, advertising); - fw_speeds = link_info->advertising_pam4; -BNXT_FW_TO_ETHTOOL_PAM4_SPDS (fw_speeds, lk_ksettings, advertising); -} - -static void bnxt_fw_to_ethtool_lp_adv (struct bnxt_link_info *link_info, -struct ethtool_link_ksettings *lk_ksettings) -{ -u16 fw_speeds = link_info->lp_auto_link_speeds; - -BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, lk_ksettings, lp_advertising); - fw_speeds = link_info->lp_auto_pam4_link_speeds; -BNXT_FW_TO_ETHTOOL_PAM4_SPDS (fw_speeds, lk_ksettings, lp_advertising); -} -static void bnxt_fw_to_ethtool_support_fec (struct bnxt_link_info *link_info,struct ethtool_link_ksettings *lk_ksettings) {
@@ -1905,16 +1933,6 @@ static void bnxt_fw_to_ethtool_support_fec(struct bnxt_link_info *link_info, lk_ksettings->link_modes.supported); } -static void bnxt_fw_to_ethtool_support_spds (struct bnxt_link_info *link_info, -struct ethtool_link_ksettings *lk_ksettings) -{ -u16 fw_speeds = link_info->support_speeds; - -BNXT_FW_TO_ETHTOOL_SPDS (fw_speeds, lk_ksettings, supported); - fw_speeds = link_info->support_pam4_speeds; -BNXT_FW_TO_ETHTOOL_PAM4_SPDS (fw_speeds, lk_ksettings, supported); -} -u32 bnxt_fw_to_ethtool_speed (u16 fw_link_speed) {switch (fw_link_speed) {
@@ -1968,7 +1986,9 @@ static int bnxt_get_link_ksettings(struct net_device *dev,enum ethtool_link_mode_bit_indices link_mode;struct bnxt *bp =netdev_priv (dev);struct bnxt_link_info *link_info; +enum bnxt_media_type media; +ethtool_link_ksettings_zero_link_mode (lk_ksettings, lp_advertising);ethtool_link_ksettings_zero_link_mode (lk_ksettings, advertising);ethtool_link_ksettings_zero_link_mode (lk_ksettings, supported); base->duplex =DUPLEX_UNKNOWN ;
@@ -1977,7 +1997,13 @@ static int bnxt_get_link_ksettings(struct net_device *dev,mutex_lock (&bp->link_lock);bnxt_get_ethtool_modes (link_info, lk_ksettings); -bnxt_fw_to_ethtool_support_spds (link_info, lk_ksettings); + media =bnxt_get_media (link_info); +bnxt_get_ethtool_speeds (link_info->support_speeds, + media,BNXT_SIG_MODE_NRZ , + lk_ksettings->link_modes.supported); +bnxt_get_ethtool_speeds (link_info->support_pam4_speeds, + media,BNXT_SIG_MODE_PAM4 , + lk_ksettings->link_modes.supported);bnxt_fw_to_ethtool_support_fec (link_info, lk_ksettings); link_mode =bnxt_get_link_mode (link_info);if (link_mode !=BNXT_LINK_MODE_UNKNOWN )
@@ -1986,13 +2012,24 @@ static int bnxt_get_link_ksettings(struct net_device *dev,bnxt_get_default_speeds (lk_ksettings, link_info);if (link_info->autoneg) { -bnxt_fw_to_ethtool_advertised_spds (link_info, lk_ksettings);bnxt_fw_to_ethtool_advertised_fec (link_info, lk_ksettings);linkmode_set_bit (ETHTOOL_LINK_MODE_Autoneg_BIT, lk_ksettings->link_modes.advertising); base->autoneg =AUTONEG_ENABLE ; -if (link_info->phy_link_status ==BNXT_LINK_LINK ) -bnxt_fw_to_ethtool_lp_adv (link_info, lk_ksettings); +bnxt_get_ethtool_speeds (link_info->advertising, + media,BNXT_SIG_MODE_NRZ , + lk_ksettings->link_modes.advertising); +bnxt_get_ethtool_speeds (link_info->advertising_pam4, + media,BNXT_SIG_MODE_PAM4 , + lk_ksettings->link_modes.advertising); +if (link_info->phy_link_status ==BNXT_LINK_LINK ) { +bnxt_get_ethtool_speeds (link_info->lp_auto_link_speeds, + media,BNXT_SIG_MODE_NRZ , + lk_ksettings->link_modes.lp_advertising); +bnxt_get_ethtool_speeds (link_info->lp_auto_pam4_link_speeds, + media,BNXT_SIG_MODE_PAM4 , + lk_ksettings->link_modes.lp_advertising); + } }else { base->autoneg =AUTONEG_DISABLE ; }
@@ -2156,12 +2193,8 @@ static int bnxt_set_link_ksettings(struct net_device *dev,mutex_lock (&bp->link_lock);if (base->autoneg ==AUTONEG_ENABLE ) { - link_info->advertising =0 ; - link_info->advertising_pam4 =0 ; -BNXT_ETHTOOL_TO_FW_SPDS (link_info->advertising, lk_ksettings, - advertising); -BNXT_ETHTOOL_TO_FW_PAM4_SPDS (link_info->advertising_pam4, - lk_ksettings, advertising); +bnxt_set_ethtool_speeds (link_info, + lk_ksettings->link_modes.advertising); link_info->autoneg |=BNXT_AUTONEG_SPEED ;if (!link_info->advertising && !link_info->advertising_pam4) { link_info->advertising = link_info->support_auto_speeds;
Signature · 1 line
2.30.1
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:
Quoted 6 lines · On Fri, 20 Oct 2023 14:27:49 -0700 you wrote:
The first 2 patches are fixes for the recently added hwmon changes. The next 6 patches are enhancements to support ethtool lanes and all the proper supported and advertised link modes. Before these patches, the driver was only supporting the link modes for copper media.
Quoted 8 lines
Edwin Peer (5):
bnxt_en: add infrastructure to lookup ethtool link mode
bnxt_en: support lane configuration via ethtool
bnxt_en: refactor speed independent ethtool modes
bnxt_en: convert tolinkmode_set_bit()API
bnxt_en: extend media types to supported and autoneg modes[...]
Here is the summary with links:
- [net-next,1/8] bnxt_en: Do not call sleeping hwmon_notify_event() from NAPI
https://git.kernel.org/netdev/net-next/c/55862094a9d0 - [net-next,2/8] bnxt_en: Fix invoking hwmon_notify_event https://git.kernel.org/netdev/net-next/c/fd78ec3fbc47 - [net-next,3/8] bnxt_en: add infrastructure to lookup ethtool link mode https://git.kernel.org/netdev/net-next/c/ecdad2a69214 - [net-next,4/8] bnxt_en: support lane configuration via ethtool https://git.kernel.org/netdev/net-next/c/d6263677bb1b - [net-next,5/8] bnxt_en: refactor speed independent ethtool modes https://git.kernel.org/netdev/net-next/c/94c89e73d377 - [net-next,6/8] bnxt_en: Refactor NRZ/PAM4 link speed related logic https://git.kernel.org/netdev/net-next/c/5802e30317d9 - [net-next,7/8] bnxt_en: convert to linkmode_set_bit() API https://git.kernel.org/netdev/net-next/c/64d20aea6e4b - [net-next,8/8] bnxt_en: extend media types to supported and autoneg modes https://git.kernel.org/netdev/net-next/c/5d4e1bf60664
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html