| 154 | } |
| 155 | |
| 156 | static int |
| 157 | enetc_hardware_init(struct enetc_eth_hw *hw) |
| 158 | { |
| 159 | struct enetc_hw *enetc_hw = &hw->hw; |
| 160 | uint32_t *mac = (uint32_t *)hw->mac.addr; |
| 161 | uint32_t high_mac = 0; |
| 162 | uint16_t low_mac = 0; |
| 163 | |
| 164 | PMD_INIT_FUNC_TRACE(); |
| 165 | /* Calculating and storing the base HW addresses */ |
| 166 | hw->hw.port = (void *)((size_t)hw->hw.reg + ENETC_PORT_BASE); |
| 167 | hw->hw.global = (void *)((size_t)hw->hw.reg + ENETC_GLOBAL_BASE); |
| 168 | |
| 169 | /* WA for Rx lock-up HW erratum */ |
| 170 | enetc_port_wr(enetc_hw, ENETC_PM0_RX_FIFO, 1); |
| 171 | |
| 172 | /* set ENETC transaction flags to coherent, don't allocate. |
| 173 | * BD writes merge with surrounding cache line data, frame data writes |
| 174 | * overwrite cache line. |
| 175 | */ |
| 176 | enetc_wr(enetc_hw, ENETC_SICAR0, ENETC_SICAR0_COHERENT); |
| 177 | |
| 178 | /* Enabling Station Interface */ |
| 179 | enetc_wr(enetc_hw, ENETC_SIMR, ENETC_SIMR_EN); |
| 180 | |
| 181 | |
| 182 | if (hw->device_id == ENETC_DEV_ID_VF) { |
| 183 | *mac = (uint32_t)enetc_rd(enetc_hw, ENETC_SIPMAR0); |
| 184 | high_mac = (uint32_t)*mac; |
| 185 | mac++; |
| 186 | *mac = (uint32_t)enetc_rd(enetc_hw, ENETC_SIPMAR1); |
| 187 | low_mac = (uint16_t)*mac; |
| 188 | } else { |
| 189 | *mac = (uint32_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR0(0)); |
| 190 | high_mac = (uint32_t)*mac; |
| 191 | mac++; |
| 192 | *mac = (uint16_t)enetc_port_rd(enetc_hw, ENETC_PSIPMAR1(0)); |
| 193 | low_mac = (uint16_t)*mac; |
| 194 | } |
| 195 | |
| 196 | if ((high_mac | low_mac) == 0) { |
| 197 | char *first_byte; |
| 198 | |
| 199 | ENETC_PMD_NOTICE("MAC is not available for this SI, " |
| 200 | "set random MAC"); |
| 201 | mac = (uint32_t *)hw->mac.addr; |
| 202 | *mac = (uint32_t)rte_rand(); |
| 203 | first_byte = (char *)mac; |
| 204 | *first_byte &= 0xfe; /* clear multicast bit */ |
| 205 | *first_byte |= 0x02; /* set local assignment bit (IEEE802) */ |
| 206 | |
| 207 | enetc_port_wr(enetc_hw, ENETC_PSIPMAR0(0), *mac); |
| 208 | mac++; |
| 209 | *mac = (uint16_t)rte_rand(); |
| 210 | enetc_port_wr(enetc_hw, ENETC_PSIPMAR1(0), *mac); |
| 211 | print_ethaddr("New address: ", |
| 212 | (const struct rte_ether_addr *)hw->mac.addr); |
| 213 | } |
no test coverage detected