Commit | Line | Data |
---|---|---|
800f879a AT |
1 | /* |
2 | * Copyright 2010-2017 Intel Corporation. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License, version 2, | |
6 | * as published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | * General Public License for more details. | |
12 | * | |
13 | * Disclaimer: The codes contained in these modules may be specific to | |
14 | * the Intel Software Development Platform codenamed Knights Ferry, | |
15 | * and the Intel product codenamed Knights Corner, and are not backward | |
16 | * compatible with other Intel products. Additionally, Intel will NOT | |
17 | * support the codes or instruction set in future products. | |
18 | * | |
19 | * Intel offers no warranty of any kind regarding the code. This code is | |
20 | * licensed on an "AS IS" basis and Intel is not obligated to provide | |
21 | * any support, assistance, installation, training, or other services | |
22 | * of any kind. Intel is also not obligated to provide any updates, | |
23 | * enhancements or extensions. Intel specifically disclaims any warranty | |
24 | * of merchantability, non-infringement, fitness for any particular | |
25 | * purpose, and any other warranty. | |
26 | * | |
27 | * Further, Intel disclaims all liability of any kind, including but | |
28 | * not limited to liability for infringement of any proprietary rights, | |
29 | * relating to the use of the code, even if Intel is notified of the | |
30 | * possibility of such liability. Except as expressly stated in an Intel | |
31 | * license agreement provided with this code and agreed upon with Intel, | |
32 | * no license, express or implied, by estoppel or otherwise, to any | |
33 | * intellectual property rights is granted herein. | |
34 | */ | |
35 | ||
36 | #ifndef MICVETH_H | |
37 | #define MICVETH_H | |
38 | ||
39 | #include "micveth_dma.h" | |
40 | ||
41 | #include "micint.h" | |
42 | #include "micveth_common.h" | |
43 | ||
44 | #define MICVETH_MAX_PACKET_SIZE (63 * 1024) | |
45 | #define MICVETH_TRANSFER_FIFO_SIZE 128 | |
46 | ||
47 | #define MICVETH_LINK_UP_MAGIC 0x1A77ABEE | |
48 | #define MICVETH_LINK_DOWN_MAGIC 0x1DEADBEE | |
49 | ||
50 | #define MICVETH_POLL_TIMER_DELAY 1 | |
51 | #define MICVETH_CLIENT_TIMER_DELAY 10 | |
52 | ||
53 | typedef struct ring_packet { | |
54 | struct sk_buff *pd_skb; | |
55 | uint64_t pd_phys; | |
56 | uint64_t pd_length; | |
57 | } ring_packet_t; | |
58 | ||
59 | typedef struct ring_desc { | |
60 | uint64_t rd_phys; | |
61 | uint64_t rd_length; | |
62 | uint32_t rd_valid; | |
63 | } ring_desc_t; | |
64 | ||
65 | typedef struct ring_queue { | |
66 | uint32_t rq_head; | |
67 | uint32_t rq_tail; | |
68 | uint32_t rq_length; | |
69 | ring_desc_t rq_descs[MICVETH_TRANSFER_FIFO_SIZE]; | |
70 | } ring_queue_t; | |
71 | ||
72 | typedef struct ring { | |
73 | ring_queue_t r_tx; | |
74 | ring_queue_t r_rx; | |
75 | } veth_ring_t; | |
76 | ||
77 | #define VETH_STATE_INITIALIZED 0 | |
78 | #define VETH_STATE_LINKUP 1 | |
79 | #define VETH_STATE_LINKDOWN 2 | |
80 | ||
81 | ||
82 | typedef struct micveth_info { | |
83 | struct pci_dev *vi_pdev; | |
84 | struct net_device *vi_netdev; | |
85 | uint8_t *vi_sbox; | |
86 | uint8_t *vi_dbox; | |
87 | uint32_t *vi_scratch14; | |
88 | uint32_t *vi_scratch15; | |
89 | mic_ctx_t *mic_ctx; | |
90 | volatile uint32_t vi_state; | |
91 | uint32_t vi_skb_mtu; | |
92 | ||
93 | struct delayed_work vi_poll; | |
94 | ||
95 | struct workqueue_struct *vi_wq; | |
96 | char vi_wqname[16]; | |
97 | struct work_struct vi_bh; | |
98 | struct work_struct vi_txws; | |
99 | ||
100 | spinlock_t vi_rxlock; | |
101 | spinlock_t vi_txlock; | |
102 | ||
103 | struct { | |
104 | veth_ring_t ring; | |
105 | uint64_t phys; | |
106 | uint64_t length; | |
107 | } vi_ring; | |
108 | ||
109 | veth_ring_t *ring_ptr; | |
110 | ||
111 | ring_packet_t vi_tx_desc[MICVETH_TRANSFER_FIFO_SIZE]; | |
112 | ring_packet_t vi_rx_desc[MICVETH_TRANSFER_FIFO_SIZE]; | |
113 | uint32_t vi_pend; | |
114 | } micveth_info_t; | |
115 | ||
116 | enum { | |
117 | CLIENT_POLL_STOPPED, | |
118 | CLIENT_POLL_RUNNING, | |
119 | CLIENT_POLL_STOPPING, | |
120 | }; | |
121 | ||
122 | typedef struct micveth { | |
123 | int lv_num_interfaces; | |
124 | int lv_num_clients; | |
125 | int lv_active_clients; | |
126 | int lv_num_links_remaining; | |
127 | micveth_info_t *lv_info; | |
128 | ||
129 | struct mutex lv_state_mutex; | |
130 | ||
131 | uint32_t lv_pollstate; | |
132 | struct delayed_work lv_poll; | |
133 | wait_queue_head_t lv_wq; | |
134 | ||
135 | } micveth_t; | |
136 | ||
137 | int micveth_init(struct device *dev); | |
138 | int micveth_init_legacy(int num_bds, struct device *dev); | |
139 | void micveth_exit(void); | |
140 | int micveth_probe(mic_ctx_t *mic_ctx); | |
141 | void micveth_remove(mic_ctx_t *mic_ctx); | |
142 | int micveth_start(mic_ctx_t *mic_ctx); | |
143 | void micveth_stop(mic_ctx_t *mic_ctx); | |
144 | ||
145 | #endif /* MICVETH_H */ |