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