kni: fix style
[dpdk.git] / kernel / linux / kni / kni_net.c
index be9e6b0..320d51d 100644 (file)
@@ -291,15 +291,15 @@ kni_net_tx(struct sk_buff *skb, struct net_device *dev)
 
        /* Free skb and update statistics */
        dev_kfree_skb(skb);
-       kni->stats.tx_bytes += len;
-       kni->stats.tx_packets++;
+       dev->stats.tx_bytes += len;
+       dev->stats.tx_packets++;
 
        return NETDEV_TX_OK;
 
 drop:
        /* Free skb and update statistics */
        dev_kfree_skb(skb);
-       kni->stats.tx_dropped++;
+       dev->stats.tx_dropped++;
 
        return NETDEV_TX_OK;
 }
@@ -340,16 +340,13 @@ kni_net_rx_normal(struct kni_dev *kni)
                data_kva = kva2data_kva(kva);
                kni->va[i] = pa2va(kni->pa[i], kva);
 
-               skb = dev_alloc_skb(len + 2);
+               skb = netdev_alloc_skb(dev, len);
                if (!skb) {
                        /* Update statistics */
-                       kni->stats.rx_dropped++;
+                       dev->stats.rx_dropped++;
                        continue;
                }
 
-               /* Align IP on 16B boundary */
-               skb_reserve(skb, 2);
-
                if (kva->nb_segs == 1) {
                        memcpy(skb_put(skb, len), data_kva, len);
                } else {
@@ -368,7 +365,6 @@ kni_net_rx_normal(struct kni_dev *kni)
                        }
                }
 
-               skb->dev = dev;
                skb->protocol = eth_type_trans(skb, dev);
                skb->ip_summed = CHECKSUM_UNNECESSARY;
 
@@ -376,8 +372,8 @@ kni_net_rx_normal(struct kni_dev *kni)
                netif_rx_ni(skb);
 
                /* Update statistics */
-               kni->stats.rx_bytes += len;
-               kni->stats.rx_packets++;
+               dev->stats.rx_bytes += len;
+               dev->stats.rx_packets++;
        }
 
        /* Burst enqueue mbufs into free_q */
@@ -400,11 +396,12 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
        void *data_kva;
        struct rte_kni_mbuf *alloc_kva;
        void *alloc_data_kva;
+       struct net_device *dev = kni->net_dev;
 
        /* Get the number of entries in rx_q */
        num_rq = kni_fifo_count(kni->rx_q);
 
-       /* Get the number of free entrie in tx_q */
+       /* Get the number of free entries in tx_q */
        num_tq = kni_fifo_free_count(kni->tx_q);
 
        /* Get the number of entries in alloc_q */
@@ -447,8 +444,8 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
                        alloc_kva->pkt_len = len;
                        alloc_kva->data_len = len;
 
-                       kni->stats.tx_bytes += len;
-                       kni->stats.rx_bytes += len;
+                       dev->stats.tx_bytes += len;
+                       dev->stats.rx_bytes += len;
                }
 
                /* Burst enqueue mbufs into tx_q */
@@ -468,8 +465,8 @@ kni_net_rx_lo_fifo(struct kni_dev *kni)
         * Update statistic, and enqueue/dequeue failure is impossible,
         * as all queues are checked at first.
         */
-       kni->stats.tx_packets += num;
-       kni->stats.rx_packets += num;
+       dev->stats.tx_packets += num;
+       dev->stats.rx_packets += num;
 }
 
 /*
@@ -512,26 +509,20 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
                data_kva = kva2data_kva(kva);
                kni->va[i] = pa2va(kni->pa[i], kva);
 
-               skb = dev_alloc_skb(len + 2);
+               skb = netdev_alloc_skb(dev, len);
                if (skb) {
-                       /* Align IP on 16B boundary */
-                       skb_reserve(skb, 2);
                        memcpy(skb_put(skb, len), data_kva, len);
