On 12/02/2014 08:11 PM, Zoltan Kiss wrote:
On 01/12/14 16:15, Maxim Uvarov wrote:@@ -619,3 +620,76 @@ int odp_pktio_promisc_enabled(odp_pktio_t id) else return 0; } ++int odp_pktio_mac_addr_set(odp_pktio_t id, const unsigned char *mac_addr,+ size_t addr_size) +{ + pktio_entry_t *entry; + int sockfd; + struct ifreq ifr; + int ret; + + if (addr_size != ETH_ALEN) + return -ENOMEM;What about EUI-64 MAC addresses? Do we need/want to care about them?
I did linux-generic implementation for hw which I have. EUI-64 can be added with other patch which we should test first. Can EUI-64 be set up with the same ioctl or something else
is needed? I need to take a look at it separately. Maxim.
+ + entry = get_entry(id); + if (entry == NULL) { + ODP_DBG("pktio entry %d does not exist\n", id); + return -ENOENT; + } + + if (entry->s.pkt_sock_mmap.sockfd > -1) + sockfd = entry->s.pkt_sock_mmap.sockfd; + else + sockfd = entry->s.pkt_sock.sockfd; + + strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = 0; + memcpy(ifr.ifr_hwaddr.sa_data, mac_addr, addr_size); + ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; + + ret = ioctl(sockfd, SIOCSIFHWADDR, &ifr); + if (ret < 0) { + ODP_DBG("ioctl SIOCSIFHWADDR error\n"); + return ret; + } + + return 0; +} + +ssize_t odp_pktio_mac_addr(odp_pktio_t id, unsigned char *mac_addr, + size_t addr_size) +{ + pktio_entry_t *entry; + int sockfd; + struct ifreq ifr; + int ret; + + if (addr_size < ETH_ALEN) + return -ENOMEM; + + entry = get_entry(id); + if (entry == NULL) { + ODP_DBG("pktio entry %d does not exist\n", id); + return -ENOENT; + } + + if (entry->s.pkt_sock_mmap.sockfd > -1) + sockfd = entry->s.pkt_sock_mmap.sockfd; + else + sockfd = entry->s.pkt_sock.sockfd; + + strncpy(ifr.ifr_name, entry->s.name, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = 0; + + ret = ioctl(sockfd, SIOCGIFHWADDR, &ifr); + if (ret < 0) { + ODP_DBG("ioctl SIOCGIFHWADDR error\n"); + return ret; + } + + memcpy(mac_addr, (unsigned char *)ifr.ifr_ifru.ifru_hwaddr.sa_data, + ETH_ALEN); + + return ETH_ALEN; +}_______________________________________________ lng-odp mailing list [email protected] http://lists.linaro.org/mailman/listinfo/lng-odp
_______________________________________________ lng-odp mailing list [email protected] http://lists.linaro.org/mailman/listinfo/lng-odp
