MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ixgbe_insert_mac_addr_generic

Function ixgbe_insert_mac_addr_generic

dpdk/drivers/net/ixgbe/base/ixgbe_common.c:3683–3741  ·  view source on GitHub ↗

* ixgbe_insert_mac_addr_generic - Find a RAR for this mac address * @hw: pointer to hardware structure * @addr: Address to put into receive address register * @vmdq: VMDq pool to assign * * Puts an ethernet address into a receive address register, or * finds the rar that it is already in; adds to the pool list **/

Source from the content-addressed store, hash-verified

3681 * finds the rar that it is already in; adds to the pool list
3682 **/
3683s32 ixgbe_insert_mac_addr_generic(struct ixgbe_hw *hw, u8 *addr, u32 vmdq)
3684{
3685 static const u32 NO_EMPTY_RAR_FOUND = 0xFFFFFFFF;
3686 u32 first_empty_rar = NO_EMPTY_RAR_FOUND;
3687 u32 rar;
3688 u32 rar_low, rar_high;
3689 u32 addr_low, addr_high;
3690
3691 DEBUGFUNC("ixgbe_insert_mac_addr_generic");
3692
3693 /* swap bytes for HW little endian */
3694 addr_low = addr[0] | (addr[1] << 8)
3695 | (addr[2] << 16)
3696 | (addr[3] << 24);
3697 addr_high = addr[4] | (addr[5] << 8);
3698
3699 /*
3700 * Either find the mac_id in rar or find the first empty space.
3701 * rar_highwater points to just after the highest currently used
3702 * rar in order to shorten the search. It grows when we add a new
3703 * rar to the top.
3704 */
3705 for (rar = 0; rar < hw->mac.rar_highwater; rar++) {
3706 rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
3707
3708 if (((IXGBE_RAH_AV & rar_high) == 0)
3709 && first_empty_rar == NO_EMPTY_RAR_FOUND) {
3710 first_empty_rar = rar;
3711 } else if ((rar_high & 0xFFFF) == addr_high) {
3712 rar_low = IXGBE_READ_REG(hw, IXGBE_RAL(rar));
3713 if (rar_low == addr_low)
3714 break; /* found it already in the rars */
3715 }
3716 }
3717
3718 if (rar < hw->mac.rar_highwater) {
3719 /* already there so just add to the pool bits */
3720 ixgbe_set_vmdq(hw, rar, vmdq);
3721 } else if (first_empty_rar != NO_EMPTY_RAR_FOUND) {
3722 /* stick it into first empty RAR slot we found */
3723 rar = first_empty_rar;
3724 ixgbe_set_rar(hw, rar, addr, vmdq, IXGBE_RAH_AV);
3725 } else if (rar == hw->mac.rar_highwater) {
3726 /* add it to the top of the list and inc the highwater mark */
3727 ixgbe_set_rar(hw, rar, addr, vmdq, IXGBE_RAH_AV);
3728 hw->mac.rar_highwater++;
3729 } else if (rar >= hw->mac.num_rar_entries) {
3730 return IXGBE_ERR_INVALID_MAC_ADDR;
3731 }
3732
3733 /*
3734 * If we found rar[0], make sure the default pool bit (we use pool 0)
3735 * remains cleared to be sure default pool packets will get delivered
3736 */
3737 if (rar == 0)
3738 ixgbe_clear_vmdq(hw, rar, 0);
3739
3740 return rar;

Callers

nothing calls this directly

Calls 3

ixgbe_set_vmdqFunction · 0.85
ixgbe_set_rarFunction · 0.85
ixgbe_clear_vmdqFunction · 0.85

Tested by

no test coverage detected