Skip to content

Commit 1d9c0bf

Browse files
Alexander DuyckJeff Kirsher
authored andcommitted
ixgbe: Use VMDq offset to indicate the default pool
This change makes it so that we can use the VMDq ring feature offset value to determine the default pool instead of using num_vfs. The reason for this change is to avoid issues should we fail to allocate vfinfo but have pre-existing VFs. What should happen in this case is that num_vfs will go to 0, but the VMDq offset will contain the location of the first PF pool. Signed-off-by: Alexander Duyck <[email protected]> Tested-by: Phil Schmitt <[email protected]> Tested-by: Sibai Li <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 769162e commit 1d9c0bf

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
#define IXGBE_MAX_VFTA_ENTRIES 128
114114
#define MAX_EMULATION_MAC_ADDRS 16
115115
#define IXGBE_MAX_PF_MACVLANS 15
116-
#define VMDQ_P(p) ((p) + adapter->num_vfs)
116+
#define VMDQ_P(p) ((p) + adapter->ring_feature[RING_F_VMDQ].offset)
117117
#define IXGBE_82599_VF_DEVICE_ID 0x10ED
118118
#define IXGBE_X540_VF_DEVICE_ID 0x1515
119119

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,7 +3118,7 @@ static void ixgbe_setup_psrtype(struct ixgbe_adapter *adapter)
31183118
psrtype |= 1 << 29;
31193119

31203120
for (p = 0; p < adapter->num_rx_pools; p++)
3121-
IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(adapter->num_vfs + p),
3121+
IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(VMDQ_P(p)),
31223122
psrtype);
31233123
}
31243124

@@ -3135,12 +3135,12 @@ static void ixgbe_configure_virtualization(struct ixgbe_adapter *adapter)
31353135
vmdctl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
31363136
vmdctl |= IXGBE_VMD_CTL_VMDQ_EN;
31373137
vmdctl &= ~IXGBE_VT_CTL_POOL_MASK;
3138-
vmdctl |= (adapter->num_vfs << IXGBE_VT_CTL_POOL_SHIFT);
3138+
vmdctl |= VMDQ_P(0) << IXGBE_VT_CTL_POOL_SHIFT;
31393139
vmdctl |= IXGBE_VT_CTL_REPLEN;
31403140
IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vmdctl);
31413141

3142-
vf_shift = adapter->num_vfs % 32;
3143-
reg_offset = (adapter->num_vfs >= 32) ? 1 : 0;
3142+
vf_shift = VMDQ_P(0) % 32;
3143+
reg_offset = (VMDQ_P(0) >= 32) ? 1 : 0;
31443144

31453145
/* Enable only the PF's pool for Tx/Rx */
31463146
IXGBE_WRITE_REG(hw, IXGBE_VFRE(reg_offset), (~0) << vf_shift);
@@ -3150,7 +3150,7 @@ static void ixgbe_configure_virtualization(struct ixgbe_adapter *adapter)
31503150
IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
31513151

31523152
/* Map PF MAC address in RAR Entry 0 to first pool following VFs */
3153-
hw->mac.ops.set_vmdq(hw, 0, adapter->num_vfs);
3153+
hw->mac.ops.set_vmdq(hw, 0, VMDQ_P(0));
31543154

31553155
/*
31563156
* Set up VF register offsets for selected VT Mode,
@@ -3310,10 +3310,9 @@ static int ixgbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
33103310
{
33113311
struct ixgbe_adapter *adapter = netdev_priv(netdev);
33123312
struct ixgbe_hw *hw = &adapter->hw;
3313-
int pool_ndx = adapter->num_vfs;
33143313

33153314
/* add VID to filter table */
3316-
hw->mac.ops.set_vfta(&adapter->hw, vid, pool_ndx, true);
3315+
hw->mac.ops.set_vfta(&adapter->hw, vid, VMDQ_P(0), true);
33173316
set_bit(vid, adapter->active_vlans);
33183317