-                       skb->dev = dev;
                        skb->ip_summed = CHECKSUM_UNNECESSARY;
                        dev_kfree_skb(skb);
                }
 
                /* Simulate real usage, allocate/copy skb twice */
-               skb = dev_alloc_skb(len + 2);
+               skb = netdev_alloc_skb(dev, len);
                if (skb == NULL) {
-                       kni->stats.rx_dropped++;
+                       dev->stats.rx_dropped++;
                        continue;
                }
 
-               /* Align IP on 16B boundary */
-               skb_reserve(skb, 2);
-
                if (kva->nb_segs == 1) {
                        memcpy(skb_put(skb, len), data_kva, len);
                } else {
@@ -550,11 +541,10 @@ kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
                        }
                }
 
-               skb->dev = dev;
                skb->ip_summed = CHECKSUM_UNNECESSARY;
 
-               kni->stats.rx_bytes += len;
-               kni->stats.rx_packets++;
+               dev->stats.rx_bytes += len;
+               dev->stats.rx_packets++;
 
                /* call tx interface */
                kni_net_tx(skb, dev);
@@ -584,32 +574,13 @@ kni_net_rx(struct kni_dev *kni)
 static void
 kni_net_tx_timeout(struct net_device *dev)
 {
-       struct kni_dev *kni = netdev_priv(dev);
-
        pr_debug("Transmit timeout at %ld, latency %ld\n", jiffies,
                        jiffies - dev_trans_start(dev));
 
-       kni->stats.tx_errors++;
+       dev->stats.tx_errors++;
        netif_wake_queue(dev);
 }
 
-/*
- * Ioctl commands
- */
-static int
-kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
-{
-       pr_debug("kni_net_ioctl group:%d cmd:%d\n",
-               ((struct kni_dev *)netdev_priv(dev))->group_id, cmd);
-
-       return -EOPNOTSUPP;
-}
-
-static void
-kni_net_set_rx_mode(struct net_device *dev)
-{
-}
-
 static int
 kni_net_change_mtu(struct net_device *dev, int new_mtu)
 {
@@ -655,17 +626,6 @@ kni_net_poll_resp(struct kni_dev *kni)
                wake_up_interruptible(&kni->wq);
 }
 
-/*
- * Return statistics to the caller
- */
-static struct net_device_stats *
-kni_net_stats(struct net_device *dev)
-{
-       struct kni_dev *kni = netdev_priv(dev);
-
-       return &kni->stats;
-}
-
 /*
  *  Fill the eth header
  */
@@ -744,6 +704,7 @@ kni_net_change_carrier(struct net_device *dev, bool new_carrier)
 
 static const struct header_ops kni_net_header_ops = {
        .create  = kni_net_header,
+       .parse   = eth_header_parse,
 #ifdef HAVE_REBUILD_HEADER
        .rebuild = kni_net_rebuild_header,
 #endif /* < 4.1.0  */
@@ -757,9 +718,6 @@ static const struct net_device_ops kni_net_netdev_ops = {
        .ndo_change_rx_flags = kni_net_set_promiscusity,
        .ndo_start_xmit = kni_net_tx,
        .ndo_change_mtu = kni_net_change_mtu,
-       .ndo_do_ioctl = kni_net_ioctl,
-       .ndo_set_rx_mode = kni_net_set_rx_mode,
-       .ndo_get_stats = kni_net_stats,
        .ndo_tx_timeout = kni_net_tx_timeout,
        .ndo_set_mac_address = kni_net_set_mac,
 #ifdef HAVE_CHANGE_CARRIER_CB
@@ -797,6 +755,7 @@ kni_net_config_lo_mode(char *lo_str)
        } else if (!strcmp(lo_str, "lo_mode_fifo_skb")) {
                pr_debug("loopback mode=lo_mode_fifo_skb enabled");
                kni_net_rx_func = kni_net_rx_lo_fifo_skb;
-       } else
-               pr_debug("Incognizant parameter, loopback disabled");
+       } else {
+               pr_debug("Unknown loopback parameter, disabled");
+       }
 }