emmericp / ixy

A simple yet fast user space network driver for Intel 10 Gbit/s NICs written from scratch
BSD 3-Clause "New" or "Revised" License
1.2k stars 125 forks source link

Please add function to read MAC address of NIC #29

Closed cyanide-burnout closed 3 years ago

cyanide-burnout commented 4 years ago

Please add function to read MAC address of NIC

stefansaraev commented 4 years ago
void ixgbe_get_mac_addr(struct ixy_device* ixy, uint8_t* mac_addr) {
  struct ixgbe_device* dev = IXY_TO_IXGBE(ixy);

  uint32_t rar_high = get_reg32(dev->addr, IXGBE_RAH(0));
  uint32_t rar_low = get_reg32(dev->addr, IXGBE_RAL(0));

  uint16_t i;

  for (i = 0; i < 4; i++)
    mac_addr[i] = (uint8_t)(rar_low >> (i*8));

  for (i = 0; i < 2; i++)
    mac_addr[i+4] = (uint8_t)(rar_high >> (i*8));
}

quick and dirty, works for me, but I am noob so not sure how to implement it properly in ixy :)