On 12/02/2014 11:44 PM, Ola Liljedahl wrote:
On 2 December 2014 at 21:37, Maxim Uvarov <[email protected]> wrote:
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?
Yes why such a restrictive check?
Why not just "if (addr_size < ETH_ALEN)" above?
I can't see why it should be an error to provide a buffer that is
larger than absolutely necessary.
-- Ola
Application should request valid size, isn't it? I.e. 6 or 8. What is
the use to request more then can be returned?
Maxim.
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
_______________________________________________
lng-odp mailing list
[email protected]
http://lists.linaro.org/mailman/listinfo/lng-odp