i40e: Fix sparse warning: missing error code 'err'
[linux-2.6-microblaze.git] / drivers / net / ethernet / intel / i40e / i40e_main.c
index 8bb8eb6..30ad7c0 100644 (file)
@@ -2560,8 +2560,7 @@ int i40e_sync_vsi_filters(struct i40e_vsi *vsi)
                                 i40e_stat_str(hw, aq_ret),
                                 i40e_aq_str(hw, hw->aq.asq_last_status));
                } else {
-                       dev_info(&pf->pdev->dev, "%s is %s allmulti mode.\n",
-                                vsi->netdev->name,
+                       dev_info(&pf->pdev->dev, "%s allmulti mode.\n",
                                 cur_multipromisc ? "entering" : "leaving");
                }
        }
@@ -2616,7 +2615,7 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)
                return;
        if (!test_and_clear_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state))
                return;
-       if (test_and_set_bit(__I40E_VF_DISABLE, pf->state)) {
+       if (test_bit(__I40E_VF_DISABLE, pf->state)) {
                set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state);
                return;
        }
@@ -2634,7 +2633,6 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf)
                        }
                }
        }
-       clear_bit(__I40E_VF_DISABLE, pf->state);
 }
 
 /**
@@ -3259,6 +3257,17 @@ static int i40e_configure_tx_ring(struct i40e_ring *ring)
        return 0;
 }
 
+/**
+ * i40e_rx_offset - Return expected offset into page to access data
+ * @rx_ring: Ring we are requesting offset of
+ *
+ * Returns the offset value for ring into the data buffer.
+ */
+static unsigned int i40e_rx_offset(struct i40e_ring *rx_ring)
+{
+       return ring_uses_build_skb(rx_ring) ? I40E_SKB_PAD : 0;
+}
+
 /**
  * i40e_configure_rx_ring - Configure a receive ring context
  * @ring: The Rx ring to configure
@@ -3370,6 +3379,8 @@ static int i40e_configure_rx_ring(struct i40e_ring *ring)
        else
                set_ring_build_skb_enabled(ring);
 
+       ring->rx_offset = i40e_rx_offset(ring);
+
        /* cache tail for quicker writes, and clear the reg before use */
        ring->tail = hw->hw_addr + I40E_QRX_TAIL(pf_q);
        writel(0, ring->tail);
@@ -5937,7 +5948,7 @@ static int i40e_add_channel(struct i40e_pf *pf, u16 uplink_seid,
        ch->enabled_tc = !i40e_is_channel_macvlan(ch) && enabled_tc;
        ch->seid = ctxt.seid;
        ch->vsi_number = ctxt.vsi_number;
-       ch->stat_counter_idx = cpu_to_le16(ctxt.info.stat_counter_idx);
+       ch->stat_counter_idx = le16_to_cpu(ctxt.info.stat_counter_idx);
 
        /* copy just the sections touched not the entire info
         * since not all sections are valid as returned by
@@ -6726,9 +6737,9 @@ out:
                        set_bit(__I40E_CLIENT_SERVICE_REQUESTED, pf->state);
                        set_bit(__I40E_CLIENT_L2_CHANGE, pf->state);
                }
-       /* registers are set, lets apply */
-       if (pf->hw_features & I40E_HW_USE_SET_LLDP_MIB)
-               ret = i40e_hw_set_dcb_config(pf, new_cfg);
+               /* registers are set, lets apply */
+               if (pf->hw_features & I40E_HW_USE_SET_LLDP_MIB)
+                       ret = i40e_hw_set_dcb_config(pf, new_cfg);
        }
 
 err:
