X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Flinuxapp%2Fkni%2Fkni_net.c;h=dd95db5b76ad69c95f1566934060a007c0fada74;hb=08b563ffb19d8baf59dd84200f25bc85031d18a7;hp=4616ac49093b5900744682012aa625d9bd3f39b7;hpb=e9d48c0072d36eb6423b45fba4ec49d0def6c36f;p=dpdk.git diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c index 4616ac4909..dd95db5b76 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -1,23 +1,23 @@ /*- * GPL LICENSE SUMMARY - * + * * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. - * + * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. * The full GNU General Public License is included in this distribution * in the file called LICENSE.GPL. - * + * * Contact Information: * Intel Corporation */ @@ -162,7 +162,8 @@ kni_net_rx_normal(struct kni_dev *kni) for (i = 0; i < num; i++) { kva = (void *)va[i] - kni->mbuf_va + kni->mbuf_kva; len = kva->data_len; - data_kva = kva->data - kni->mbuf_va + kni->mbuf_kva; + data_kva = kva->buf_addr + kva->data_off - kni->mbuf_va + + kni->mbuf_kva; skb = dev_alloc_skb(len + 2); if (!skb) { @@ -179,7 +180,7 @@ kni_net_rx_normal(struct kni_dev *kni) skb->ip_summed = CHECKSUM_UNNECESSARY; /* Call netif interface */ - netif_receive_skb(skb); + netif_rx(skb); /* Update statistics */ kni->stats.rx_bytes += len; @@ -246,13 +247,14 @@ kni_net_rx_lo_fifo(struct kni_dev *kni) for (i = 0; i < num; i++) { kva = (void *)va[i] - kni->mbuf_va + kni->mbuf_kva; len = kva->pkt_len; - data_kva = kva->data - kni->mbuf_va + - kni->mbuf_kva; + data_kva = kva->buf_addr + kva->data_off - + kni->mbuf_va + kni->mbuf_kva; alloc_kva = (void *)alloc_va[i] - kni->mbuf_va + kni->mbuf_kva; - alloc_data_kva = alloc_kva->data - kni->mbuf_va + - kni->mbuf_kva; + alloc_data_kva = alloc_kva->buf_addr + + alloc_kva->data_off - kni->mbuf_va + + kni->mbuf_kva; memcpy(alloc_data_kva, data_kva, len); alloc_kva->pkt_len = len; alloc_kva->data_len = len; @@ -321,7 +323,8 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) for (i = 0; i < num; i++) { kva = (void *)va[i] - kni->mbuf_va + kni->mbuf_kva; len = kva->data_len; - data_kva = kva->data - kni->mbuf_va + kni->mbuf_kva; + data_kva = kva->buf_addr + kva->data_off - kni->mbuf_va + + kni->mbuf_kva; skb = dev_alloc_skb(len + 2); if (skb == NULL) @@ -331,7 +334,6 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) skb_reserve(skb, 2); memcpy(skb_put(skb, len), data_kva, len); skb->dev = dev; - skb->protocol = eth_type_trans(skb, dev); skb->ip_summed = CHECKSUM_UNNECESSARY; dev_kfree_skb(skb); } @@ -347,7 +349,6 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni) skb_reserve(skb, 2); memcpy(skb_put(skb, len), data_kva, len); skb->dev = dev; - skb->protocol = eth_type_trans(skb, dev); skb->ip_summed = CHECKSUM_UNNECESSARY; kni->stats.rx_bytes += len; @@ -384,10 +385,10 @@ static int kni_net_tx(struct sk_buff *skb, struct net_device *dev) { struct kni_dev *kni = netdev_priv(dev); - + dev_kfree_skb(skb); kni->stats.tx_dropped++; - + return NETDEV_TX_OK; } #else @@ -425,7 +426,8 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev) void *data_kva; pkt_kva = (void *)pkt_va - kni->mbuf_va + kni->mbuf_kva; - data_kva = pkt_kva->data - kni->mbuf_va + kni->mbuf_kva; + data_kva = pkt_kva->buf_addr + pkt_kva->data_off - kni->mbuf_va + + kni->mbuf_kva; len = skb->len; memcpy(data_kva, skb->data, len); @@ -614,6 +616,21 @@ kni_net_rebuild_header(struct sk_buff *skb) return 0; } +/** + * kni_net_set_mac - Change the Ethernet Address of the KNI NIC + * @netdev: network interface device structure + * @p: pointer to an address structure + * + * Returns 0 on success, negative on failure + **/ +static int kni_net_set_mac(struct net_device *netdev, void *p) +{ + struct sockaddr *addr = p; + if (!is_valid_ether_addr((unsigned char *)(addr->sa_data))) + return -EADDRNOTAVAIL; + memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); + return 0; +} static const struct header_ops kni_net_header_ops = { .create = kni_net_header, @@ -630,6 +647,7 @@ static const struct net_device_ops kni_net_netdev_ops = { .ndo_do_ioctl = kni_net_ioctl, .ndo_get_stats = kni_net_stats, .ndo_tx_timeout = kni_net_tx_timeout, + .ndo_set_mac_address = kni_net_set_mac, }; void