| 132 | } |
| 133 | |
| 134 | int ngbe_pf_host_configure(struct rte_eth_dev *eth_dev) |
| 135 | { |
| 136 | uint32_t vtctl, fcrth; |
| 137 | uint32_t vfre_offset; |
| 138 | uint16_t vf_num; |
| 139 | const uint8_t VFRE_SHIFT = 5; /* VFRE 32 bits per slot */ |
| 140 | const uint8_t VFRE_MASK = (uint8_t)((1U << VFRE_SHIFT) - 1); |
| 141 | struct ngbe_hw *hw = ngbe_dev_hw(eth_dev); |
| 142 | uint32_t gpie; |
| 143 | uint32_t gcr_ext; |
| 144 | uint32_t vlanctrl; |
| 145 | int i; |
| 146 | |
| 147 | vf_num = dev_num_vf(eth_dev); |
| 148 | if (vf_num == 0) |
| 149 | return -1; |
| 150 | |
| 151 | /* set the default pool for PF */ |
| 152 | vtctl = rd32(hw, NGBE_POOLCTL); |
| 153 | vtctl &= ~NGBE_POOLCTL_DEFPL_MASK; |
| 154 | vtctl |= NGBE_POOLCTL_DEFPL(vf_num); |
| 155 | vtctl |= NGBE_POOLCTL_RPLEN; |
| 156 | wr32(hw, NGBE_POOLCTL, vtctl); |
| 157 | |
| 158 | vfre_offset = vf_num & VFRE_MASK; |
| 159 | |
| 160 | /* Enable pools reserved to PF only */ |
| 161 | wr32(hw, NGBE_POOLRXENA(0), (~0U) << vfre_offset); |
| 162 | wr32(hw, NGBE_POOLTXENA(0), (~0U) << vfre_offset); |
| 163 | |
| 164 | wr32(hw, NGBE_PSRCTL, NGBE_PSRCTL_LBENA); |
| 165 | |
| 166 | /* clear VMDq map to permanent rar 0 */ |
| 167 | hw->mac.clear_vmdq(hw, 0, BIT_MASK32); |
| 168 | |
| 169 | /* clear VMDq map to scan rar 31 */ |
| 170 | wr32(hw, NGBE_ETHADDRIDX, hw->mac.num_rar_entries); |
| 171 | wr32(hw, NGBE_ETHADDRASS, 0); |
| 172 | |
| 173 | /* set VMDq map to default PF pool */ |
| 174 | hw->mac.set_vmdq(hw, 0, vf_num); |
| 175 | |
| 176 | /* |
| 177 | * SW msut set PORTCTL.VT_Mode the same as GPIE.VT_Mode |
| 178 | */ |
| 179 | gpie = rd32(hw, NGBE_GPIE); |
| 180 | gpie |= NGBE_GPIE_MSIX; |
| 181 | gcr_ext = rd32(hw, NGBE_PORTCTL); |
| 182 | gcr_ext &= ~NGBE_PORTCTL_NUMVT_MASK; |
| 183 | |
| 184 | if (RTE_ETH_DEV_SRIOV(eth_dev).active == RTE_ETH_8_POOLS) |
| 185 | gcr_ext |= NGBE_PORTCTL_NUMVT_8; |
| 186 | |
| 187 | wr32(hw, NGBE_PORTCTL, gcr_ext); |
| 188 | wr32(hw, NGBE_GPIE, gpie); |
| 189 | |
| 190 | /* |
| 191 | * enable vlan filtering and allow all vlan tags through |
no test coverage detected