@@ -7977,8 +7988,8 @@ static inline void
 i40e_set_cld_element(struct i40e_cloud_filter *filter,
                     struct i40e_aqc_cloud_filters_element_data *cld)
 {
-       int i, j;
        u32 ipa;
+       int i;
 
        memset(cld, 0, sizeof(*cld));
        ether_addr_copy(cld->outer_mac, filter->dst_mac);
@@ -7989,14 +8000,14 @@ i40e_set_cld_element(struct i40e_cloud_filter *filter,
 
        if (filter->n_proto == ETH_P_IPV6) {
 #define IPV6_MAX_INDEX (ARRAY_SIZE(filter->dst_ipv6) - 1)
-               for (i = 0, j = 0; i < ARRAY_SIZE(filter->dst_ipv6);
-                    i++, j += 2) {
+               for (i = 0; i < ARRAY_SIZE(filter->dst_ipv6); i++) {
                        ipa = be32_to_cpu(filter->dst_ipv6[IPV6_MAX_INDEX - i]);
-                       ipa = cpu_to_le32(ipa);
-                       memcpy(&cld->ipaddr.raw_v6.data[j], &ipa, sizeof(ipa));
+
+                       *(__le32 *)&cld->ipaddr.raw_v6.data[i * 2] = cpu_to_le32(ipa);
                }
        } else {
                ipa = be32_to_cpu(filter->dst_ipv4);
+
                memcpy(&cld->ipaddr.v4.data, &ipa, sizeof(ipa));
        }
 
@@ -8044,6 +8055,8 @@ int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,
        if (filter->flags >= ARRAY_SIZE(flag_table))
                return I40E_ERR_CONFIG;
 
+       memset(&cld_filter, 0, sizeof(cld_filter));
+
        /* copy element needed to add cloud filter from filter */
        i40e_set_cld_element(filter, &cld_filter);
 
@@ -8107,10 +8120,13 @@ int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,
                return -EOPNOTSUPP;
 
        /* adding filter using src_port/src_ip is not supported at this stage */
-       if (filter->src_port || filter->src_ipv4 ||
+       if (filter->src_port ||
+           (filter->src_ipv4 && filter->n_proto != ETH_P_IPV6) ||
            !ipv6_addr_any(&filter->ip.v6.src_ip6))
                return -EOPNOTSUPP;
 
+       memset(&cld_filter, 0, sizeof(cld_filter));
+
        /* copy element needed to add cloud filter from filter */
        i40e_set_cld_element(filter, &cld_filter.element);
 
@@ -8134,7 +8150,7 @@ int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,
                        cpu_to_le16(I40E_AQC_ADD_CLOUD_FILTER_MAC_VLAN_PORT);
                }
 
-       } else if (filter->dst_ipv4 ||
+       } else if ((filter->dst_ipv4 && filter->n_proto != ETH_P_IPV6) ||
                   !ipv6_addr_any(&filter->ip.v6.dst_ip6)) {
                cld_filter.element.flags =
                                cpu_to_le16(I40E_AQC_ADD_CLOUD_FILTER_IP_PORT);
@@ -8928,11 +8944,6 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired)
                dev_dbg(&pf->pdev->dev, "PFR requested\n");
                i40e_handle_reset_warning(pf, lock_acquired);
 
-               dev_info(&pf->pdev->dev,
-                        pf->flags & I40E_FLAG_DISABLE_FW_LLDP ?
-                        "FW LLDP is disabled\n" :
-                        "FW LLDP is enabled\n");
-
        } else if (reset_flags & I40E_PF_RESET_AND_REBUILD_FLAG) {
                /* Request a PF Reset
                 *
@@ -8940,6 +8951,10 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired)
                 */
                i40e_prep_for_reset(pf);
                i40e_reset_and_rebuild(pf, true, lock_acquired);
+               dev_info(&pf->pdev->dev,
+                        pf->flags & I40E_FLAG_DISABLE_FW_LLDP ?
+                        "FW LLDP is disabled\n" :
+                        "FW LLDP is enabled\n");
 
        } else if (reset_flags & BIT_ULL(__I40E_REINIT_REQUESTED)) {
                int v;
@@ -10462,7 +10477,6 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
        int old_recovery_mode_bit = test_bit(__I40E_RECOVERY_MODE, pf->state);
        struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
        struct i40e_hw *hw = &pf->hw;
-       u8 set_fc_aq_fail = 0;
        i40e_status ret;
        u32 val;
        int v;
@@ -10558,12 +10572,6 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
                goto end_core_reset;
        }
 
-       if (!lock_acquired)
-               rtnl_lock();
-       ret = i40e_setup_pf_switch(pf, reinit);
-       if (ret)
-               goto end_unlock;
-
 #ifdef CONFIG_I40E_DCB
        /* Enable FW to write a default DCB config on link-up
         * unless I40E_FLAG_TC_MQPRIO was enabled or DCB
@@ -10578,7 +10586,7 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
                        i40e_aq_set_dcb_parameters(hw, false, NULL);
                        dev_warn(&pf->pdev->dev,
                                 "DCB is not supported for X710-T*L 2.5/5G speeds\n");
-                                pf->flags &= ~I40E_FLAG_DCB_CAPABLE;
+                       pf->flags &= ~I40E_FLAG_DCB_CAPABLE;
                } else {
                        i40e_aq_set_dcb_parameters(hw, true, NULL);
                        ret = i40e_init_pf_dcb(pf);
@@ -10592,6 +10600,11 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
        }
 
 #endif /* CONFIG_I40E_DCB */
+       if (!lock_acquired)
+               rtnl_lock();
+       ret = i40e_setup_pf_switch(pf, reinit);
+       if (ret)
+               goto end_unlock;
 
        /* The driver only wants link up/down and module qualification
         * reports from firmware.  Note the negative logic.
@@ -10605,13 +10618,6 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
                         i40e_stat_str(&pf->hw, ret),
                         i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status));
 
-       /* make sure our flow control settings are restored */
-       ret = i40e_set_fc(&pf->hw, &set_fc_aq_fail, true);
-       if (ret)
-               dev_dbg(&pf->pdev->dev, "setting flow control: ret = %s last_status = %s\n",
-                       i40e_stat_str(&pf->hw, ret),
-                       i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status));
-
        /* Rebuild the VSIs and VEBs that existed before reset.
         * They are still in our local switch element arrays, so only
         * need to rebuild the switch model in the HW.
@@ -12191,6 +12197,8 @@ i40e_status i40e_set_partition_bw_setting(struct i40e_pf *pf)
        struct i40e_aqc_configure_partition_bw_data bw_data;
        i40e_status status;
 
+       memset(&bw_data, 0, sizeof(bw_data));
+
        /* Set the valid bit for this PF */
        bw_data.pf_valid_bits = cpu_to_le16(BIT(pf->hw.pf_id));
        bw_data.max_bw[pf->hw.pf_id] = pf->max_bw & I40E_ALT_BW_VALUE_MASK;