33193318
return 0;
@@ -3323,10 +3322,9 @@ static int ixgbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
33233322
{
33243323
struct ixgbe_adapter *adapter = netdev_priv(netdev);
33253324
struct ixgbe_hw *hw = &adapter->hw;
3326-
int pool_ndx = adapter->num_vfs;
33273325

33283326
/* remove VID from filter table */
3329-
hw->mac.ops.set_vfta(&adapter->hw, vid, pool_ndx, false);
3327+
hw->mac.ops.set_vfta(&adapter->hw, vid, VMDQ_P(0), false);
33303328
clear_bit(vid, adapter->active_vlans);
33313329

33323330
return 0;
@@ -3444,7 +3442,6 @@ static int ixgbe_write_uc_addr_list(struct net_device *netdev)
34443442
{
34453443
struct ixgbe_adapter *adapter = netdev_priv(netdev);
34463444
struct ixgbe_hw *hw = &adapter->hw;
3447-
unsigned int vfn = adapter->num_vfs;
34483445
unsigned int rar_entries = IXGBE_MAX_PF_MACVLANS;
34493446
int count = 0;
34503447

@@ -3462,7 +3459,7 @@ static int ixgbe_write_uc_addr_list(struct net_device *netdev)
34623459
if (!rar_entries)
34633460
break;
34643461
hw->mac.ops.set_rar(hw, rar_entries--, ha->addr,
3465-
vfn, IXGBE_RAH_AV);
3462+
VMDQ_P(0), IXGBE_RAH_AV);
34663463
count++;
34673464
}
34683465
}
@@ -3536,12 +3533,14 @@ void ixgbe_set_rx_mode(struct net_device *netdev)
35363533
vmolr |= IXGBE_VMOLR_ROPE;
35373534
}
35383535

3539-
if (adapter->num_vfs) {
3536+
if (adapter->num_vfs)
35403537
ixgbe_restore_vf_multicasts(adapter);
3541-
vmolr |= IXGBE_READ_REG(hw, IXGBE_VMOLR(adapter->num_vfs)) &
3538+
3539+
if (hw->mac.type != ixgbe_mac_82598EB) {
3540+
vmolr |= IXGBE_READ_REG(hw, IXGBE_VMOLR(VMDQ_P(0))) &
35423541
~(IXGBE_VMOLR_MPE | IXGBE_VMOLR_ROMPE |
35433542
IXGBE_VMOLR_ROPE);
3544-
IXGBE_WRITE_REG(hw, IXGBE_VMOLR(adapter->num_vfs), vmolr);
3543+
IXGBE_WRITE_REG(hw, IXGBE_VMOLR(VMDQ_P(0)), vmolr);
35453544
}
35463545

35473546
/* This is useful for sniffing bad packets. */
@@ -4120,8 +4119,7 @@ void ixgbe_reset(struct ixgbe_adapter *adapter)
41204119
clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state);
41214120

41224121
/* reprogram the RAR[0] in case user changed it. */
4123-
hw->mac.ops.set_rar(hw, 0, hw->mac.addr, adapter->num_vfs,
4124-
IXGBE_RAH_AV);
4122+
hw->mac.ops.set_rar(hw, 0, hw->mac.addr, VMDQ_P(0), IXGBE_RAH_AV);
41254123
}
41264124

41274125
/**
@@ -6445,8 +6443,7 @@ static int ixgbe_set_mac(struct net_device *netdev, void *p)
64456443
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
64466444
memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len);
64476445

6448-
hw->mac.ops.set_rar(hw, 0, hw->mac.addr, adapter->num_vfs,
6449-
IXGBE_RAH_AV);
6446+
hw->mac.ops.set_rar(hw, 0, hw->mac.addr, VMDQ_P(0), IXGBE_RAH_AV);
64506447

64516448
return 0;
64526449
}

drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
225225
IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vmdctl);
226226
IXGBE_WRITE_FLUSH(hw);
227227

228+
/* Disable VMDq flag so device will be set in VM mode */
229+
if (adapter->ring_feature[RING_F_VMDQ].limit == 1)
230+
adapter->flags &= ~IXGBE_FLAG_VMDQ_ENABLED;
231+
adapter->ring_feature[RING_F_VMDQ].offset = 0;
232+
228233
/* take a breather then clean up driver data */
229234
msleep(100);
230235

0 commit comments

Comments
 (0)