hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
....@@ -100,13 +100,11 @@
100100 DP(NETIF_MSG_HW, "write 0x%08x to IGU(via GRC) addr 0x%x\n",
101101 cmd_data.sb_id_and_flags, igu_addr_data);
102102 REG_WR(bp, igu_addr_data, cmd_data.sb_id_and_flags);
103
- mmiowb();
104103 barrier();
105104
106105 DP(NETIF_MSG_HW, "write 0x%08x to IGU(via GRC) addr 0x%x\n",
107106 ctl, igu_addr_ctl);
108107 REG_WR(bp, igu_addr_ctl, ctl);
109
- mmiowb();
110108 barrier();
111109 }
112110
....@@ -209,7 +207,10 @@
209207 */
210208 __set_bit(BNX2X_Q_FLG_TX_SWITCH, &setup_p->flags);
211209 __set_bit(BNX2X_Q_FLG_TX_SEC, &setup_p->flags);
212
- __set_bit(BNX2X_Q_FLG_ANTI_SPOOF, &setup_p->flags);
210
+ if (vf->spoofchk)
211
+ __set_bit(BNX2X_Q_FLG_ANTI_SPOOF, &setup_p->flags);
212
+ else
213
+ __clear_bit(BNX2X_Q_FLG_ANTI_SPOOF, &setup_p->flags);
213214
214215 /* Setup-op rx parameters */
215216 if (test_bit(BNX2X_Q_TYPE_HAS_RX, &q_type)) {
....@@ -328,27 +329,6 @@
328329 ++vf->sb_count;
329330 }
330331 BP_VFDB(bp)->vf_sbs_pool++;
331
-}
332
-
333
-static inline void bnx2x_vf_vlan_credit(struct bnx2x *bp,
334
- struct bnx2x_vlan_mac_obj *obj,
335
- atomic_t *counter)
336
-{
337
- struct list_head *pos;
338
- int read_lock;
339
- int cnt = 0;
340
-
341
- read_lock = bnx2x_vlan_mac_h_read_lock(bp, obj);
342
- if (read_lock)
343
- DP(BNX2X_MSG_SP, "Failed to take vlan mac read head; continuing anyway\n");
344
-
345
- list_for_each(pos, &obj->head)
346
- cnt++;
347
-
348
- if (!read_lock)
349
- bnx2x_vlan_mac_h_read_unlock(bp, obj);
350
-
351
- atomic_set(counter, cnt);
352332 }
353333
354334 static int bnx2x_vf_vlan_mac_clear(struct bnx2x *bp, struct bnx2x_virtf *vf,
....@@ -778,9 +758,18 @@
778758
779759 void bnx2x_vf_enable_access(struct bnx2x *bp, u8 abs_vfid)
780760 {
761
+ u16 abs_fid;
762
+
763
+ abs_fid = FW_VF_HANDLE(abs_vfid);
764
+
781765 /* set the VF-PF association in the FW */
782
- storm_memset_vf_to_pf(bp, FW_VF_HANDLE(abs_vfid), BP_FUNC(bp));
783
- storm_memset_func_en(bp, FW_VF_HANDLE(abs_vfid), 1);
766
+ storm_memset_vf_to_pf(bp, abs_fid, BP_FUNC(bp));
767
+ storm_memset_func_en(bp, abs_fid, 1);
768
+
769
+ /* Invalidate fp_hsi version for vfs */
770
+ if (bp->fw_cap & FW_CAP_INVALIDATE_VF_FP_HSI)
771
+ REG_WR8(bp, BAR_XSTRORM_INTMEM +
772
+ XSTORM_ETH_FUNCTION_INFO_FP_HSI_VALID_E2_OFFSET(abs_fid), 0);
784773
785774 /* clear vf errors*/
786775 bnx2x_vf_semi_clear_err(bp, abs_vfid);
....@@ -806,16 +795,20 @@
806795
807796 static u8 bnx2x_vf_is_pcie_pending(struct bnx2x *bp, u8 abs_vfid)
808797 {
809
- struct pci_dev *dev;
810798 struct bnx2x_virtf *vf = bnx2x_vf_by_abs_fid(bp, abs_vfid);
799
+ struct pci_dev *dev;
800
+ bool pending;
811801
812802 if (!vf)
813803 return false;
814804
815805 dev = pci_get_domain_bus_and_slot(vf->domain, vf->bus, vf->devfn);
816
- if (dev)
817
- return bnx2x_is_pcie_pending(dev);
818
- return false;
806
+ if (!dev)
807
+ return false;
808
+ pending = bnx2x_is_pcie_pending(dev);
809
+ pci_dev_put(dev);
810
+
811
+ return pending;
819812 }
820813
821814 int bnx2x_vf_flr_clnup_epilog(struct bnx2x *bp, u8 abs_vfid)
....@@ -1271,6 +1264,8 @@
12711264 bnx2x_vf(bp, i, state) = VF_FREE;
12721265 mutex_init(&bnx2x_vf(bp, i, op_mutex));
12731266 bnx2x_vf(bp, i, op_current) = CHANNEL_TLV_NONE;
1267
+ /* enable spoofchk by default */
1268
+ bnx2x_vf(bp, i, spoofchk) = 1;
12741269 }
12751270
12761271 /* re-read the IGU CAM for VFs - index and abs_vfid must be set */
....@@ -1829,7 +1824,7 @@
18291824 DP(BNX2X_MSG_IOV, "got VF [%d:%d] RSS update ramrod\n",
18301825 vf->abs_vfid, qidx);
18311826 bnx2x_vf_handle_rss_update_eqe(bp, vf);
1832
- /* fall through */
1827
+ fallthrough;
18331828 case EVENT_RING_OPCODE_VF_FLR:
18341829 /* Do nothing for now */
18351830 return 0;
....@@ -2227,7 +2222,7 @@
22272222 rc = bnx2x_vf_close(bp, vf);
22282223 if (rc)
22292224 goto op_err;
2230
- /* Fallthrough to release resources */
2225
+ fallthrough; /* to release resources */
22312226 case VF_ACQUIRED:
22322227 DP(BNX2X_MSG_IOV, "about to free resources\n");
22332228 bnx2x_vf_free_resc(bp, vf);
....@@ -2640,7 +2635,8 @@
26402635 ivi->qos = 0;
26412636 ivi->max_tx_rate = 10000; /* always 10G. TBA take from link struct */
26422637 ivi->min_tx_rate = 0;
2643
- ivi->spoofchk = 1; /*always enabled */
2638
+ ivi->spoofchk = vf->spoofchk ? 1 : 0;
2639
+ ivi->linkstate = vf->link_cfg;
26442640 if (vf->state == VF_ENABLED) {
26452641 /* mac and vlan are in vlan_mac objects */
26462642 if (bnx2x_validate_vf_sp_objs(bp, vf, false)) {
....@@ -2958,6 +2954,77 @@
29582954 return rc;
29592955 }
29602956
2957
+int bnx2x_set_vf_spoofchk(struct net_device *dev, int idx, bool val)
2958
+{
2959
+ struct bnx2x *bp = netdev_priv(dev);
2960
+ struct bnx2x_virtf *vf;
2961
+ int i, rc = 0;
2962
+
2963
+ vf = BP_VF(bp, idx);
2964
+ if (!vf)
2965
+ return -EINVAL;
2966
+
2967
+ /* nothing to do */
2968
+ if (vf->spoofchk == val)
2969
+ return 0;
2970
+
2971
+ vf->spoofchk = val ? 1 : 0;
2972
+
2973
+ DP(BNX2X_MSG_IOV, "%s spoofchk for VF %d\n",
2974
+ val ? "enabling" : "disabling", idx);
2975
+
2976
+ /* is vf initialized and queue set up? */
2977
+ if (vf->state != VF_ENABLED ||
2978
+ bnx2x_get_q_logical_state(bp, &bnx2x_leading_vfq(vf, sp_obj)) !=
2979
+ BNX2X_Q_LOGICAL_STATE_ACTIVE)
2980
+ return rc;
2981
+
2982
+ /* User should be able to see error in system logs */
2983
+ if (!bnx2x_validate_vf_sp_objs(bp, vf, true))
2984
+ return -EINVAL;
2985
+
2986
+ /* send queue update ramrods to configure spoofchk */
2987
+ for_each_vfq(vf, i) {
2988
+ struct bnx2x_queue_state_params q_params = {NULL};
2989
+ struct bnx2x_queue_update_params *update_params;
2990
+
2991
+ q_params.q_obj = &bnx2x_vfq(vf, i, sp_obj);
2992
+
2993
+ /* validate the Q is UP */
2994
+ if (bnx2x_get_q_logical_state(bp, q_params.q_obj) !=
2995
+ BNX2X_Q_LOGICAL_STATE_ACTIVE)
2996
+ continue;
2997
+
2998
+ __set_bit(RAMROD_COMP_WAIT, &q_params.ramrod_flags);
2999
+ q_params.cmd = BNX2X_Q_CMD_UPDATE;
3000
+ update_params = &q_params.params.update;
3001
+ __set_bit(BNX2X_Q_UPDATE_ANTI_SPOOF_CHNG,
3002
+ &update_params->update_flags);
3003
+ if (val) {
3004
+ __set_bit(BNX2X_Q_UPDATE_ANTI_SPOOF,
3005
+ &update_params->update_flags);
3006
+ } else {
3007
+ __clear_bit(BNX2X_Q_UPDATE_ANTI_SPOOF,
3008
+ &update_params->update_flags);
3009
+ }
3010
+
3011
+ /* Update the Queue state */
3012
+ rc = bnx2x_queue_state_change(bp, &q_params);
3013
+ if (rc) {
3014
+ BNX2X_ERR("Failed to %s spoofchk on VF %d - vfq %d\n",
3015
+ val ? "enable" : "disable", idx, i);
3016
+ goto out;
3017
+ }
3018
+ }
3019
+out:
3020
+ if (!rc)
3021
+ DP(BNX2X_MSG_IOV,
3022
+ "%s spoofchk for VF[%d]\n", val ? "Enabled" : "Disabled",
3023
+ idx);
3024
+
3025
+ return rc;
3026
+}
3027
+
29613028 /* crc is the first field in the bulletin board. Compute the crc over the
29623029 * entire bulletin board excluding the crc field itself. Use the length field
29633030 * as the Bulletin Board was posted by a PF with possibly a different version