bnx2x: (semantic) revise scheduling of sp_rtnl
authorYuval Mintz <yuvalmin@broadcom.com>
Wed, 12 Feb 2014 16:19:56 +0000 (18:19 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Feb 2014 00:15:42 +0000 (19:15 -0500)
This removes the various points where the driver use bit operations in order
to schedule the sp_rtnl_task from the code, adding a single utility function
that does it instead.

Signed-off-by: Yuval Mintz <yuvalmin@broadcom.com>
Signed-off-by: Ariel Elior <ariele@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnx2x/bnx2x.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c

index c871d19ab6e1131b5622cef8dd40a38c624b27ec..21fdd1b869db06d8d9bf09199960d0d5730575f5 100644 (file)
@@ -1402,7 +1402,7 @@ struct bnx2x_fw_stats_data {
 };
 
 /* Public slow path states */
-enum {
+enum sp_rtnl_flag {
        BNX2X_SP_RTNL_SETUP_TC,
        BNX2X_SP_RTNL_TX_TIMEOUT,
        BNX2X_SP_RTNL_FAN_FAILURE,
index 9d7419e0390bd526d52e850f0d54c3863c920ffd..9ded3dbb7678981c7b8c37abba17f5282dd2a5ce 100644 (file)
@@ -4773,12 +4773,8 @@ void bnx2x_tx_timeout(struct net_device *dev)
                bnx2x_panic();
 #endif
 
-       smp_mb__before_clear_bit();
-       set_bit(BNX2X_SP_RTNL_TX_TIMEOUT, &bp->sp_rtnl_state);
-       smp_mb__after_clear_bit();
-
        /* This allows the netif to be shutdown gracefully before resetting */
-       schedule_delayed_work(&bp->sp_rtnl_task, 0);
+       bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_TX_TIMEOUT, 0);
 }
 
 int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state)
@@ -4906,3 +4902,15 @@ void bnx2x_update_coalesce_sb_index(struct bnx2x *bp, u8 fw_sb_id,
        disable = disable ? 1 : (usec ? 0 : 1);
        storm_memset_hc_disable(bp, port, fw_sb_id, sb_index, disable);
 }
+
+void bnx2x_schedule_sp_rtnl(struct bnx2x *bp, enum sp_rtnl_flag flag,
+                           u32 verbose)
+{
+       smp_mb__before_clear_bit();
+       set_bit(flag, &bp->sp_rtnl_state);
+       smp_mb__after_clear_bit();
+       DP((BNX2X_MSG_SP | verbose), "Scheduling sp_rtnl task [Flag: %d]\n",
+          flag);
+       schedule_delayed_work(&bp->sp_rtnl_task, 0);
+}
+EXPORT_SYMBOL(bnx2x_schedule_sp_rtnl);
index bfc58d488bb52fde01d82ceb60647df083534bd8..5135cc7f7b6f678a077774298fd03b7e8553b556 100644 (file)
@@ -1324,4 +1324,7 @@ void bnx2x_fill_fw_str(struct bnx2x *bp, char *buf, size_t buf_len);
 int bnx2x_drain_tx_queues(struct bnx2x *bp);
 void bnx2x_squeeze_objects(struct bnx2x *bp);
 
+void bnx2x_schedule_sp_rtnl(struct bnx2x*, enum sp_rtnl_flag,
+                           u32 verbose);
+
 #endif /* BNX2X_CMN_H */
index fdace204b0549aa2599edd67c1c3112e0c4bf9de..97ea5421dd96f41bc3daf7a899ef9f1ddaab0931 100644 (file)
@@ -710,8 +710,7 @@ static inline void bnx2x_dcbx_update_tc_mapping(struct bnx2x *bp)
         * as we are handling an attention on a work queue which must be
         * flushed at some rtnl-locked contexts (e.g. if down)
         */
-       if (!test_and_set_bit(BNX2X_SP_RTNL_SETUP_TC, &bp->sp_rtnl_state))
-               schedule_delayed_work(&bp->sp_rtnl_task, 0);
+       bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_SETUP_TC, 0);
 }
 
 void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
@@ -764,10 +763,7 @@ void bnx2x_dcbx_set_params(struct bnx2x *bp, u32 state)
                        if (IS_MF(bp))
                                bnx2x_link_sync_notify(bp);
 
-                       set_bit(BNX2X_SP_RTNL_TX_STOP, &bp->sp_rtnl_state);
-
-                       schedule_delayed_work(&bp->sp_rtnl_task, 0);
-
+                       bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_TX_STOP, 0);
                        return;
                }
        case BNX2X_DCBX_STATE_TX_PAUSED:
