db9f4898910a0ec21eab427c073c1b670350d687
[deb_dpdk.git] / lib / librte_eal / linuxapp / kni / kni_net.c
1 /*-
2  * GPL LICENSE SUMMARY
3  *
4  *   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of version 2 of the GNU General Public License as
8  *   published by the Free Software Foundation.
9  *
10  *   This program is distributed in the hope that it will be useful, but
11  *   WITHOUT ANY WARRANTY; without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  *   General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program; if not, write to the Free Software
17  *   Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18  *   The full GNU General Public License is included in this distribution
19  *   in the file called LICENSE.GPL.
20  *
21  *   Contact Information:
22  *   Intel Corporation
23  */
24
25 /*
26  * This code is inspired from the book "Linux Device Drivers" by
27  * Alessandro Rubini and Jonathan Corbet, published by O'Reilly & Associates
28  */
29
30 #include <linux/device.h>
31 #include <linux/module.h>
32 #include <linux/version.h>
33 #include <linux/netdevice.h>
34 #include <linux/etherdevice.h> /* eth_type_trans */
35 #include <linux/skbuff.h>
36 #include <linux/kthread.h>
37 #include <linux/delay.h>
38
39 #include <exec-env/rte_kni_common.h>
40 #include <kni_fifo.h>
41
42 #include "compat.h"
43 #include "kni_dev.h"
44
45 #define WD_TIMEOUT 5 /*jiffies */
46
47 #define KNI_WAIT_RESPONSE_TIMEOUT 300 /* 3 seconds */
48
49 /* typedef for rx function */
50 typedef void (*kni_net_rx_t)(struct kni_dev *kni);
51
52 static void kni_net_rx_normal(struct kni_dev *kni);
53
54 /* kni rx function pointer, with default to normal rx */
55 static kni_net_rx_t kni_net_rx_func = kni_net_rx_normal;
56
57 /* physical address to kernel virtual address */
58 static void *
59 pa2kva(void *pa)
60 {
61         return phys_to_virt((unsigned long)pa);
62 }
63
64 /* physical address to virtual address */
65 static void *
66 pa2va(void *pa, struct rte_kni_mbuf *m)
67 {
68         void *va;
69
70         va = (void *)((unsigned long)pa +
71                         (unsigned long)m->buf_addr -
72                         (unsigned long)m->buf_physaddr);
73         return va;
74 }
75
76 /* mbuf data kernel virtual address from mbuf kernel virtual address */
77 static void *
78 kva2data_kva(struct rte_kni_mbuf *m)
79 {
80         return phys_to_virt(m->buf_physaddr + m->data_off);
81 }
82
83 /* virtual address to physical address */
84 static void *
85 va2pa(void *va, struct rte_kni_mbuf *m)
86 {
87         void *pa;
88
89         pa = (void *)((unsigned long)va -
90                         ((unsigned long)m->buf_addr -
91                          (unsigned long)m->buf_physaddr));
92         return pa;
93 }
94
95 /*
96  * It can be called to process the request.
97  */
98 static int
99 kni_net_process_request(struct kni_dev *kni, struct rte_kni_request *req)
100 {
101         int ret = -1;
102         void *resp_va;
103         uint32_t num;
104         int ret_val;
105
106         if (!kni || !req) {
107                 pr_err("No kni instance or request\n");
108                 return -EINVAL;
109         }
110
111         mutex_lock(&kni->sync_lock);
112
113         /* Construct data */
114         memcpy(kni->sync_kva, req, sizeof(struct rte_kni_request));
115         num = kni_fifo_put(kni->req_q, &kni->sync_va, 1);
116         if (num < 1) {
117                 pr_err("Cannot send to req_q\n");
118                 ret = -EBUSY;
119                 goto fail;
120         }
121
122         ret_val = wait_event_interruptible_timeout(kni->wq,
123                         kni_fifo_count(kni->resp_q), 3 * HZ);
124         if (signal_pending(current) || ret_val <= 0) {
125                 ret = -ETIME;
126                 goto fail;
127         }
128         num = kni_fifo_get(kni->resp_q, (void **)&resp_va, 1);
129         if (num != 1 || resp_va != kni->sync_va) {
130                 /* This should never happen */
131                 pr_err("No data in resp_q\n");
132                 ret = -ENODATA;
133                 goto fail;
134         }
135
136         memcpy(req, kni->sync_kva, sizeof(struct rte_kni_request));
137         ret = 0;
138
139 fail:
140         mutex_unlock(&kni->sync_lock);
141         return ret;
142 }
143
144 /*
145  * Open and close
146  */
147 static int
148 kni_net_open(struct net_device *dev)
149 {
150         int ret;
151         struct rte_kni_request req;
152         struct kni_dev *kni = netdev_priv(dev);
153
154         netif_start_queue(dev);
155
156         memset(&req, 0, sizeof(req));
157         req.req_id = RTE_KNI_REQ_CFG_NETWORK_IF;
158
159         /* Setting if_up to non-zero means up */
160         req.if_up = 1;
161         ret = kni_net_process_request(kni, &req);
162
163         return (ret == 0) ? req.result : ret;
164 }
165
166 static int
167 kni_net_release(struct net_device *dev)
168 {
169         int ret;
170         struct rte_kni_request req;
171         struct kni_dev *kni = netdev_priv(dev);
172
173         netif_stop_queue(dev); /* can't transmit any more */
174
175         memset(&req, 0, sizeof(req));
176         req.req_id = RTE_KNI_REQ_CFG_NETWORK_IF;
177
178         /* Setting if_up to 0 means down */
179         req.if_up = 0;
180         ret = kni_net_process_request(kni, &req);
181
182         return (ret == 0) ? req.result : ret;
183 }
184
185 /*
186  * Configuration changes (passed on by ifconfig)
187  */
188 static int
189 kni_net_config(struct net_device *dev, struct ifmap *map)
190 {
191         if (dev->flags & IFF_UP) /* can't act on a running interface */
192                 return -EBUSY;
193
194         /* ignore other fields */
195         return 0;
196 }
197
198 /*
199  * Transmit a packet (called by the kernel)
200  */
201 static int
202 kni_net_tx(struct sk_buff *skb, struct net_device *dev)
203 {
204         int len = 0;
205         uint32_t ret;
206         struct kni_dev *kni = netdev_priv(dev);
207         struct rte_kni_mbuf *pkt_kva = NULL;
208         void *pkt_pa = NULL;
209         void *pkt_va = NULL;
210
211         /* save the timestamp */
212 #ifdef HAVE_TRANS_START_HELPER
213         netif_trans_update(dev);
214 #else
215         dev->trans_start = jiffies;
216 #endif
217
218         /* Check if the length of skb is less than mbuf size */
219         if (skb->len > kni->mbuf_size)
220                 goto drop;
221
222         /**
223          * Check if it has at least one free entry in tx_q and
224          * one entry in alloc_q.
225          */
226         if (kni_fifo_free_count(kni->tx_q) == 0 ||
227                         kni_fifo_count(kni->alloc_q) == 0) {
228                 /**
229                  * If no free entry in tx_q or no entry in alloc_q,
230                  * drops skb and goes out.
231                  */
232                 goto drop;
233         }
234
235         /* dequeue a mbuf from alloc_q */
236         ret = kni_fifo_get(kni->alloc_q, &pkt_pa, 1);
237         if (likely(ret == 1)) {
238                 void *data_kva;
239
240                 pkt_kva = pa2kva(pkt_pa);
241                 data_kva = kva2data_kva(pkt_kva);
242                 pkt_va = pa2va(pkt_pa, pkt_kva);
243
244                 len = skb->len;
245                 memcpy(data_kva, skb->data, len);
246                 if (unlikely(len < ETH_ZLEN)) {
247                         memset(data_kva + len, 0, ETH_ZLEN - len);
248                         len = ETH_ZLEN;
249                 }
250                 pkt_kva->pkt_len = len;
251                 pkt_kva->data_len = len;
252
253                 /* enqueue mbuf into tx_q */
254                 ret = kni_fifo_put(kni->tx_q, &pkt_va, 1);
255                 if (unlikely(ret != 1)) {
256                         /* Failing should not happen */
257                         pr_err("Fail to enqueue mbuf into tx_q\n");
258                         goto drop;
259                 }
260         } else {
261                 /* Failing should not happen */
262                 pr_err("Fail to dequeue mbuf from alloc_q\n");
263                 goto drop;
264         }
265
266         /* Free skb and update statistics */
267         dev_kfree_skb(skb);
268         kni->stats.tx_bytes += len;
269         kni->stats.tx_packets++;
270
271         return NETDEV_TX_OK;
272
273 drop:
274         /* Free skb and update statistics */
275         dev_kfree_skb(skb);
276         kni->stats.tx_dropped++;
277
278         return NETDEV_TX_OK;
279 }
280
281 /*
282  * RX: normal working mode
283  */
284 static void
285 kni_net_rx_normal(struct kni_dev *kni)
286 {
287         uint32_t ret;
288         uint32_t len;
289         uint32_t i, num_rx, num_fq;
290         struct rte_kni_mbuf *kva;
291         void *data_kva;
292         struct sk_buff *skb;
293         struct net_device *dev = kni->net_dev;
294
295         /* Get the number of free entries in free_q */
296         num_fq = kni_fifo_free_count(kni->free_q);
297         if (num_fq == 0) {
298                 /* No room on the free_q, bail out */
299                 return;
300         }
301
302         /* Calculate the number of entries to dequeue from rx_q */
303         num_rx = min_t(uint32_t, num_fq, MBUF_BURST_SZ);
304
305         /* Burst dequeue from rx_q */
306         num_rx = kni_fifo_get(kni->rx_q, kni->pa, num_rx);
307         if (num_rx == 0)
308                 return;
309
310         /* Transfer received packets to netif */
311         for (i = 0; i < num_rx; i++) {
312                 kva = pa2kva(kni->pa[i]);
313                 len = kva->pkt_len;
314                 data_kva = kva2data_kva(kva);
315                 kni->va[i] = pa2va(kni->pa[i], kva);
316
317                 skb = dev_alloc_skb(len + 2);
318                 if (!skb) {
319                         /* Update statistics */
320                         kni->stats.rx_dropped++;
321                         continue;
322                 }
323
324                 /* Align IP on 16B boundary */
325                 skb_reserve(skb, 2);
326
327                 if (kva->nb_segs == 1) {
328                         memcpy(skb_put(skb, len), data_kva, len);
329                 } else {
330                         int nb_segs;
331                         int kva_nb_segs = kva->nb_segs;
332
333                         for (nb_segs = 0; nb_segs < kva_nb_segs; nb_segs++) {
334                                 memcpy(skb_put(skb, kva->data_len),
335                                         data_kva, kva->data_len);
336
337                                 if (!kva->next)
338                                         break;
339
340                                 kva = pa2kva(va2pa(kva->next, kva));
341                                 data_kva = kva2data_kva(kva);
342                         }
343                 }
344
345                 skb->dev = dev;
346                 skb->protocol = eth_type_trans(skb, dev);
347                 skb->ip_summed = CHECKSUM_UNNECESSARY;
348
349                 /* Call netif interface */
350                 netif_rx_ni(skb);
351
352                 /* Update statistics */
353                 kni->stats.rx_bytes += len;
354                 kni->stats.rx_packets++;
355         }
356
357         /* Burst enqueue mbufs into free_q */
358         ret = kni_fifo_put(kni->free_q, kni->va, num_rx);
359         if (ret != num_rx)
360                 /* Failing should not happen */
361                 pr_err("Fail to enqueue entries into free_q\n");
362 }
363
364 /*
365  * RX: loopback with enqueue/dequeue fifos.
366  */
367 static void
368 kni_net_rx_lo_fifo(struct kni_dev *kni)
369 {
370         uint32_t ret;
371         uint32_t len;
372         uint32_t i, num, num_rq, num_tq, num_aq, num_fq;
373         struct rte_kni_mbuf *kva;
374         void *data_kva;
375         struct rte_kni_mbuf *alloc_kva;
376         void *alloc_data_kva;
377
378         /* Get the number of entries in rx_q */
379         num_rq = kni_fifo_count(kni->rx_q);
380
381         /* Get the number of free entrie in tx_q */
382         num_tq = kni_fifo_free_count(kni->tx_q);
383
384         /* Get the number of entries in alloc_q */
385         num_aq = kni_fifo_count(kni->alloc_q);
386
387         /* Get the number of free entries in free_q */
388         num_fq = kni_fifo_free_count(kni->free_q);
389
390         /* Calculate the number of entries to be dequeued from rx_q */
391         num = min(num_rq, num_tq);
392         num = min(num, num_aq);
393         num = min(num, num_fq);
394         num = min_t(uint32_t, num, MBUF_BURST_SZ);
395
396         /* Return if no entry to dequeue from rx_q */
397         if (num == 0)
398                 return;
399
400         /* Burst dequeue from rx_q */
401         ret = kni_fifo_get(kni->rx_q, kni->pa, num);
402         if (ret == 0)
403                 return; /* Failing should not happen */
404
405         /* Dequeue entries from alloc_q */
406         ret = kni_fifo_get(kni->alloc_q, kni->alloc_pa, num);
407         if (ret) {
408                 num = ret;
409                 /* Copy mbufs */
410                 for (i = 0; i < num; i++) {
411                         kva = pa2kva(kni->pa[i]);
412                         len = kva->pkt_len;
413                         data_kva = kva2data_kva(kva);
414                         kni->va[i] = pa2va(kni->pa[i], kva);
415
416                         alloc_kva = pa2kva(kni->alloc_pa[i]);
417                         alloc_data_kva = kva2data_kva(alloc_kva);
418                         kni->alloc_va[i] = pa2va(kni->alloc_pa[i], alloc_kva);
419
420                         memcpy(alloc_data_kva, data_kva, len);
421                         alloc_kva->pkt_len = len;
422                         alloc_kva->data_len = len;
423
424                         kni->stats.tx_bytes += len;
425                         kni->stats.rx_bytes += len;
426                 }
427
428                 /* Burst enqueue mbufs into tx_q */
429                 ret = kni_fifo_put(kni->tx_q, kni->alloc_va, num);
430                 if (ret != num)
431                         /* Failing should not happen */
432                         pr_err("Fail to enqueue mbufs into tx_q\n");
433         }
434
435         /* Burst enqueue mbufs into free_q */
436         ret = kni_fifo_put(kni->free_q, kni->va, num);
437         if (ret != num)
438                 /* Failing should not happen */
439                 pr_err("Fail to enqueue mbufs into free_q\n");
440
441         /**
442          * Update statistic, and enqueue/dequeue failure is impossible,
443          * as all queues are checked at first.
444          */
445         kni->stats.tx_packets += num;
446         kni->stats.rx_packets += num;
447 }
448
449 /*
450  * RX: loopback with enqueue/dequeue fifos and sk buffer copies.
451  */
452 static void
453 kni_net_rx_lo_fifo_skb(struct kni_dev *kni)
454 {
455         uint32_t ret;
456         uint32_t len;
457         uint32_t i, num_rq, num_fq, num;
458         struct rte_kni_mbuf *kva;
459         void *data_kva;
460         struct sk_buff *skb;
461         struct net_device *dev = kni->net_dev;
462
463         /* Get the number of entries in rx_q */
464         num_rq = kni_fifo_count(kni->rx_q);
465
466         /* Get the number of free entries in free_q */
467         num_fq = kni_fifo_free_count(kni->free_q);
468
469         /* Calculate the number of entries to dequeue from rx_q */
470         num = min(num_rq, num_fq);
471         num = min_t(uint32_t, num, MBUF_BURST_SZ);
472
473         /* Return if no entry to dequeue from rx_q */
474         if (num == 0)
475                 return;
476
477         /* Burst dequeue mbufs from rx_q */
478         ret = kni_fifo_get(kni->rx_q, kni->pa, num);
479         if (ret == 0)
480                 return;
481
482         /* Copy mbufs to sk buffer and then call tx interface */
483         for (i = 0; i < num; i++) {
484                 kva = pa2kva(kni->pa[i]);
485                 len = kva->pkt_len;
486                 data_kva = kva2data_kva(kva);
487                 kni->va[i] = pa2va(kni->pa[i], kva);
488
489                 skb = dev_alloc_skb(len + 2);
490                 if (skb) {
491                         /* Align IP on 16B boundary */
492                         skb_reserve(skb, 2);
493                         memcpy(skb_put(skb, len), data_kva, len);
494                         skb->dev = dev;
495                         skb->ip_summed = CHECKSUM_UNNECESSARY;
496                         dev_kfree_skb(skb);
497                 }
498
499                 /* Simulate real usage, allocate/copy skb twice */
500                 skb = dev_alloc_skb(len + 2);
501                 if (skb == NULL) {
502                         kni->stats.rx_dropped++;
503                         continue;
504                 }
505
506                 /* Align IP on 16B boundary */
507                 skb_reserve(skb, 2);
508
509                 if (kva->nb_segs == 1) {
510                         memcpy(skb_put(skb, len), data_kva, len);
511                 } else {
512                         int nb_segs;
513                         int kva_nb_segs = kva->nb_segs;
514
515                         for (nb_segs = 0; nb_segs < kva_nb_segs; nb_segs++) {
516                                 memcpy(skb_put(skb, kva->data_len),
517                                         data_kva, kva->data_len);
518
519                                 if (!kva->next)
520                                         break;
521
522                                 kva = pa2kva(va2pa(kva->next, kva));
523                                 data_kva = kva2data_kva(kva);
524                         }
525                 }
526
527                 skb->dev = dev;
528                 skb->ip_summed = CHECKSUM_UNNECESSARY;
529
530                 kni->stats.rx_bytes += len;
531                 kni->stats.rx_packets++;
532
533                 /* call tx interface */
534                 kni_net_tx(skb, dev);
535         }
536
537         /* enqueue all the mbufs from rx_q into free_q */
538         ret = kni_fifo_put(kni->free_q, kni->va, num);
539         if (ret != num)
540                 /* Failing should not happen */
541                 pr_err("Fail to enqueue mbufs into free_q\n");
542 }
543
544 /* rx interface */
545 void
546 kni_net_rx(struct kni_dev *kni)
547 {
548         /**
549          * It doesn't need to check if it is NULL pointer,
550          * as it has a default value
551          */
552         (*kni_net_rx_func)(kni);
553 }
554
555 /*
556  * Deal with a transmit timeout.
557  */
558 static void
559 kni_net_tx_timeout(struct net_device *dev)
560 {
561         struct kni_dev *kni = netdev_priv(dev);
562
563         pr_debug("Transmit timeout at %ld, latency %ld\n", jiffies,
564                         jiffies - dev_trans_start(dev));
565
566         kni->stats.tx_errors++;
567         netif_wake_queue(dev);
568 }
569
570 /*
571  * Ioctl commands
572  */
573 static int
574 kni_net_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
575 {
576         pr_debug("kni_net_ioctl group:%d cmd:%d\n",
577                 ((struct kni_dev *)netdev_priv(dev))->group_id, cmd);
578
579         return 0;
580 }
581
582 static void
583 kni_net_set_rx_mode(struct net_device *dev)
584 {
585 }
586
587 static int
588 kni_net_change_mtu(struct net_device *dev, int new_mtu)
589 {
590         int ret;
591         struct rte_kni_request req;
592         struct kni_dev *kni = netdev_priv(dev);
593
594         pr_debug("kni_net_change_mtu new mtu %d to be set\n", new_mtu);
595
596         memset(&req, 0, sizeof(req));
597         req.req_id = RTE_KNI_REQ_CHANGE_MTU;
598         req.new_mtu = new_mtu;
599         ret = kni_net_process_request(kni, &req);
600         if (ret == 0 && req.result == 0)
601                 dev->mtu = new_mtu;
602
603         return (ret == 0) ? req.result : ret;
604 }
605
606 /*
607  * Checks if the user space application provided the resp message
608  */
609 void
610 kni_net_poll_resp(struct kni_dev *kni)
611 {
612         if (kni_fifo_count(kni->resp_q))
613                 wake_up_interruptible(&kni->wq);
614 }
615
616 /*
617  * Return statistics to the caller
618  */
619 static struct net_device_stats *
620 kni_net_stats(struct net_device *dev)
621 {
622         struct kni_dev *kni = netdev_priv(dev);
623
624         return &kni->stats;
625 }
626
627 /*
628  *  Fill the eth header
629  */
630 static int
631 kni_net_header(struct sk_buff *skb, struct net_device *dev,
632                 unsigned short type, const void *daddr,
633                 const void *saddr, uint32_t len)
634 {
635         struct ethhdr *eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
636
637         memcpy(eth->h_source, saddr ? saddr : dev->dev_addr, dev->addr_len);
638         memcpy(eth->h_dest,   daddr ? daddr : dev->dev_addr, dev->addr_len);
639         eth->h_proto = htons(type);
640
641         return dev->hard_header_len;
642 }
643
644 /*
645  * Re-fill the eth header
646  */
647 #ifdef HAVE_REBUILD_HEADER
648 static int
649 kni_net_rebuild_header(struct sk_buff *skb)
650 {
651         struct net_device *dev = skb->dev;
652         struct ethhdr *eth = (struct ethhdr *) skb->data;
653
654         memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
655         memcpy(eth->h_dest, dev->dev_addr, dev->addr_len);
656
657         return 0;
658 }
659 #endif /* < 4.1.0  */
660
661 /**
662  * kni_net_set_mac - Change the Ethernet Address of the KNI NIC
663  * @netdev: network interface device structure
664  * @p: pointer to an address structure
665  *
666  * Returns 0 on success, negative on failure
667  **/
668 static int
669 kni_net_set_mac(struct net_device *netdev, void *p)
670 {
671         struct sockaddr *addr = p;
672
673         if (!is_valid_ether_addr((unsigned char *)(addr->sa_data)))
674                 return -EADDRNOTAVAIL;
675         memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
676         return 0;
677 }
678
679 #ifdef HAVE_CHANGE_CARRIER_CB
680 static int
681 kni_net_change_carrier(struct net_device *dev, bool new_carrier)
682 {
683         if (new_carrier)
684                 netif_carrier_on(dev);
685         else
686                 netif_carrier_off(dev);
687         return 0;
688 }
689 #endif
690
691 static const struct header_ops kni_net_header_ops = {
692         .create  = kni_net_header,
693 #ifdef HAVE_REBUILD_HEADER
694         .rebuild = kni_net_rebuild_header,
695 #endif /* < 4.1.0  */
696         .cache   = NULL,  /* disable caching */
697 };
698
699 static const struct net_device_ops kni_net_netdev_ops = {
700         .ndo_open = kni_net_open,
701         .ndo_stop = kni_net_release,
702         .ndo_set_config = kni_net_config,
703         .ndo_start_xmit = kni_net_tx,
704         .ndo_change_mtu = kni_net_change_mtu,
705         .ndo_do_ioctl = kni_net_ioctl,
706         .ndo_set_rx_mode = kni_net_set_rx_mode,
707         .ndo_get_stats = kni_net_stats,
708         .ndo_tx_timeout = kni_net_tx_timeout,
709         .ndo_set_mac_address = kni_net_set_mac,
710 #ifdef HAVE_CHANGE_CARRIER_CB
711         .ndo_change_carrier = kni_net_change_carrier,
712 #endif
713 };
714
715 void
716 kni_net_init(struct net_device *dev)
717 {
718         struct kni_dev *kni = netdev_priv(dev);
719
720         init_waitqueue_head(&kni->wq);
721         mutex_init(&kni->sync_lock);
722
723         ether_setup(dev); /* assign some of the fields */
724         dev->netdev_ops      = &kni_net_netdev_ops;
725         dev->header_ops      = &kni_net_header_ops;
726         dev->watchdog_timeo = WD_TIMEOUT;
727 }
728
729 void
730 kni_net_config_lo_mode(char *lo_str)
731 {
732         if (!lo_str) {
733                 pr_debug("loopback disabled");
734                 return;
735         }
736
737         if (!strcmp(lo_str, "lo_mode_none"))
738                 pr_debug("loopback disabled");
739         else if (!strcmp(lo_str, "lo_mode_fifo")) {
740                 pr_debug("loopback mode=lo_mode_fifo enabled");
741                 kni_net_rx_func = kni_net_rx_lo_fifo;
742         } else if (!strcmp(lo_str, "lo_mode_fifo_skb")) {
743                 pr_debug("loopback mode=lo_mode_fifo_skb enabled");
744                 kni_net_rx_func = kni_net_rx_lo_fifo_skb;
745         } else
746                 pr_debug("Incognizant parameter, loopback disabled");
747 }