aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c')
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c56
1 files changed, 33 insertions, 23 deletions
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index 1d925fd9cdc6..fbc026c4cab2 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -1755,11 +1755,8 @@ void bnx2x_iov_init_dq(struct bnx2x *bp)
1755 1755
1756void bnx2x_iov_init_dmae(struct bnx2x *bp) 1756void bnx2x_iov_init_dmae(struct bnx2x *bp)
1757{ 1757{
1758 DP(BNX2X_MSG_IOV, "SRIOV is %s\n", IS_SRIOV(bp) ? "ON" : "OFF"); 1758 if (pci_find_ext_capability(bp->pdev, PCI_EXT_CAP_ID_SRIOV))
1759 if (!IS_SRIOV(bp)) 1759 REG_WR(bp, DMAE_REG_BACKWARD_COMP_EN, 0);
1760 return;
1761
1762 REG_WR(bp, DMAE_REG_BACKWARD_COMP_EN, 0);
1763} 1760}
1764 1761
1765static int bnx2x_vf_bus(struct bnx2x *bp, int vfid) 1762static int bnx2x_vf_bus(struct bnx2x *bp, int vfid)
@@ -3092,8 +3089,9 @@ void bnx2x_disable_sriov(struct bnx2x *bp)
3092 pci_disable_sriov(bp->pdev); 3089 pci_disable_sriov(bp->pdev);
3093} 3090}
3094 3091
3095static int bnx2x_vf_ndo_sanity(struct bnx2x *bp, int vfidx, 3092static int bnx2x_vf_ndo_prep(struct bnx2x *bp, int vfidx,
3096 struct bnx2x_virtf *vf) 3093 struct bnx2x_virtf **vf,
3094 struct pf_vf_bulletin_content **bulletin)
3097{ 3095{
3098 if (bp->state != BNX2X_STATE_OPEN) { 3096 if (bp->state != BNX2X_STATE_OPEN) {
3099 BNX2X_ERR("vf ndo called though PF is down\n"); 3097 BNX2X_ERR("vf ndo called though PF is down\n");
@@ -3111,12 +3109,22 @@ static int bnx2x_vf_ndo_sanity(struct bnx2x *bp, int vfidx,
3111 return -EINVAL; 3109 return -EINVAL;
3112 } 3110 }
3113 3111
3114 if (!vf) { 3112 /* init members */
3113 *vf = BP_VF(bp, vfidx);
3114 *bulletin = BP_VF_BULLETIN(bp, vfidx);
3115
3116 if (!*vf) {
3115 BNX2X_ERR("vf ndo called but vf was null. vfidx was %d\n", 3117 BNX2X_ERR("vf ndo called but vf was null. vfidx was %d\n",
3116 vfidx); 3118 vfidx);
3117 return -EINVAL; 3119 return -EINVAL;
3118 } 3120 }
3119 3121
3122 if (!*bulletin) {
3123 BNX2X_ERR("vf ndo called but Bulletin Board struct is null. vfidx was %d\n",
3124 vfidx);
3125 return -EINVAL;
3126 }
3127
3120 return 0; 3128 return 0;
3121} 3129}
3122 3130
@@ -3124,17 +3132,19 @@ int bnx2x_get_vf_config(struct net_device *dev, int vfidx,
3124 struct ifla_vf_info *ivi) 3132 struct ifla_vf_info *ivi)
3125{ 3133{
3126 struct bnx2x *bp = netdev_priv(dev); 3134 struct bnx2x *bp = netdev_priv(dev);
3127 struct bnx2x_virtf *vf = BP_VF(bp, vfidx); 3135 struct bnx2x_virtf *vf = NULL;
3128 struct bnx2x_vlan_mac_obj *mac_obj = &bnx2x_vfq(vf, 0, mac_obj); 3136 struct pf_vf_bulletin_content *bulletin = NULL;
3129 struct bnx2x_vlan_mac_obj *vlan_obj = &bnx2x_vfq(vf, 0, vlan_obj); 3137 struct bnx2x_vlan_mac_obj *mac_obj;
3130 struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vfidx); 3138 struct bnx2x_vlan_mac_obj *vlan_obj;
3131 int rc; 3139 int rc;
3132 3140
3133 /* sanity */ 3141 /* sanity and init */
3134 rc = bnx2x_vf_ndo_sanity(bp, vfidx, vf); 3142 rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin);
3135 if (rc) 3143 if (rc)
3136 return rc; 3144 return rc;
3137 if (!mac_obj || !vlan_obj || !bulletin) { 3145 mac_obj = &bnx2x_vfq(vf, 0, mac_obj);
3146 vlan_obj = &bnx2x_vfq(vf, 0, vlan_obj);
3147 if (!mac_obj || !vlan_obj) {
3138 BNX2X_ERR("VF partially initialized\n"); 3148 BNX2X_ERR("VF partially initialized\n");
3139 return -EINVAL; 3149 return -EINVAL;
3140 } 3150 }
@@ -3191,11 +3201,11 @@ int bnx2x_set_vf_mac(struct net_device *dev, int vfidx, u8 *mac)
3191{ 3201{
3192 struct bnx2x *bp = netdev_priv(dev); 3202 struct bnx2x *bp = netdev_priv(dev);
3193 int rc, q_logical_state; 3203 int rc, q_logical_state;
3194 struct bnx2x_virtf *vf = BP_VF(bp, vfidx); 3204 struct bnx2x_virtf *vf = NULL;
3195 struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vfidx); 3205 struct pf_vf_bulletin_content *bulletin = NULL;
3196 3206
3197 /* sanity */ 3207 /* sanity and init */
3198 rc = bnx2x_vf_ndo_sanity(bp, vfidx, vf); 3208 rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin);
3199 if (rc) 3209 if (rc)
3200 return rc; 3210 return rc;
3201 if (!is_valid_ether_addr(mac)) { 3211 if (!is_valid_ether_addr(mac)) {
@@ -3257,11 +3267,11 @@ int bnx2x_set_vf_vlan(struct net_device *dev, int vfidx, u16 vlan, u8 qos)
3257{ 3267{
3258 struct bnx2x *bp = netdev_priv(dev); 3268 struct bnx2x *bp = netdev_priv(dev);
3259 int rc, q_logical_state; 3269 int rc, q_logical_state;
3260 struct bnx2x_virtf *vf = BP_VF(bp, vfidx); 3270 struct bnx2x_virtf *vf = NULL;
3261 struct pf_vf_bulletin_content *bulletin = BP_VF_BULLETIN(bp, vfidx); 3271 struct pf_vf_bulletin_content *bulletin = NULL;
3262 3272
3263 /* sanity */ 3273 /* sanity and init */
3264 rc = bnx2x_vf_ndo_sanity(bp, vfidx, vf); 3274 rc = bnx2x_vf_ndo_prep(bp, vfidx, &vf, &bulletin);
3265 if (rc) 3275 if (rc)
3266 return rc; 3276 return rc;
3267 3277