ionic: updates for stable FW recovery
Subsystems (3)
cover ionic: updates for stable FW recovery
Recent FW work has tightened up timings in its error recovery handling and uncovered weaknesses in the driver's responses, so this is a set of updates primarily for better handling of the firmware's recovery mechanisms.
Brett Creeley (7):
ionic: Don't send reset commands if FW isn't running
ionic: Correctly print AQ errors if completions aren't received
ionic: Allow flexibility for error reporting on dev commands
ionic: Query FW when getting VF info via ndo_get_vf_config
ionic: Prevent filter add/del err msgs when the device is not
available
ionic: Cleanups in the Tx hotpath code
ionic: disable napi when ionic_lif_init() fails
Shannon Nelson (9):
ionic: fix type complaint in ionic_dev_cmd_clean()
ionic: start watchdog after all is setup
ionic: separate function for watchdog init
ionic: add FW_STOPPING state
ionic: better handling of RESET event
ionic: fix up printing of timeout error
ionic: remove the dbid_inuse bitmap
ionic: stretch heartbeat detection
ionic: replace set_vf data with union
drivers/net/ethernet/pensando/ionic/ionic.h | 7 +- .../ethernet/pensando/ionic/ionic_bus_pci.c | 17 +- .../net/ethernet/pensando/ionic/ionic_dev.c | 162 ++++++++------- .../net/ethernet/pensando/ionic/ionic_dev.h | 6 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 189 +++++++++++++----- .../net/ethernet/pensando/ionic/ionic_lif.h | 2 +- .../net/ethernet/pensando/ionic/ionic_main.c | 125 ++++++++---- .../ethernet/pensando/ionic/ionic_rx_filter.c | 37 +++- .../net/ethernet/pensando/ionic/ionic_txrx.c | 66 +++--- 9 files changed, 409 insertions(+), 202 deletions(-)
Signature · 1 line
2.17.1
PATCH 1/16 ionic: fix type complaint in ionic_dev_cmd_clean()
Sparse seems to have gotten a little more picky lately and we need to revisit this bit of code to make sparse happy.
warning: incorrect type in initializer (different address spaces)
expected union ionic_dev_cmd_regs *regs
got union ionic_dev_cmd_regs [noderef] __iomem *dev_cmd_regs
warning: incorrect type in argument 2 (different address spaces)
expected void [noderef] __iomem *
got unsigned int *
warning: incorrect type in argument 1 (different address spaces)
expected void volatile [noderef] __iomem *
got union ionic_dev_cmd *
--- drivers/net/ethernet/pensando/ionic/ionic_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_main.c +3 -3
@@ -370,10 +370,10 @@ int ionic_adminq_post_wait_nomsg(struct ionic_lif *lif, struct ionic_admin_ctx *static void ionic_dev_cmd_clean (struct ionic *ionic) { -union __iomem ionic_dev_cmd_regs *regs = ionic->idev.dev_cmd_regs; +struct ionic_dev *idev = &ionic->idev; -iowrite32 (0 , ®s->doorbell); -memset_io (®s->cmd,0 ,sizeof (regs->cmd)); +iowrite32 (0 , &idev->dev_cmd_regs->doorbell); +memset_io (&idev->dev_cmd_regs->cmd,0 ,sizeof (idev->dev_cmd_regs->cmd)); }int ionic_dev_cmd_wait (struct ionic *ionic,unsigned long max_seconds)
Signature · 1 line
2.17.1
PATCH 2/16 ionic: start watchdog after all is setup
In reply to Shannon NelsonThe watchdog expects the lif to fully exist when it goes off, so lets not start the watchdog until all is ready in case there is some quirky time dialation that makes probe take multiple seconds.
--- drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c | 4 +++- drivers/net/ethernet/pensando/ionic/ionic_dev.c | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +3 -1
@@ -331,6 +331,9 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto err_out_deregister_lifs; } +mod_timer (&ionic->watchdog_timer, +round_jiffies (jiffies + ionic->watchdog_period)); +return 0 ; err_out_deregister_lifs:
@@ -348,7 +351,6 @@ static int ionic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_out_reset:ionic_reset (ionic); err_out_teardown: -del_timer_sync (&ionic->watchdog_timer);pci_clear_master (pdev);/* Don't fail the probe for these errors, keep * the hw interface around for inspection
drivers/net/ethernet/pensando/ionic/ionic_dev.c +0 -3
@@ -122,9 +122,6 @@ int ionic_dev_setup(struct ionic *ionic) idev->fw_generation =IONIC_FW_STS_F_GENERATION &ioread8 (&idev->dev_info_regs->fw_status); -mod_timer (&ionic->watchdog_timer, -round_jiffies (jiffies + ionic->watchdog_period)); - idev->db_pages = bar->vaddr; idev->phy_db_pages = bar->bus_addr;
Signature · 1 line
2.17.1
PATCH 3/16 ionic: separate function for watchdog init
In reply to Shannon NelsonPull the watchdog init code out to a separate bite-sized function. Code cleaning for now, will be a useful change in the near future.
--- .../net/ethernet/pensando/ionic/ionic_dev.c | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +19 -12
@@ -46,6 +46,24 @@ static void ionic_watchdog_cb(struct timer_list *t) } } +static void ionic_watchdog_init (struct ionic *ionic) +{ +struct ionic_dev *idev = &ionic->idev; + +timer_setup (&ionic->watchdog_timer, ionic_watchdog_cb,0 ); + ionic->watchdog_period =IONIC_WATCHDOG_SECS *HZ ; + +/* set times to ensure the first check will proceed */ +atomic_long_set (&idev->last_check_time, jiffies -2 *HZ ); + idev->last_hb_time = jiffies -2 * ionic->watchdog_period; +/* init as ready, so no transition if the first check succeeds */ + idev->last_fw_hb =0 ; + idev->fw_hb_ready = true; + idev->fw_status_ready = true; + idev->fw_generation =IONIC_FW_STS_F_GENERATION & +ioread8 (&idev->dev_info_regs->fw_status); +} +void ionic_init_devinfo (struct ionic *ionic) {struct ionic_dev *idev = &ionic->idev;
@@ -109,18 +127,7 @@ int ionic_dev_setup(struct ionic *ionic)return -EFAULT ; } -timer_setup (&ionic->watchdog_timer, ionic_watchdog_cb,0 ); - ionic->watchdog_period =IONIC_WATCHDOG_SECS *HZ ; - -/* set times to ensure the first check will proceed */ -atomic_long_set (&idev->last_check_time, jiffies -2 *HZ ); - idev->last_hb_time = jiffies -2 * ionic->watchdog_period; -/* init as ready, so no transition if the first check succeeds */ - idev->last_fw_hb =0 ; - idev->fw_hb_ready = true; - idev->fw_status_ready = true; - idev->fw_generation =IONIC_FW_STS_F_GENERATION & -ioread8 (&idev->dev_info_regs->fw_status); +ionic_watchdog_init (ionic); idev->db_pages = bar->vaddr; idev->phy_db_pages = bar->bus_addr;
Signature · 1 line
2.17.1
PATCH 4/16 ionic: Don't send reset commands if FW isn't running
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
It's possible the FW is already shutting down while the driver is being removed and/or when the driver is going through reset. This can cause unexpected/unnecessary errors to be printed:
eth0: DEV_CMD IONIC_CMD_PORT_RESET (12) error, IONIC_RC_ERROR (29) failed
eth1: DEV_CMD IONIC_CMD_RESET (3) error, IONIC_RC_ERROR (29) failed
Fix this by checking the FW status register before issuing the reset commands.
Also, since err may not be assigned in ionic_port_reset(), assign it a default value of 0, and remove an unnecessary log message.
--- .../net/ethernet/pensando/ionic/ionic_dev.c | 17 ++++++++++++----- .../net/ethernet/pensando/ionic/ionic_dev.h | 1 + .../net/ethernet/pensando/ionic/ionic_main.c | 18 ++++++++++-------- 3 files changed, 23 insertions(+), 13 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +12 -5
@@ -136,6 +136,16 @@ int ionic_dev_setup(struct ionic *ionic) }/* Devcmd Interface */ +bool ionic_is_fw_running (struct ionic_dev *idev) +{ +u8 fw_status =ioread8 (&idev->dev_info_regs->fw_status); + +/* firmware is useful only if the running bit is set and +* fw_status != 0xff (bad PCI read) +*/ +return (fw_status !=0xff ) && (fw_status &IONIC_FW_STS_F_RUNNING ); +} +int ionic_heartbeat_check (struct ionic *ionic) {struct ionic_dev *idev = &ionic->idev;
@@ -159,13 +169,10 @@ int ionic_heartbeat_check(struct ionic *ionic) goto do_check_time; } -/* firmware is useful only if the running bit is set and -* fw_status != 0xff (bad PCI read) -* If fw_status is not ready don't bother with the generation. -*/ fw_status =ioread8 (&idev->dev_info_regs->fw_status); -if (fw_status ==0xff || !(fw_status &IONIC_FW_STS_F_RUNNING )) { +/* If fw_status is not ready don't bother with the generation */ +if (!ionic_is_fw_running (idev)) { fw_status_ready = false; }else { fw_generation = fw_status &IONIC_FW_STS_F_GENERATION ;
drivers/net/ethernet/pensando/ionic/ionic_dev.h +1 -0
@@ -353,5 +353,6 @@ void ionic_q_rewind(struct ionic_queue *q, struct ionic_desc_info *start);void ionic_q_service (struct ionic_queue *q,struct ionic_cq_info *cq_info,unsigned int stop_index);int ionic_heartbeat_check (struct ionic *ionic); +bool ionic_is_fw_running (struct ionic_dev *idev);#endif /* _IONIC_DEV_H_ */
drivers/net/ethernet/pensando/ionic/ionic_main.c +10 -8
@@ -540,6 +540,9 @@ int ionic_reset(struct ionic *ionic)struct ionic_dev *idev = &ionic->idev;int err; +if (!ionic_is_fw_running (idev)) +return 0 ; +mutex_lock (&ionic->dev_cmd_lock);ionic_dev_cmd_reset (idev); err =ionic_dev_cmd_wait (ionic,DEVCMD_TIMEOUT );
@@ -612,15 +615,17 @@ int ionic_port_init(struct ionic *ionic)int ionic_port_reset (struct ionic *ionic) {struct ionic_dev *idev = &ionic->idev; -int err; +int err =0 ;if (!idev->port_info)return 0 ; -mutex_lock (&ionic->dev_cmd_lock); -ionic_dev_cmd_port_reset (idev); - err =ionic_dev_cmd_wait (ionic,DEVCMD_TIMEOUT ); -mutex_unlock (&ionic->dev_cmd_lock); +if (ionic_is_fw_running (idev)) { +mutex_lock (&ionic->dev_cmd_lock); +ionic_dev_cmd_port_reset (idev); + err =ionic_dev_cmd_wait (ionic,DEVCMD_TIMEOUT ); +mutex_unlock (&ionic->dev_cmd_lock); + }dma_free_coherent (ionic->dev, idev->port_info_sz, idev->port_info, idev->port_info_pa);
@@ -628,9 +633,6 @@ int ionic_port_reset(struct ionic *ionic) idev->port_info =NULL ; idev->port_info_pa =0 ; -if (err) -dev_err (ionic->dev,"Failed to reset port\n" ); -return err; }
Signature · 1 line
2.17.1
PATCH 5/16 ionic: add FW_STOPPING state
In reply to Shannon NelsonBetween fw running and fw actually stopped into reset, we need a fw_stopping concept to catch and block some actions while we're transitioning to FW_RESET state. This will help to be sure the fw_up task is not scheduled until after the fw_down task has completed.
On some rare occasion timing, it is possible for the fw_up task to try to run before the fw_down task, then not get run after the fw_down task has run, leaving the device in a down state. This is possible if the watchdog goes off in between finding the down transition and starting the fw_down task, where the later watchdog sees the FW is back up and schedules a fw_up task.
--- .../net/ethernet/pensando/ionic/ionic_dev.c | 25 +++++++++++-------- .../net/ethernet/pensando/ionic/ionic_lif.c | 1 + .../net/ethernet/pensando/ionic/ionic_lif.h | 1 + .../net/ethernet/pensando/ionic/ionic_main.c | 4 ++- 4 files changed, 19 insertions(+), 12 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +14 -11
@@ -197,21 +197,24 @@ int ionic_heartbeat_check(struct ionic *ionic)struct ionic_lif *lif = ionic->lif;bool trigger = false; - idev->fw_status_ready = fw_status_ready; - -if (!fw_status_ready) { -dev_info (ionic->dev,"FW stopped %u\n" , fw_status); -if (lif && !test_bit (IONIC_LIF_F_FW_RESET , lif->state)) - trigger = true; - }else { -dev_info (ionic->dev,"FW running %u\n" , fw_status); -if (lif &&test_bit (IONIC_LIF_F_FW_RESET , lif->state)) - trigger = true; +if (!fw_status_ready && lif && + !test_bit (IONIC_LIF_F_FW_RESET , lif->state) && + !test_and_set_bit (IONIC_LIF_F_FW_STOPPING , lif->state)) { +dev_info (ionic->dev,"FW stopped 0x%02x\n" , fw_status); + trigger = true; + + }else if (fw_status_ready && lif && +test_bit (IONIC_LIF_F_FW_RESET , lif->state) && + !test_bit (IONIC_LIF_F_FW_STOPPING , lif->state)) { +dev_info (ionic->dev,"FW running 0x%02x\n" , fw_status); + trigger = true; }if (trigger) {struct ionic_deferred_work *work; + idev->fw_status_ready = fw_status_ready; + work =kzalloc (sizeof (*work),GFP_ATOMIC );if (work) { work->type =IONIC_DW_TYPE_LIF_RESET ;
@@ -221,7 +224,7 @@ int ionic_heartbeat_check(struct ionic *ionic) } } -if (!fw_status_ready) +if (!idev->fw_status_ready)return -ENXIO ;/* wait at least one watchdog period since the last heartbeat */
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1 -0
@@ -2835,6 +2835,7 @@ static void ionic_lif_handle_fw_down(struct ionic_lif *lif)mutex_unlock (&lif->queue_lock); +clear_bit (IONIC_LIF_F_FW_STOPPING , lif->state);dev_info (ionic->dev,"FW Down: LIFs stopped\n" ); }
drivers/net/ethernet/pensando/ionic/ionic_lif.h +1 -0
@@ -135,6 +135,7 @@ enum ionic_lif_state_flags {IONIC_LIF_F_LINK_CHECK_REQUESTED ,IONIC_LIF_F_FILTER_SYNC_NEEDED ,IONIC_LIF_F_FW_RESET , +IONIC_LIF_F_FW_STOPPING ,IONIC_LIF_F_SPLIT_INTR ,IONIC_LIF_F_BROKEN , IONIC_LIF_F_TX_DIM_INTR,
drivers/net/ethernet/pensando/ionic/ionic_main.c +3 -1
@@ -332,7 +332,9 @@ int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx,break ;/* interrupt the wait if FW stopped */ -if (test_bit (IONIC_LIF_F_FW_RESET , lif->state)) { +if ((test_bit (IONIC_LIF_F_FW_RESET , lif->state) && + !lif->ionic->idev.fw_status_ready) || +test_bit (IONIC_LIF_F_FW_STOPPING , lif->state)) {if (do_msg)netdev_err (netdev,"%s (%d) interrupted, FW in reset\n" , name, ctx->cmd.cmd.opcode);
Signature · 1 line
2.17.1
PATCH 6/16 ionic: better handling of RESET event
In reply to Shannon NelsonWhen IONIC_EVENT_RESET is received, we only need to start the fw_down process if we aren't already down, and we need to be sure to set the FW_STOPPING state on the way.
If this is how we noticed that FW was stopped, it is most likely from a FW update, and we'll see a new FW generation. The update happens quickly enough that we might not see fw_status==0, so we need to be sure things get restarted when we see the fw_generation change.
--- drivers/net/ethernet/pensando/ionic/ionic_dev.c | 17 +++++++++++++---- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 17 +++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_dev.c +13 -4
@@ -33,7 +33,8 @@ static void ionic_watchdog_cb(struct timer_list *t) !test_bit(IONIC_LIF_F_FW_RESET, lif->state))ionic_link_status_check_request (lif,CAN_NOT_SLEEP ); -if (test_bit (IONIC_LIF_F_FILTER_SYNC_NEEDED , lif->state)) { +if (test_bit (IONIC_LIF_F_FILTER_SYNC_NEEDED , lif->state) && + !test_bit (IONIC_LIF_F_FW_RESET , lif->state)) { work =kzalloc (sizeof (*work),GFP_ATOMIC );if (!work) {netdev_err (lif->netdev,"rxmode change dropped\n" );
@@ -148,8 +149,9 @@ bool ionic_is_fw_running(struct ionic_dev *idev)int ionic_heartbeat_check (struct ionic *ionic) { -struct ionic_dev *idev = &ionic->idev;unsigned long check_time, last_check_time; +struct ionic_dev *idev = &ionic->idev; +struct ionic_lif *lif = ionic->lif;bool fw_status_ready = true;bool fw_hb_ready;u8 fw_generation;
@@ -187,14 +189,21 @@ int ionic_heartbeat_check(struct ionic *ionic)* the down, the next watchdog will see the fw is up * and the generation value stable, so will trigger * the fw-up activity. +* +* If we had already moved to FW_RESET from a RESET event, +* it is possible that we never saw the fw_status go to 0, +* so we fake the current idev->fw_status_ready here to +* force the transition and get FW up again. */ - fw_status_ready = false; +if (test_bit (IONIC_LIF_F_FW_RESET , lif->state)) + idev->fw_status_ready = false;/* go to running */ +else + fw_status_ready = false;/* go to down */ } }/* is this a transition? */ if (fw_status_ready != idev->fw_status_ready) { -struct ionic_lif *lif = ionic->lif;bool trigger = false; if (!fw_status_ready && lif &&
drivers/net/ethernet/pensando/ionic/ionic_lif.c +11 -6
@@ -1112,12 +1112,17 @@ static bool ionic_notifyq_service(struct ionic_cq *cq,ionic_link_status_check_request (lif,CAN_NOT_SLEEP );break ;case IONIC_EVENT_RESET : - work =kzalloc (sizeof (*work),GFP_ATOMIC ); -if (!work) { -netdev_err (lif->netdev,"Reset event dropped\n" ); - }else { - work->type =IONIC_DW_TYPE_LIF_RESET ; -ionic_lif_deferred_enqueue (&lif->deferred, work); +if (lif->ionic->idev.fw_status_ready && + !test_bit (IONIC_LIF_F_FW_RESET , lif->state) && + !test_and_set_bit (IONIC_LIF_F_FW_STOPPING , lif->state)) { + work =kzalloc (sizeof (*work),GFP_ATOMIC ); +if (!work) { +netdev_err (lif->netdev,"Reset event dropped\n" ); +clear_bit (IONIC_LIF_F_FW_STOPPING , lif->state); + }else { + work->type =IONIC_DW_TYPE_LIF_RESET ; +ionic_lif_deferred_enqueue (&lif->deferred, work); + } }break ;default :
Signature · 1 line
2.17.1
PATCH 7/16 ionic: fix up printing of timeout error
In reply to Shannon NelsonMake sure we print the TIMEOUT string if we had a timeout error, rather than printing the wrong status.
--- drivers/net/ethernet/pensando/ionic/ionic_main.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_main.c +6 -2
@@ -215,9 +215,13 @@ static void ionic_adminq_flush(struct ionic_lif *lif)void ionic_adminq_netdev_err_print (struct ionic_lif *lif,u8 opcode,u8 status,int err) { +const char *stat_str; + + stat_str = (err == -ETIMEDOUT ) ?"TIMEOUT" : +ionic_error_to_str (status); +netdev_err (lif->netdev,"%s (%d) failed: %s (%d)\n" , -ionic_opcode_to_str (opcode), opcode, -ionic_error_to_str (status), err); +ionic_opcode_to_str (opcode), opcode, stat_str, err); } static int ionic_adminq_check_err(struct ionic_lif *lif,
Signature · 1 line
2.17.1
PATCH 8/16 ionic: Correctly print AQ errors if completions aren't received
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
Recent changes went into the driver to allow flexibility when printing error messages. Unfortunately this had the unexpected consequence of printing confusing messages like the following:
IONIC_CMD_RX_FILTER_ADD (31) failed: IONIC_RC_SUCCESS (-6)
In cases like this the completion of the admin queue command never completes, so the completion status is 0, hence IONIC_RC_SUCCESS is printed even though the command clearly failed. For example, this could happen when the driver tries to add a filter and at the same time the FW goes through a reset, so the AQ command never completes.
Fix this by forcing the FW completion status to IONIC_RC_ERROR in cases where we never get the completion.
--- drivers/net/ethernet/pensando/ionic/ionic_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/pensando/ionic/ionic_main.c +2 -0
@@ -322,6 +322,7 @@ int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx,if (do_msg && !test_bit (IONIC_LIF_F_FW_RESET , lif->state))netdev_err (netdev,"Posting of %s (%d) failed: %d\n" , name, ctx->cmd.cmd.opcode, err); + ctx->comp.comp.status =IONIC_RC_ERROR ;return err; }
@@ -342,6 +343,7 @@ int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx,if (do_msg)netdev_err (netdev,"%s (%d) interrupted, FW in reset\n" , name, ctx->cmd.cmd.opcode); + ctx->comp.comp.status =IONIC_RC_ERROR ;return -ENXIO ; }
Signature · 1 line
2.17.1
PATCH 9/16 ionic: Allow flexibility for error reporting on dev commands
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
When dev commands fail, an error message will always be printed, which may be overly alarming the to system administrators, especially if the driver shouldn't be printing the error due to some unsupported capability.
Similar to recent adminq request changes, we can update the dev command interface with the ability to selectively print error messages to allow the driver to prevent printing errors that are expected.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 3 ++ .../net/ethernet/pensando/ionic/ionic_main.c | 31 ++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic.h +3 -0
@@ -78,6 +78,9 @@ void ionic_adminq_netdev_err_print(struct ionic_lif *lif, u8 opcode, u8 status, int err);int ionic_dev_cmd_wait (struct ionic *ionic,unsigned long max_wait); +int ionic_dev_cmd_wait_nomsg (struct ionic *ionic,unsigned long max_wait); +void ionic_dev_cmd_dev_err_print (struct ionic *ionic,u8 opcode,u8 status, +int err);int ionic_set_dma_mask (struct ionic *ionic);int ionic_setup (struct ionic *ionic);
drivers/net/ethernet/pensando/ionic/ionic_main.c +27 -4
@@ -384,7 +384,20 @@ static void ionic_dev_cmd_clean(struct ionic *ionic)memset_io (&idev->dev_cmd_regs->cmd,0 ,sizeof (idev->dev_cmd_regs->cmd)); } -int ionic_dev_cmd_wait (struct ionic *ionic,unsigned long max_seconds) +void ionic_dev_cmd_dev_err_print (struct ionic *ionic,u8 opcode,u8 status, +int err) +{ +const char *stat_str; + + stat_str = (err == -ETIMEDOUT ) ?"TIMEOUT" : +ionic_error_to_str (status); + +dev_err (ionic->dev,"DEV_CMD %s (%d) error, %s (%d) failed\n" , +ionic_opcode_to_str (opcode), opcode, stat_str, err); +} + +static int __ionic_dev_cmd_wait (struct ionic *ionic,unsigned long max_seconds, +const bool do_msg) {struct ionic_dev *idev = &ionic->idev;unsigned long start_time;
@@ -452,9 +465,9 @@ int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds) }if (!(opcode ==IONIC_CMD_FW_CONTROL && err ==IONIC_RC_EAGAIN )) -dev_err (ionic->dev,"DEV_CMD %s (%d) error, %s (%d) failed\n" , -ionic_opcode_to_str (opcode), opcode, -ionic_error_to_str (err), err); +if (do_msg) +ionic_dev_cmd_dev_err_print (ionic, opcode, err, +ionic_error_to_errno (err));return ionic_error_to_errno (err); }
@@ -462,6 +475,16 @@ int ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds)return 0 ; } +int ionic_dev_cmd_wait (struct ionic *ionic,unsigned long max_seconds) +{ +return __ionic_dev_cmd_wait (ionic, max_seconds, true); +} + +int ionic_dev_cmd_wait_nomsg (struct ionic *ionic,unsigned long max_seconds) +{ +return __ionic_dev_cmd_wait (ionic, max_seconds, false); +} +int ionic_setup (struct ionic *ionic) {int err;
Signature · 1 line
2.17.1
PATCH 10/16 ionic: Query FW when getting VF info via ndo_get_vf_config
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
Currently when an administrator configures a VF via ndo_set_vf*, the driver will send the set command to FW and then update the cached value. The cached value is then used when reporting VF info via ndo_get_vf_config.
A problem is that the VF info may have been updated between the last ndo_set_vf* and ndo_get_vf_info commands via some other method, i.e. a VF changes its MAC address (assuming it's allowed to do so) and since this is all managed by the FW, this new value won't be reflected in the PF's cache of values.
To fix this, update the driver to always get the latest VF information by making use of the IONIC_CMD_VF_GETATTR dev command. The FW may not support getting all the attributes for IONIC_CMD_VF_GETATTR, so the driver will only update the cached VF config members if their associated IONIC_CMD_VF_GETATTR was successful. Otherwise the cached VF config members will remain the same as what was set in ndo_set_vf*.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 2 + .../net/ethernet/pensando/ionic/ionic_dev.c | 40 +++++++++ .../net/ethernet/pensando/ionic/ionic_dev.h | 2 + .../net/ethernet/pensando/ionic/ionic_lif.c | 90 +++++++++++++++++-- .../net/ethernet/pensando/ionic/ionic_main.c | 22 +++++ 5 files changed, 148 insertions(+), 8 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic.h +2 -0
@@ -92,4 +92,6 @@ int ionic_port_identify(struct ionic *ionic);int ionic_port_init (struct ionic *ionic);int ionic_port_reset (struct ionic *ionic); +const char *ionic_vf_attr_to_str (enum ionic_vf_attr attr); +#endif /* _IONIC_H_ */
drivers/net/ethernet/pensando/ionic/ionic_dev.c +40 -0
@@ -472,6 +472,46 @@ int ionic_set_vf_config(struct ionic *ionic, int vf, u8 attr, u8 *data)return err; } +int ionic_dev_cmd_vf_getattr (struct ionic *ionic,int vf,u8 attr, +struct ionic_vf_getattr_comp *comp) +{ +union ionic_dev_cmd cmd = { + .vf_getattr.opcode =IONIC_CMD_VF_GETATTR , + .vf_getattr.attr = attr, + .vf_getattr.vf_index =cpu_to_le16 (vf), + }; +int err; + +if (vf >= ionic->num_vfs) +return -EINVAL ; + +switch (attr) { +case IONIC_VF_ATTR_SPOOFCHK : +case IONIC_VF_ATTR_TRUST : +case IONIC_VF_ATTR_LINKSTATE : +case IONIC_VF_ATTR_MAC : +case IONIC_VF_ATTR_VLAN : +case IONIC_VF_ATTR_RATE : +break ; +case IONIC_VF_ATTR_STATSADDR : +default : +return -EINVAL ; + } + +mutex_lock (&ionic->dev_cmd_lock); +ionic_dev_cmd_go (&ionic->idev, &cmd); + err =ionic_dev_cmd_wait_nomsg (ionic,DEVCMD_TIMEOUT ); +memcpy_fromio (comp, &ionic->idev.dev_cmd_regs->comp.vf_getattr, +sizeof (*comp)); +mutex_unlock (&ionic->dev_cmd_lock); + +if (err && comp->status !=IONIC_RC_ENOSUPP ) +ionic_dev_cmd_dev_err_print (ionic, cmd.vf_getattr.opcode, + comp->status, err); + +return err; +} +/* LIF commands */ void ionic_dev_cmd_queue_identify (struct ionic_dev *idev,u16 lif_type,u8 qtype,u8 qver)
drivers/net/ethernet/pensando/ionic/ionic_dev.h +2 -0
@@ -319,6 +319,8 @@ void ionic_dev_cmd_port_fec(struct ionic_dev *idev, u8 fec_type);void ionic_dev_cmd_port_pause (struct ionic_dev *idev,u8 pause_type);int ionic_set_vf_config (struct ionic *ionic,int vf,u8 attr,u8 *data); +int ionic_dev_cmd_vf_getattr (struct ionic *ionic,int vf,u8 attr, +struct ionic_vf_getattr_comp *comp);void ionic_dev_cmd_queue_identify (struct ionic_dev *idev,u16 lif_type,u8 qtype,u8 qver);void ionic_dev_cmd_lif_identify (struct ionic_dev *idev,u8 type,u8 ver);
drivers/net/ethernet/pensando/ionic/ionic_lif.c +82 -8
102 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_main.c +22 -0
@@ -188,6 +188,28 @@ static const char *ionic_opcode_to_str(enum ionic_cmd_opcode opcode) } } +const char *ionic_vf_attr_to_str (enum ionic_vf_attr attr) +{ +switch (attr) { +case IONIC_VF_ATTR_SPOOFCHK : +return "IONIC_VF_ATTR_SPOOFCHK" ; +case IONIC_VF_ATTR_TRUST : +return "IONIC_VF_ATTR_TRUST" ; +case IONIC_VF_ATTR_LINKSTATE : +return "IONIC_VF_ATTR_LINKSTATE" ; +case IONIC_VF_ATTR_MAC : +return "IONIC_VF_ATTR_MAC" ; +case IONIC_VF_ATTR_VLAN : +return "IONIC_VF_ATTR_VLAN" ; +case IONIC_VF_ATTR_RATE : +return "IONIC_VF_ATTR_RATE" ; +case IONIC_VF_ATTR_STATSADDR : +return "IONIC_VF_ATTR_STATSADDR" ; +default : +return "IONIC_VF_ATTR_UNKNOWN" ; + } +} +static void ionic_adminq_flush (struct ionic_lif *lif) {struct ionic_desc_info *desc_info;
Signature · 1 line
2.17.1
PATCH 11/16 ionic: Prevent filter add/del err msgs when the device is not available
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
Currently when a request for add/deleting a filter is made when ionic_heartbeat_check() returns failure the driver will be overly verbose about failures, especially when these are usually temporary fails and the request will be retried later. An example of this is a filter add when the FW is in the middle of resetting:
IONIC_CMD_RX_FILTER_ADD (31) failed: IONIC_RC_ERROR (-6) rx_filter add failed: ADDR 01:80:c2:00:00:0e
Fix this by checking for -ENXIO and other error values on filter request fails before printing the error message. Add similar checking to the delete filter code.
--- .../ethernet/pensando/ionic/ionic_rx_filter.c | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_rx_filter.c +32 -5
@@ -376,10 +376,24 @@ static int ionic_lif_filter_add(struct ionic_lif *lif,spin_unlock_bh (&lif->rx_filters.lock); -if (err == -ENOSPC ) { -if (le16_to_cpu (ctx.cmd.rx_filter_add.match) ==IONIC_RX_FILTER_MATCH_VLAN ) - lif->max_vlans = lif->nvlans; +/* store the max_vlans limit that we found */ +if (err == -ENOSPC && +le16_to_cpu (ctx.cmd.rx_filter_add.match) ==IONIC_RX_FILTER_MATCH_VLAN ) + lif->max_vlans = lif->nvlans; + +/* Prevent unnecessary error messages on recoverable +* errors as the filter will get retried on the next +* sync attempt. +*/ +switch (err) { +case -ENOSPC : +case -ENXIO : +case -ETIMEDOUT : +case -EAGAIN : +case -EBUSY :return 0 ; +default : +break ; } ionic_adminq_netdev_err_print(lif, ctx.cmd.cmd.opcode,
@@ -494,9 +508,22 @@ static int ionic_lif_filter_del(struct ionic_lif *lif,spin_unlock_bh (&lif->rx_filters.lock);if (state !=IONIC_FILTER_STATE_NEW ) { - err =ionic_adminq_post_wait (lif, &ctx); -if (err && err != -EEXIST ) + err =ionic_adminq_post_wait_nomsg (lif, &ctx); + +switch (err) { +/* ignore these errors */ +case -EEXIST : +case -ENXIO : +case -ETIMEDOUT : +case -EAGAIN : +case -EBUSY : +case 0 : +break ; +default : +ionic_adminq_netdev_err_print (lif, ctx.cmd.cmd.opcode, + ctx.comp.comp.status, err);return err; + } }return 0 ;
Signature · 1 line
2.17.1
PATCH 12/16 ionic: Cleanups in the Tx hotpath code
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
Buffer DMA mapping happens in ionic_tx_map_skb() and this function is called from ionic_tx() and ionic_tx_tso(). If ionic_tx_map_skb() succeeds, but a failure is encountered later in ionic_tx() or ionic_tx_tso() we aren't unmapping the buffers. This can be fixed in ionic_tx() by changing functions it calls to return void because they always return 0. For ionic_tx_tso(), there's an actual possibility that we leave the buffers mapped, so fix this by introducing the helper function ionic_tx_desc_unmap_bufs(). This function is also re-used in ionic_tx_clean().
--- .../net/ethernet/pensando/ionic/ionic_txrx.c | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_txrx.c +34 -32
@@ -669,27 +669,37 @@ static int ionic_tx_map_skb(struct ionic_queue *q, struct sk_buff *skb,return -EIO ; } +static void ionic_tx_desc_unmap_bufs (struct ionic_queue *q, +struct ionic_desc_info *desc_info) +{ +struct ionic_buf_info *buf_info = desc_info->bufs; +struct device *dev = q->dev; +unsigned int i; + +if (!desc_info->nbufs) +return ; + +dma_unmap_single (dev, (dma_addr_t )buf_info->dma_addr, + buf_info->len,DMA_TO_DEVICE ); + buf_info++; +for (i =1 ; i < desc_info->nbufs; i++, buf_info++) +dma_unmap_page (dev, (dma_addr_t )buf_info->dma_addr, + buf_info->len,DMA_TO_DEVICE ); + + desc_info->nbufs =0 ; +} +static void ionic_tx_clean (struct ionic_queue *q,struct ionic_desc_info *desc_info,struct ionic_cq_info *cq_info,void *cb_arg) { -struct ionic_buf_info *buf_info = desc_info->bufs;struct ionic_tx_stats *stats =q_to_tx_stats (q);struct ionic_qcq *qcq =q_to_qcq (q);struct sk_buff *skb = cb_arg; -struct device *dev = q->dev; -unsigned int i;u16 qi; -if (desc_info->nbufs) { -dma_unmap_single (dev, (dma_addr_t )buf_info->dma_addr, - buf_info->len,DMA_TO_DEVICE ); - buf_info++; -for (i =1 ; i < desc_info->nbufs; i++, buf_info++) -dma_unmap_page (dev, (dma_addr_t )buf_info->dma_addr, - buf_info->len,DMA_TO_DEVICE ); - } +ionic_tx_desc_unmap_bufs (q, desc_info);if (!skb)return ;
@@ -931,8 +941,11 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb) err =ionic_tx_tcp_inner_pseudo_csum (skb); else err =ionic_tx_tcp_pseudo_csum (skb); -if (err) +if (err) { +/* clean up mapping from ionic_tx_map_skb */ +ionic_tx_desc_unmap_bufs (q, desc_info);return err; + }if (encap) hdrlen = skb_inner_transport_header(skb) - skb->data +
@@ -1003,8 +1016,8 @@ static int ionic_tx_tso(struct ionic_queue *q, struct sk_buff *skb)return 0 ; } -static int ionic_tx_calc_csum (struct ionic_queue *q,struct sk_buff *skb, -struct ionic_desc_info *desc_info) +static void ionic_tx_calc_csum (struct ionic_queue *q,struct sk_buff *skb, +struct ionic_desc_info *desc_info) {struct ionic_txq_desc *desc = desc_info->txq_desc;struct ionic_buf_info *buf_info = desc_info->bufs;
@@ -1038,12 +1051,10 @@ static int ionic_tx_calc_csum(struct ionic_queue *q, struct sk_buff *skb, stats->crc32_csum++; else stats->csum++; - -return 0 ; } -static int ionic_tx_calc_no_csum (struct ionic_queue *q,struct sk_buff *skb, -struct ionic_desc_info *desc_info) +static void ionic_tx_calc_no_csum (struct ionic_queue *q,struct sk_buff *skb, +struct ionic_desc_info *desc_info) {struct ionic_txq_desc *desc = desc_info->txq_desc;struct ionic_buf_info *buf_info = desc_info->bufs;
@@ -1074,12 +1085,10 @@ static int ionic_tx_calc_no_csum(struct ionic_queue *q, struct sk_buff *skb, desc->csum_offset =0 ; stats->csum_none++; - -return 0 ; } -static int ionic_tx_skb_frags (struct ionic_queue *q,struct sk_buff *skb, -struct ionic_desc_info *desc_info) +static void ionic_tx_skb_frags (struct ionic_queue *q,struct sk_buff *skb, +struct ionic_desc_info *desc_info) {struct ionic_txq_sg_desc *sg_desc = desc_info->txq_sg_desc;struct ionic_buf_info *buf_info = &desc_info->bufs[1 ];
@@ -1093,31 +1102,24 @@ static int ionic_tx_skb_frags(struct ionic_queue *q, struct sk_buff *skb, } stats->frags +=skb_shinfo (skb)->nr_frags; - -return 0 ; }static int ionic_tx (struct ionic_queue *q,struct sk_buff *skb) {struct ionic_desc_info *desc_info = &q->info[q->head_idx];struct ionic_tx_stats *stats =q_to_tx_stats (q); -int err;if (unlikely (ionic_tx_map_skb (q, skb, desc_info)))return -EIO ;/* set up the initial descriptor */ if (skb->ip_summed ==CHECKSUM_PARTIAL ) - err =ionic_tx_calc_csum (q, skb, desc_info); +ionic_tx_calc_csum (q, skb, desc_info);else - err =ionic_tx_calc_no_csum (q, skb, desc_info); -if (err) -return err; +ionic_tx_calc_no_csum (q, skb, desc_info);/* add frags */ - err =ionic_tx_skb_frags (q, skb, desc_info); -if (err) -return err; +ionic_tx_skb_frags (q, skb, desc_info);skb_tx_timestamp (skb); stats->pkts++;
Signature · 1 line
2.17.1
PATCH 13/16 ionic: disable napi when ionic_lif_init() fails
In reply to Shannon NelsonFrom: Brett Creeley <[email protected]>
When the driver is going through reset, it will eventually call ionic_lif_init(), which does a lot of re-initialization. One of the re-initialization steps is to setup the adminq and enable napi for it. If something breaks after this point we can end up with a kernel NULL pointer dereference through ionic_adminq_napi.
Fix this by making sure to call napi_disable() in the cleanup path of ionic_lif_init(). This forces any pending napi contexts to finish and prevents them from being recalled before deleting the napi context.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1 -0
@@ -3266,6 +3266,7 @@ int ionic_lif_init(struct ionic_lif *lif)return 0 ; err_out_notifyq_deinit: +napi_disable (&lif->adminqcq->napi);ionic_lif_qcq_deinit (lif, lif->notifyqcq); err_out_adminq_deinit:ionic_lif_qcq_deinit (lif, lif->adminqcq);
Signature · 1 line
2.17.1
PATCH 14/16 ionic: remove the dbid_inuse bitmap
In reply to Shannon NelsonThe dbid_inuse bitmap is not useful in this driver so remove it.
--- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 17 +---------------- drivers/net/ethernet/pensando/ionic/ionic_lif.h | 1 - 2 files changed, 1 insertion(+), 17 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1 -16
@@ -3014,8 +3014,6 @@ void ionic_lif_free(struct ionic_lif *lif)/* unmap doorbell page */ ionic_bus_unmap_dbpage (lif->ionic, lif->kern_dbpage); lif->kern_dbpage =NULL ; -kfree (lif->dbid_inuse); - lif->dbid_inuse =NULL ;mutex_destroy (&lif->config_lock);mutex_destroy (&lif->queue_lock);
@@ -3215,22 +3213,12 @@ int ionic_lif_init(struct ionic_lif *lif)return -EINVAL ; } - lif->dbid_inuse =bitmap_zalloc (lif->dbid_count,GFP_KERNEL ); -if (!lif->dbid_inuse) { -dev_err (dev,"Failed alloc doorbell id bitmap, aborting\n" ); -return -ENOMEM ; - } - -/* first doorbell id reserved for kernel (dbid aka pid == zero) */ -set_bit (0 , lif->dbid_inuse); lif->kern_pid =0 ; - dbpage_num =ionic_db_page_num (lif, lif->kern_pid); lif->kern_dbpage =ionic_bus_map_dbpage (lif->ionic, dbpage_num);if (!lif->kern_dbpage) {dev_err (dev,"Cannot map dbpage, aborting\n" ); - err = -ENOMEM ; - goto err_out_free_dbid; +return -ENOMEM ; } err =ionic_lif_adminq_init (lif);
@@ -3273,9 +3261,6 @@ int ionic_lif_init(struct ionic_lif *lif)ionic_lif_reset (lif);ionic_bus_unmap_dbpage (lif->ionic, lif->kern_dbpage); lif->kern_dbpage =NULL ; -err_out_free_dbid: -kfree (lif->dbid_inuse); - lif->dbid_inuse =NULL ;return err; }
drivers/net/ethernet/pensando/ionic/ionic_lif.h +0 -1
@@ -214,7 +214,6 @@ struct ionic_lif {u32 rx_coalesce_hw;/* what the hw is using */ u32 tx_coalesce_usecs;/* what the user asked for */ u32 tx_coalesce_hw;/* what the hw is using */ -unsigned long *dbid_inuse;unsigned int dbid_count;struct ionic_phc *phc;
Signature · 1 line
2.17.1
PATCH 15/16 ionic: stretch heartbeat detection
In reply to Shannon NelsonThe driver can be premature in detecting stalled firmware when the heartbeat is not updated because the firmware can occasionally take a long time (more than 2 seconds) to service a request, and doesn't update the heartbeat during that time.
The firmware heartbeat is not necessarily a steady 1 second periodic beat, but better described as something that should progress at least once in every DECVMD_TIMEOUT period. The single-threaded design in the FW means that if a devcmd or adminq request launches a large internal job, it is stuck waiting for that job to finish before it can get back to updating the heartbeat. Since all requests are "guaranteed" to finish within the DEVCMD_TIMEOUT period, the driver needs to less aggressive in checking the heartbeat progress.
We change our current 2 second window to something bigger than DEVCMD_TIMEOUT which should take care of most of the issue. We stop checking for the heartbeat while waiting for a request, as long as we're still watching for the FW status. Lastly, we make sure our FW status is up to date before running a devcmd request.
Once we do this, we need to not check the heartbeat on DEV commands because it may be stalled while we're on the fw_down path. Instead, we can rely on the is_fw_running check.
--- drivers/net/ethernet/pensando/ionic/ionic.h | 2 +- .../net/ethernet/pensando/ionic/ionic_dev.c | 6 ++-- .../net/ethernet/pensando/ionic/ionic_lif.c | 2 +- .../net/ethernet/pensando/ionic/ionic_main.c | 34 ++++++++----------- 4 files changed, 20 insertions(+), 24 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic.h +1 -1
@@ -18,7 +18,7 @@ struct ionic_lif;#define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_PF 0x1002#define PCI_DEVICE_ID_PENSANDO_IONIC_ETH_VF 0x1003 -#define DEVCMD_TIMEOUT 10 +#define DEVCMD_TIMEOUT 5#define IONIC_ADMINQ_TIME_SLICE msecs_to_jiffies(100)#define IONIC_PHC_UPDATE_NS 10000000000/* 10s in nanoseconds */
drivers/net/ethernet/pensando/ionic/ionic_dev.c +4 -2
@@ -236,9 +236,11 @@ int ionic_heartbeat_check(struct ionic *ionic)if (!idev->fw_status_ready)return -ENXIO ; -/* wait at least one watchdog period since the last heartbeat */ +/* Because of some variability in the actual FW heartbeat, we +* wait longer than the DEVCMD_TIMEOUT before checking again. +*/ last_check_time = idev->last_hb_time; -if (time_before (check_time, last_check_time + ionic->watchdog_period)) +if (time_before (check_time, last_check_time +DEVCMD_TIMEOUT *2 *HZ ))return 0 ; fw_hb =ioread32 (&idev->dev_info_regs->fw_heartbeat);
drivers/net/ethernet/pensando/ionic/ionic_lif.c +1 -1
@@ -1787,7 +1787,7 @@ static void ionic_lif_quiesce(struct ionic_lif *lif) err =ionic_adminq_post_wait (lif, &ctx);if (err) -netdev_err (lif->netdev,"lif quiesce failed %d\n" , err); +netdev_dbg (lif->netdev,"lif quiesce failed %d\n" , err); }static void ionic_txrx_disable (struct ionic_lif *lif)
drivers/net/ethernet/pensando/ionic/ionic_main.c +14 -20
@@ -358,13 +358,14 @@ int ionic_adminq_wait(struct ionic_lif *lif, struct ionic_admin_ctx *ctx,if (remaining)break ; -/* interrupt the wait if FW stopped */ +/* force a check of FW status and break out if FW reset */ + (void )ionic_heartbeat_check (lif->ionic);if ((test_bit (IONIC_LIF_F_FW_RESET , lif->state) && !lif->ionic->idev.fw_status_ready) ||test_bit (IONIC_LIF_F_FW_STOPPING , lif->state)) {if (do_msg) -netdev_err (netdev,"%s (%d) interrupted, FW in reset\n" , - name, ctx->cmd.cmd.opcode); +netdev_warn (netdev,"%s (%d) interrupted, FW in reset\n" , + name, ctx->cmd.cmd.opcode); ctx->comp.comp.status =IONIC_RC_ERROR ;return -ENXIO ; }
@@ -425,9 +426,9 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds,unsigned long start_time;unsigned long max_wait;unsigned long duration; +int done =0 ; +bool fw_up;int opcode; -int hb =0 ; -int done;int err;/* Wait for dev cmd to complete, retrying if we get EAGAIN,
@@ -437,31 +438,24 @@ static int __ionic_dev_cmd_wait(struct ionic *ionic, unsigned long max_seconds, try_again: opcode =readb (&idev->dev_cmd_regs->cmd.cmd.opcode); start_time = jiffies; -do { +for (fw_up =ionic_is_fw_running (idev); + !done && fw_up &&time_before (jiffies, max_wait); + fw_up =ionic_is_fw_running (idev)) { done =ionic_dev_cmd_done (idev);if (done)break ;usleep_range (100 ,200 ); - -/* Don't check the heartbeat on FW_CONTROL commands as they are -* notorious for interrupting the firmware's heartbeat update. -*/ -if (opcode !=IONIC_CMD_FW_CONTROL ) - hb =ionic_heartbeat_check (ionic); - }while (!done && !hb &&time_before (jiffies, max_wait)); + } duration = jiffies - start_time;dev_dbg (ionic->dev,"DEVCMD %s (%d) done=%d took %ld secs (%ld jiffies)\n" ,ionic_opcode_to_str (opcode), opcode, done, duration /HZ , duration); -if (!done && hb) { -/* It is possible (but unlikely) that FW was busy and missed a -* heartbeat check but is still alive and will process this -* request, so don't clean the dev_cmd in this case. -*/ -dev_dbg (ionic->dev,"DEVCMD %s (%d) failed - FW halted\n" , -ionic_opcode_to_str (opcode), opcode); +if (!done && !fw_up) { +ionic_dev_cmd_clean (ionic); +dev_warn (ionic->dev,"DEVCMD %s (%d) interrupted - FW is down\n" , +ionic_opcode_to_str (opcode), opcode);return -ENXIO ; }
Signature · 1 line
2.17.1
PATCH 16/16 ionic: replace set_vf data with union
In reply to Shannon NelsonThis (ab)use of a data buffer made some static code checkers rather itchy, so we replace the a generic data buffer with the union in the struct ionic_vf_setattr_cmd.
--- .../ethernet/pensando/ionic/ionic_bus_pci.c | 13 ++-- .../net/ethernet/pensando/ionic/ionic_dev.c | 45 ++------------ .../net/ethernet/pensando/ionic/ionic_dev.h | 3 +- .../net/ethernet/pensando/ionic/ionic_lif.c | 61 +++++++++++++------ 4 files changed, 55 insertions(+), 67 deletions(-)
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c +7 -6
@@ -109,8 +109,8 @@ void ionic_bus_unmap_dbpage(struct ionic *ionic, void __iomem *page)static void ionic_vf_dealloc_locked (struct ionic *ionic) { +struct ionic_vf_setattr_cmd vfc = { .attr =IONIC_VF_ATTR_STATSADDR };struct ionic_vf *v; -dma_addr_t dma =0 ;int i;if (!ionic->vfs)
@@ -120,9 +120,8 @@ static void ionic_vf_dealloc_locked(struct ionic *ionic) v = &ionic->vfs[i];if (v->stats_pa) { - (void )ionic_set_vf_config (ionic, i, -IONIC_VF_ATTR_STATSADDR , - (u8 *)&dma); + vfc.stats_pa =0 ; + (void )ionic_set_vf_config (ionic, i, &vfc);dma_unmap_single (ionic->dev, v->stats_pa,sizeof (v->stats),DMA_FROM_DEVICE ); v->stats_pa =0 ;
@@ -143,6 +142,7 @@ static void ionic_vf_dealloc(struct ionic *ionic)static int ionic_vf_alloc (struct ionic *ionic,int num_vfs) { +struct ionic_vf_setattr_cmd vfc = { .attr =IONIC_VF_ATTR_STATSADDR };struct ionic_vf *v;int err =0 ;int i;
@@ -166,9 +166,10 @@ static int ionic_vf_alloc(struct ionic *ionic, int num_vfs) } ionic->num_vfs++; +/* ignore failures from older FW, we just won't get stats */ - (void )ionic_set_vf_config (ionic, i,IONIC_VF_ATTR_STATSADDR , - (u8 *)&v->stats_pa); + vfc.stats_pa =cpu_to_le64 (v->stats_pa); + (void )ionic_set_vf_config (ionic, i, &vfc); } out:
drivers/net/ethernet/pensando/ionic/ionic_dev.c +4 -41
58 lines not on this page · raw message
drivers/net/ethernet/pensando/ionic/ionic_dev.h +2 -1
@@ -318,7 +318,8 @@ void ionic_dev_cmd_port_autoneg(struct ionic_dev *idev, u8 an_enable);void ionic_dev_cmd_port_fec (struct ionic_dev *idev,u8 fec_type);void ionic_dev_cmd_port_pause (struct ionic_dev *idev,u8 pause_type); -int ionic_set_vf_config (struct ionic *ionic,int vf,u8 attr,u8 *data); +int ionic_set_vf_config (struct ionic *ionic,int vf, +struct ionic_vf_setattr_cmd *vfc);int ionic_dev_cmd_vf_getattr (struct ionic *ionic,int vf,u8 attr,struct ionic_vf_getattr_comp *comp); void ionic_dev_cmd_queue_identify(struct ionic_dev *idev,
drivers/net/ethernet/pensando/ionic/ionic_lif.c +42 -19
149 lines not on this page · raw message
Signature · 1 line
2.17.1
Quoted 4 lines · On Mon, 24 Jan 2022 10:52:56 -0800 Shannon Nelson wrote:
Recent FW work has tightened up timings in its error recovery handling and uncovered weaknesses in the driver's responses, so this is a set of updates primarily for better handling of the firmware's recovery mechanisms.
Applied, thanks, 8a0de61c40af ("Merge branch 'ionic-fw-recovery'") in net-next.