1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright(c) 2010-2014 Intel Corporation. 4 */ 5 6 #ifndef _KNI_DEV_H_ 7 #define _KNI_DEV_H_ 8 9 #ifdef pr_fmt 10 #undef pr_fmt 11 #endif 12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 13 14 #include "compat.h" 15 16 #include <linux/if.h> 17 #include <linux/wait.h> 18 #ifdef HAVE_SIGNAL_FUNCTIONS_OWN_HEADER 19 #include <linux/sched/signal.h> 20 #else 21 #include <linux/sched.h> 22 #endif 23 #include <linux/netdevice.h> 24 #include <linux/spinlock.h> 25 #include <linux/list.h> 26 27 #include <exec-env/rte_kni_common.h> 28 #define KNI_KTHREAD_RESCHEDULE_INTERVAL 5 /* us */ 29 30 #define MBUF_BURST_SZ 32 31 32 /* Default carrier state for created KNI network interfaces */ 33 extern uint32_t dflt_carrier; 34 35 /** 36 * A structure describing the private information for a kni device. 37 */ 38 struct kni_dev { 39 /* kni list */ 40 struct list_head list; 41 42 struct net_device_stats stats; 43 int status; 44 uint16_t group_id; /* Group ID of a group of KNI devices */ 45 uint32_t core_id; /* Core ID to bind */ 46 char name[RTE_KNI_NAMESIZE]; /* Network device name */ 47 struct task_struct *pthread; 48 49 /* wait queue for req/resp */ 50 wait_queue_head_t wq; 51 struct mutex sync_lock; 52 53 /* PCI device id */ 54 uint16_t device_id; 55 56 /* kni device */ 57 struct net_device *net_dev; 58 struct net_device *lad_dev; 59 struct pci_dev *pci_dev; 60 61 /* queue for packets to be sent out */ 62 void *tx_q; 63 64 /* queue for the packets received */ 65 void *rx_q; 66 67 /* queue for the allocated mbufs those can be used to save sk buffs */ 68 void *alloc_q; 69 70 /* free queue for the mbufs to be freed */ 71 void *free_q; 72 73 /* request queue */ 74 void *req_q; 75 76 /* response queue */ 77 void *resp_q; 78 79 void *sync_kva; 80 void *sync_va; 81 82 void *mbuf_kva; 83 void *mbuf_va; 84 85 /* mbuf size */ 86 uint32_t mbuf_size; 87 88 /* synchro for request processing */ 89 unsigned long synchro; 90 91 /* buffers */ 92 void *pa[MBUF_BURST_SZ]; 93 void *va[MBUF_BURST_SZ]; 94 void *alloc_pa[MBUF_BURST_SZ]; 95 void *alloc_va[MBUF_BURST_SZ]; 96 }; 97 98 void kni_net_release_fifo_phy(struct kni_dev *kni); 99 void kni_net_rx(struct kni_dev *kni); 100 void kni_net_init(struct net_device *dev); 101 void kni_net_config_lo_mode(char *lo_str); 102 void kni_net_poll_resp(struct kni_dev *kni); 103 void kni_set_ethtool_ops(struct net_device *netdev); 104 105 int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev); 106 void ixgbe_kni_remove(struct pci_dev *pdev); 107 int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev); 108 void igb_kni_remove(struct pci_dev *pdev); 109 110 #endif 111