index da4f75e5cf07993138fb17d5df486d2af31c87d9..84439152e499eeaa01035311146840b1574055fb 100644 (file)
@@ -3908,10 +3908,7 @@ static void bnx2x_fan_failure(struct bnx2x *bp)
         * This is due to some boards consuming sufficient power when driver is
         * up to overheat if fan fails.
         */
-       smp_mb__before_clear_bit();
-       set_bit(BNX2X_SP_RTNL_FAN_FAILURE, &bp->sp_rtnl_state);
-       smp_mb__after_clear_bit();
-       schedule_delayed_work(&bp->sp_rtnl_task, 0);
+       bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_FAN_FAILURE, 0);
 }
 
 static void bnx2x_attn_int_deasserted0(struct bnx2x *bp, u32 attn)
@@ -5303,6 +5300,8 @@ static void bnx2x_eq_int(struct bnx2x *bp)
                                        break;
 
                        } else {
+                               int cmd = BNX2X_SP_RTNL_AFEX_F_UPDATE;
+
                                DP(BNX2X_MSG_SP | BNX2X_MSG_MCP,
                                   "AFEX: ramrod completed FUNCTION_UPDATE\n");
                                f_obj->complete_cmd(bp, f_obj,
@@ -5312,12 +5311,7 @@ static void bnx2x_eq_int(struct bnx2x *bp)
                                 * sp_rtnl task as all Queue SP operations
                                 * should run under rtnl_lock.
                                 */
-                               smp_mb__before_clear_bit();
-                               set_bit(BNX2X_SP_RTNL_AFEX_F_UPDATE,
-                                       &bp->sp_rtnl_state);
-                               smp_mb__after_clear_bit();
-
-                               schedule_delayed_work(&bp->sp_rtnl_task, 0);
+                               bnx2x_schedule_sp_rtnl(bp, cmd, 0);
                        }
 
                        goto next_spqe;
@@ -12082,11 +12076,8 @@ static void bnx2x_set_rx_mode(struct net_device *dev)
                return;
        } else {
                /* Schedule an SP task to handle rest of change */
-               DP(NETIF_MSG_IFUP, "Scheduling an Rx mode change\n");
-               smp_mb__before_clear_bit();
-               set_bit(BNX2X_SP_RTNL_RX_MODE, &bp->sp_rtnl_state);
-               smp_mb__after_clear_bit();
-               schedule_delayed_work(&bp->sp_rtnl_task, 0);
+               bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_RX_MODE,
+                                      NETIF_MSG_IFUP);
        }
 }
 
@@ -12119,11 +12110,8 @@ void bnx2x_set_rx_mode_inner(struct bnx2x *bp)
                        /* configuring mcast to a vf involves sleeping (when we
                         * wait for the pf's response).
                         */
-                       smp_mb__before_clear_bit();
-                       set_bit(BNX2X_SP_RTNL_VFPF_MCAST,
-                               &bp->sp_rtnl_state);
-                       smp_mb__after_clear_bit();
-                       schedule_delayed_work(&bp->sp_rtnl_task, 0);
+                       bnx2x_schedule_sp_rtnl(bp,
+                                              BNX2X_SP_RTNL_VFPF_MCAST, 0);
                }
        }
 
index bf001602bbb65b1d62b6d58d5cba89aa7543503d..98b53671a6527467be3896626c511a16dafa79bf 100644 (file)
@@ -983,11 +983,8 @@ op_err:
 op_done:
        case BNX2X_VFOP_QSETUP_DONE:
                vf->cfg_flags |= VF_CFG_VLAN;
-               smp_mb__before_clear_bit();
-               set_bit(BNX2X_SP_RTNL_HYPERVISOR_VLAN,
-                       &bp->sp_rtnl_state);
-               smp_mb__after_clear_bit();
-               schedule_delayed_work(&bp->sp_rtnl_task, 0);
+               bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_HYPERVISOR_VLAN,
+                                      BNX2X_MSG_IOV);
                bnx2x_vfop_end(bp, vf, vfop);
                return;
        default:
@@ -3812,13 +3809,9 @@ void bnx2x_timer_sriov(struct bnx2x *bp)
        bnx2x_sample_bulletin(bp);
 
        /* if channel is down we need to self destruct */
-       if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN) {
-               smp_mb__before_clear_bit();
-               set_bit(BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
-                       &bp->sp_rtnl_state);
-               smp_mb__after_clear_bit();
-               schedule_delayed_work(&bp->sp_rtnl_task, 0);
-       }
+       if (bp->old_bulletin.valid_bitmap & 1 << CHANNEL_DOWN)
+               bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_VFPF_CHANNEL_DOWN,
+                                      BNX2X_MSG_IOV);
 }
 
 void __iomem *bnx2x_vf_doorbells(struct bnx2x *bp)