@@ -15130,12 +15138,16 @@ static int i40e_init_recovery_mode(struct i40e_pf *pf, struct i40e_hw *hw)
         * in order to register the netdev
         */
        v_idx = i40e_vsi_mem_alloc(pf, I40E_VSI_MAIN);
-       if (v_idx < 0)
+       if (v_idx < 0) {
+               err = v_idx;
                goto err_switch_setup;
+       }
        pf->lan_vsi = v_idx;
        vsi = pf->vsi[v_idx];
-       if (!vsi)
+       if (!vsi) {
+               err = -EFAULT;
                goto err_switch_setup;
+       }
        vsi->alloc_queue_pairs = 1;
        err = i40e_config_netdev(vsi);
        if (err)
@@ -15198,7 +15210,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        int err;
        u32 val;
        u32 i;
-       u8 set_fc_aq_fail;
 
        err = pci_enable_device_mem(pdev);
        if (err)
@@ -15537,24 +15548,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        }
        INIT_LIST_HEAD(&pf->vsi[pf->lan_vsi]->ch_list);
 
-       /* Make sure flow control is set according to current settings */
-       err = i40e_set_fc(hw, &set_fc_aq_fail, true);
-       if (set_fc_aq_fail & I40E_SET_FC_AQ_FAIL_GET)
-               dev_dbg(&pf->pdev->dev,
-                       "Set fc with err %s aq_err %s on get_phy_cap\n",
-                       i40e_stat_str(hw, err),
-                       i40e_aq_str(hw, hw->aq.asq_last_status));
-       if (set_fc_aq_fail & I40E_SET_FC_AQ_FAIL_SET)
-               dev_dbg(&pf->pdev->dev,
-                       "Set fc with err %s aq_err %s on set_phy_config\n",
-                       i40e_stat_str(hw, err),
-                       i40e_aq_str(hw, hw->aq.asq_last_status));
-       if (set_fc_aq_fail & I40E_SET_FC_AQ_FAIL_UPDATE)
-               dev_dbg(&pf->pdev->dev,
-                       "Set fc with err %s aq_err %s on get_link_info\n",
-                       i40e_stat_str(hw, err),
-                       i40e_aq_str(hw, hw->aq.asq_last_status));
-
        /* if FDIR VSI was set up, start it now */
        for (i = 0; i < pf->num_alloc_vsi; i++) {
                if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) {
@@ -15611,6 +15604,8 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                if (err) {
                        dev_info(&pdev->dev,
                                 "setup of misc vector failed: %d\n", err);
+                       i40e_cloud_filter_exit(pf);
+                       i40e_fdir_teardown(pf);
                        goto err_vsis;
                }
        }