* ngbe_set_rar - Set Rx address register * @hw: pointer to hardware structure * @index: Receive address register to write * @addr: Address to put into receive address register * @vmdq: VMDq "set" or "pool" index * @enable_addr: set flag that address is active * * Puts an ethernet address into a receive address register. **/
| 465 | * Puts an ethernet address into a receive address register. |
| 466 | **/ |
| 467 | s32 ngbe_set_rar(struct ngbe_hw *hw, u32 index, u8 *addr, u32 vmdq, |
| 468 | u32 enable_addr) |
| 469 | { |
| 470 | u32 rar_low, rar_high; |
| 471 | u32 rar_entries = hw->mac.num_rar_entries; |
| 472 | |
| 473 | /* Make sure we are using a valid rar index range */ |
| 474 | if (index >= rar_entries) { |
| 475 | DEBUGOUT("RAR index %d is out of range.", index); |
| 476 | return NGBE_ERR_INVALID_ARGUMENT; |
| 477 | } |
| 478 | |
| 479 | /* setup VMDq pool selection before this RAR gets enabled */ |
| 480 | hw->mac.set_vmdq(hw, index, vmdq); |
| 481 | |
| 482 | /* |
| 483 | * HW expects these in little endian so we reverse the byte |
| 484 | * order from network order (big endian) to little endian |
| 485 | */ |
| 486 | rar_low = NGBE_ETHADDRL_AD0(addr[5]) | |
| 487 | NGBE_ETHADDRL_AD1(addr[4]) | |
| 488 | NGBE_ETHADDRL_AD2(addr[3]) | |
| 489 | NGBE_ETHADDRL_AD3(addr[2]); |
| 490 | /* |
| 491 | * Some parts put the VMDq setting in the extra RAH bits, |
| 492 | * so save everything except the lower 16 bits that hold part |
| 493 | * of the address and the address valid bit. |
| 494 | */ |
| 495 | rar_high = rd32(hw, NGBE_ETHADDRH); |
| 496 | rar_high &= ~NGBE_ETHADDRH_AD_MASK; |
| 497 | rar_high |= (NGBE_ETHADDRH_AD4(addr[1]) | |
| 498 | NGBE_ETHADDRH_AD5(addr[0])); |
| 499 | |
| 500 | rar_high &= ~NGBE_ETHADDRH_VLD; |
| 501 | if (enable_addr != 0) |
| 502 | rar_high |= NGBE_ETHADDRH_VLD; |
| 503 | |
| 504 | wr32(hw, NGBE_ETHADDRIDX, index); |
| 505 | wr32(hw, NGBE_ETHADDRL, rar_low); |
| 506 | wr32(hw, NGBE_ETHADDRH, rar_high); |
| 507 | |
| 508 | return 0; |
| 509 | } |
| 510 | |
| 511 | /** |
| 512 | * ngbe_clear_rar - Remove Rx address register |
no test coverage detected