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 /** 33 * A structure describing the private information for a kni device. 34 */ 35 struct kni_dev { 36 /* kni list */ 37 struct list_head list; 38 39 struct net_device_stats stats; 40 int status; 41 uint16_t group_id; /* Group ID of a group of KNI devices */ 42 uint32_t core_id; /* Core ID to bind */ 43 char name[RTE_KNI_NAMESIZE]; /* Network device name */ 44 struct task_struct *pthread; 45 46 /* wait queue for req/resp */ 47 wait_queue_head_t wq; 48 struct mutex sync_lock; 49 50 /* PCI device id */ 51 uint16_t device_id; 52 53 /* kni device */ 54 struct net_device *net_dev; 55 struct net_device *lad_dev; 56 struct pci_dev *pci_dev; 57 58 /* queue for packets to be sent out */ 59 void *tx_q; 60 61 /* queue for the packets received */ 62 void *rx_q; 63 64 /* queue for the allocated mbufs those can be used to save sk buffs */ 65 void *alloc_q; 66 67 /* free queue for the mbufs to be freed */ 68 void *free_q; 69 70 /* request queue */ 71 void *req_q; 72 73 /* response queue */ 74 void *resp_q; 75 76 void *sync_kva; 77 void *sync_va; 78 79 void *mbuf_kva; 80 void *mbuf_va; 81 82 /* mbuf size */ 83 uint32_t mbuf_size; 84 85 /* synchro for request processing */ 86 unsigned long synchro; 87 88 /* buffers */ 89 void *pa[MBUF_BURST_SZ]; 90 void *va[MBUF_BURST_SZ]; 91 void *alloc_pa[MBUF_BURST_SZ]; 92 void *alloc_va[MBUF_BURST_SZ]; 93 }; 94 95 void kni_net_release_fifo_phy(struct kni_dev *kni); 96 void kni_net_rx(struct kni_dev *kni); 97 void kni_net_init(struct net_device *dev); 98 void kni_net_config_lo_mode(char *lo_str); 99 void kni_net_poll_resp(struct kni_dev *kni); 100 void kni_set_ethtool_ops(struct net_device *netdev); 101 102 int ixgbe_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev); 103 void ixgbe_kni_remove(struct pci_dev *pdev); 104 int igb_kni_probe(struct pci_dev *pdev, struct net_device **lad_dev); 105 void igb_kni_remove(struct pci_dev *pdev); 106 107 #endif 108