58a932e03d0bab8477394ab5d010874a9ae2ad30
[dpdk.git] / drivers / net / liquidio / lio_ethdev.c
1 /*
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Cavium, Inc.. All rights reserved.
5  *   All rights reserved.
6  *
7  *   Redistribution and use in source and binary forms, with or without
8  *   modification, are permitted provided that the following conditions
9  *   are met:
10  *
11  *     * Redistributions of source code must retain the above copyright
12  *       notice, this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in
15  *       the documentation and/or other materials provided with the
16  *       distribution.
17  *     * Neither the name of Cavium, Inc. nor the names of its
18  *       contributors may be used to endorse or promote products derived
19  *       from this software without specific prior written permission.
20  *
21  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  *   OWNER(S) OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33
34 #include <rte_ethdev.h>
35 #include <rte_cycles.h>
36 #include <rte_malloc.h>
37 #include <rte_alarm.h>
38
39 #include "lio_logs.h"
40 #include "lio_23xx_vf.h"
41 #include "lio_ethdev.h"
42 #include "lio_rxtx.h"
43
44 /* Default RSS key in use */
45 static uint8_t lio_rss_key[40] = {
46         0x6D, 0x5A, 0x56, 0xDA, 0x25, 0x5B, 0x0E, 0xC2,
47         0x41, 0x67, 0x25, 0x3D, 0x43, 0xA3, 0x8F, 0xB0,
48         0xD0, 0xCA, 0x2B, 0xCB, 0xAE, 0x7B, 0x30, 0xB4,
49         0x77, 0xCB, 0x2D, 0xA3, 0x80, 0x30, 0xF2, 0x0C,
50         0x6A, 0x42, 0xB7, 0x3B, 0xBE, 0xAC, 0x01, 0xFA,
51 };
52
53 /* Wait for control command to reach nic. */
54 static uint16_t
55 lio_wait_for_ctrl_cmd(struct lio_device *lio_dev,
56                       struct lio_dev_ctrl_cmd *ctrl_cmd)
57 {
58         uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
59
60         while ((ctrl_cmd->cond == 0) && --timeout) {
61                 lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
62                 rte_delay_ms(1);
63         }
64
65         return !timeout;
66 }
67
68 /**
69  * \brief Send Rx control command
70  * @param eth_dev Pointer to the structure rte_eth_dev
71  * @param start_stop whether to start or stop
72  */
73 static int
74 lio_send_rx_ctrl_cmd(struct rte_eth_dev *eth_dev, int start_stop)
75 {
76         struct lio_device *lio_dev = LIO_DEV(eth_dev);
77         struct lio_dev_ctrl_cmd ctrl_cmd;
78         struct lio_ctrl_pkt ctrl_pkt;
79
80         /* flush added to prevent cmd failure
81          * incase the queue is full
82          */
83         lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
84
85         memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
86         memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
87
88         ctrl_cmd.eth_dev = eth_dev;
89         ctrl_cmd.cond = 0;
90
91         ctrl_pkt.ncmd.s.cmd = LIO_CMD_RX_CTL;
92         ctrl_pkt.ncmd.s.param1 = start_stop;
93         ctrl_pkt.ctrl_cmd = &ctrl_cmd;
94
95         if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
96                 lio_dev_err(lio_dev, "Failed to send RX Control message\n");
97                 return -1;
98         }
99
100         if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
101                 lio_dev_err(lio_dev, "RX Control command timed out\n");
102                 return -1;
103         }
104
105         return 0;
106 }
107
108 static int
109 lio_dev_rss_reta_update(struct rte_eth_dev *eth_dev,
110                         struct rte_eth_rss_reta_entry64 *reta_conf,
111                         uint16_t reta_size)
112 {
113         struct lio_device *lio_dev = LIO_DEV(eth_dev);
114         struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
115         struct lio_rss_set *rss_param;
116         struct lio_dev_ctrl_cmd ctrl_cmd;
117         struct lio_ctrl_pkt ctrl_pkt;
118         int i, j, index;
119
120         if (!lio_dev->intf_open) {
121                 lio_dev_err(lio_dev, "Port %d down, can't update reta\n",
122                             lio_dev->port_id);
123                 return -EINVAL;
124         }
125
126         if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
127                 lio_dev_err(lio_dev,
128                             "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
129                             reta_size, LIO_RSS_MAX_TABLE_SZ);
130                 return -EINVAL;
131         }
132
133         /* flush added to prevent cmd failure
134          * incase the queue is full
135          */
136         lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
137
138         memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
139         memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
140
141         rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
142
143         ctrl_cmd.eth_dev = eth_dev;
144         ctrl_cmd.cond = 0;
145
146         ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
147         ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
148         ctrl_pkt.ctrl_cmd = &ctrl_cmd;
149
150         rss_param->param.flags = 0xF;
151         rss_param->param.flags &= ~LIO_RSS_PARAM_ITABLE_UNCHANGED;
152         rss_param->param.itablesize = LIO_RSS_MAX_TABLE_SZ;
153
154         for (i = 0; i < (reta_size / RTE_RETA_GROUP_SIZE); i++) {
155                 for (j = 0; j < RTE_RETA_GROUP_SIZE; j++) {
156                         if ((reta_conf[i].mask) & ((uint64_t)1 << j)) {
157                                 index = (i * RTE_RETA_GROUP_SIZE) + j;
158                                 rss_state->itable[index] = reta_conf[i].reta[j];
159                         }
160                 }
161         }
162
163         rss_state->itable_size = LIO_RSS_MAX_TABLE_SZ;
164         memcpy(rss_param->itable, rss_state->itable, rss_state->itable_size);
165
166         lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
167
168         if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
169                 lio_dev_err(lio_dev, "Failed to set rss hash\n");
170                 return -1;
171         }
172
173         if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
174                 lio_dev_err(lio_dev, "Set rss hash timed out\n");
175                 return -1;
176         }
177
178         return 0;
179 }
180
181 static int
182 lio_dev_rss_reta_query(struct rte_eth_dev *eth_dev,
183                        struct rte_eth_rss_reta_entry64 *reta_conf,
184                        uint16_t reta_size)
185 {
186         struct lio_device *lio_dev = LIO_DEV(eth_dev);
187         struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
188         int i, num;
189
190         if (reta_size != LIO_RSS_MAX_TABLE_SZ) {
191                 lio_dev_err(lio_dev,
192                             "The size of hash lookup table configured (%d) doesn't match the number hardware can supported (%d)\n",
193                             reta_size, LIO_RSS_MAX_TABLE_SZ);
194                 return -EINVAL;
195         }
196
197         num = reta_size / RTE_RETA_GROUP_SIZE;
198
199         for (i = 0; i < num; i++) {
200                 memcpy(reta_conf->reta,
201                        &rss_state->itable[i * RTE_RETA_GROUP_SIZE],
202                        RTE_RETA_GROUP_SIZE);
203                 reta_conf++;
204         }
205
206         return 0;
207 }
208
209 static int
210 lio_dev_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
211                           struct rte_eth_rss_conf *rss_conf)
212 {
213         struct lio_device *lio_dev = LIO_DEV(eth_dev);
214         struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
215         uint8_t *hash_key = NULL;
216         uint64_t rss_hf = 0;
217
218         if (rss_state->hash_disable) {
219                 lio_dev_info(lio_dev, "RSS disabled in nic\n");
220                 rss_conf->rss_hf = 0;
221                 return 0;
222         }
223
224         /* Get key value */
225         hash_key = rss_conf->rss_key;
226         if (hash_key != NULL)
227                 memcpy(hash_key, rss_state->hash_key, rss_state->hash_key_size);
228
229         if (rss_state->ip)
230                 rss_hf |= ETH_RSS_IPV4;
231         if (rss_state->tcp_hash)
232                 rss_hf |= ETH_RSS_NONFRAG_IPV4_TCP;
233         if (rss_state->ipv6)
234                 rss_hf |= ETH_RSS_IPV6;
235         if (rss_state->ipv6_tcp_hash)
236                 rss_hf |= ETH_RSS_NONFRAG_IPV6_TCP;
237         if (rss_state->ipv6_ex)
238                 rss_hf |= ETH_RSS_IPV6_EX;
239         if (rss_state->ipv6_tcp_ex_hash)
240                 rss_hf |= ETH_RSS_IPV6_TCP_EX;
241
242         rss_conf->rss_hf = rss_hf;
243
244         return 0;
245 }
246
247 static int
248 lio_dev_rss_hash_update(struct rte_eth_dev *eth_dev,
249                         struct rte_eth_rss_conf *rss_conf)
250 {
251         struct lio_device *lio_dev = LIO_DEV(eth_dev);
252         struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
253         struct lio_rss_set *rss_param;
254         struct lio_dev_ctrl_cmd ctrl_cmd;
255         struct lio_ctrl_pkt ctrl_pkt;
256
257         if (!lio_dev->intf_open) {
258                 lio_dev_err(lio_dev, "Port %d down, can't update hash\n",
259                             lio_dev->port_id);
260                 return -EINVAL;
261         }
262
263         /* flush added to prevent cmd failure
264          * incase the queue is full
265          */
266         lio_flush_iq(lio_dev, lio_dev->instr_queue[0]);
267
268         memset(&ctrl_pkt, 0, sizeof(struct lio_ctrl_pkt));
269         memset(&ctrl_cmd, 0, sizeof(struct lio_dev_ctrl_cmd));
270
271         rss_param = (struct lio_rss_set *)&ctrl_pkt.udd[0];
272
273         ctrl_cmd.eth_dev = eth_dev;
274         ctrl_cmd.cond = 0;
275
276         ctrl_pkt.ncmd.s.cmd = LIO_CMD_SET_RSS;
277         ctrl_pkt.ncmd.s.more = sizeof(struct lio_rss_set) >> 3;
278         ctrl_pkt.ctrl_cmd = &ctrl_cmd;
279
280         rss_param->param.flags = 0xF;
281
282         if (rss_conf->rss_key) {
283                 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_KEY_UNCHANGED;
284                 rss_state->hash_key_size = LIO_RSS_MAX_KEY_SZ;
285                 rss_param->param.hashkeysize = LIO_RSS_MAX_KEY_SZ;
286                 memcpy(rss_state->hash_key, rss_conf->rss_key,
287                        rss_state->hash_key_size);
288                 memcpy(rss_param->key, rss_state->hash_key,
289                        rss_state->hash_key_size);
290         }
291
292         if ((rss_conf->rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
293                 /* Can't disable rss through hash flags,
294                  * if it is enabled by default during init
295                  */
296                 if (!rss_state->hash_disable)
297                         return -EINVAL;
298
299                 /* This is for --disable-rss during testpmd launch */
300                 rss_param->param.flags |= LIO_RSS_PARAM_DISABLE_RSS;
301         } else {
302                 uint32_t hashinfo = 0;
303
304                 /* Can't enable rss if disabled by default during init */
305                 if (rss_state->hash_disable)
306                         return -EINVAL;
307
308                 if (rss_conf->rss_hf & ETH_RSS_IPV4) {
309                         hashinfo |= LIO_RSS_HASH_IPV4;
310                         rss_state->ip = 1;
311                 } else {
312                         rss_state->ip = 0;
313                 }
314
315                 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV4_TCP) {
316                         hashinfo |= LIO_RSS_HASH_TCP_IPV4;
317                         rss_state->tcp_hash = 1;
318                 } else {
319                         rss_state->tcp_hash = 0;
320                 }
321
322                 if (rss_conf->rss_hf & ETH_RSS_IPV6) {
323                         hashinfo |= LIO_RSS_HASH_IPV6;
324                         rss_state->ipv6 = 1;
325                 } else {
326                         rss_state->ipv6 = 0;
327                 }
328
329                 if (rss_conf->rss_hf & ETH_RSS_NONFRAG_IPV6_TCP) {
330                         hashinfo |= LIO_RSS_HASH_TCP_IPV6;
331                         rss_state->ipv6_tcp_hash = 1;
332                 } else {
333                         rss_state->ipv6_tcp_hash = 0;
334                 }
335
336                 if (rss_conf->rss_hf & ETH_RSS_IPV6_EX) {
337                         hashinfo |= LIO_RSS_HASH_IPV6_EX;
338                         rss_state->ipv6_ex = 1;
339                 } else {
340                         rss_state->ipv6_ex = 0;
341                 }
342
343                 if (rss_conf->rss_hf & ETH_RSS_IPV6_TCP_EX) {
344                         hashinfo |= LIO_RSS_HASH_TCP_IPV6_EX;
345                         rss_state->ipv6_tcp_ex_hash = 1;
346                 } else {
347                         rss_state->ipv6_tcp_ex_hash = 0;
348                 }
349
350                 rss_param->param.flags &= ~LIO_RSS_PARAM_HASH_INFO_UNCHANGED;
351                 rss_param->param.hashinfo = hashinfo;
352         }
353
354         lio_swap_8B_data((uint64_t *)rss_param, LIO_RSS_PARAM_SIZE >> 3);
355
356         if (lio_send_ctrl_pkt(lio_dev, &ctrl_pkt)) {
357                 lio_dev_err(lio_dev, "Failed to set rss hash\n");
358                 return -1;
359         }
360
361         if (lio_wait_for_ctrl_cmd(lio_dev, &ctrl_cmd)) {
362                 lio_dev_err(lio_dev, "Set rss hash timed out\n");
363                 return -1;
364         }
365
366         return 0;
367 }
368
369 /**
370  * Atomically writes the link status information into global
371  * structure rte_eth_dev.
372  *
373  * @param eth_dev
374  *   - Pointer to the structure rte_eth_dev to read from.
375  *   - Pointer to the buffer to be saved with the link status.
376  *
377  * @return
378  *   - On success, zero.
379  *   - On failure, negative value.
380  */
381 static inline int
382 lio_dev_atomic_write_link_status(struct rte_eth_dev *eth_dev,
383                                  struct rte_eth_link *link)
384 {
385         struct rte_eth_link *dst = &eth_dev->data->dev_link;
386         struct rte_eth_link *src = link;
387
388         if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
389                                 *(uint64_t *)src) == 0)
390                 return -1;
391
392         return 0;
393 }
394
395 static uint64_t
396 lio_hweight64(uint64_t w)
397 {
398         uint64_t res = w - ((w >> 1) & 0x5555555555555555ul);
399
400         res =
401             (res & 0x3333333333333333ul) + ((res >> 2) & 0x3333333333333333ul);
402         res = (res + (res >> 4)) & 0x0F0F0F0F0F0F0F0Ful;
403         res = res + (res >> 8);
404         res = res + (res >> 16);
405
406         return (res + (res >> 32)) & 0x00000000000000FFul;
407 }
408
409 static int
410 lio_dev_link_update(struct rte_eth_dev *eth_dev,
411                     int wait_to_complete __rte_unused)
412 {
413         struct lio_device *lio_dev = LIO_DEV(eth_dev);
414         struct rte_eth_link link, old;
415
416         /* Initialize */
417         link.link_status = ETH_LINK_DOWN;
418         link.link_speed = ETH_SPEED_NUM_NONE;
419         link.link_duplex = ETH_LINK_HALF_DUPLEX;
420         memset(&old, 0, sizeof(old));
421
422         /* Return what we found */
423         if (lio_dev->linfo.link.s.link_up == 0) {
424                 /* Interface is down */
425                 if (lio_dev_atomic_write_link_status(eth_dev, &link))
426                         return -1;
427                 if (link.link_status == old.link_status)
428                         return -1;
429                 return 0;
430         }
431
432         link.link_status = ETH_LINK_UP; /* Interface is up */
433         link.link_duplex = ETH_LINK_FULL_DUPLEX;
434         switch (lio_dev->linfo.link.s.speed) {
435         case LIO_LINK_SPEED_10000:
436                 link.link_speed = ETH_SPEED_NUM_10G;
437                 break;
438         default:
439                 link.link_speed = ETH_SPEED_NUM_NONE;
440                 link.link_duplex = ETH_LINK_HALF_DUPLEX;
441         }
442
443         if (lio_dev_atomic_write_link_status(eth_dev, &link))
444                 return -1;
445
446         if (link.link_status == old.link_status)
447                 return -1;
448
449         return 0;
450 }
451
452 static void
453 lio_dev_rss_configure(struct rte_eth_dev *eth_dev)
454 {
455         struct lio_device *lio_dev = LIO_DEV(eth_dev);
456         struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
457         struct rte_eth_rss_reta_entry64 reta_conf[8];
458         struct rte_eth_rss_conf rss_conf;
459         uint16_t i;
460
461         /* Configure the RSS key and the RSS protocols used to compute
462          * the RSS hash of input packets.
463          */
464         rss_conf = eth_dev->data->dev_conf.rx_adv_conf.rss_conf;
465         if ((rss_conf.rss_hf & LIO_RSS_OFFLOAD_ALL) == 0) {
466                 rss_state->hash_disable = 1;
467                 lio_dev_rss_hash_update(eth_dev, &rss_conf);
468                 return;
469         }
470
471         if (rss_conf.rss_key == NULL)
472                 rss_conf.rss_key = lio_rss_key; /* Default hash key */
473
474         lio_dev_rss_hash_update(eth_dev, &rss_conf);
475
476         memset(reta_conf, 0, sizeof(reta_conf));
477         for (i = 0; i < LIO_RSS_MAX_TABLE_SZ; i++) {
478                 uint8_t q_idx, conf_idx, reta_idx;
479
480                 q_idx = (uint8_t)((eth_dev->data->nb_rx_queues > 1) ?
481                                   i % eth_dev->data->nb_rx_queues : 0);
482                 conf_idx = i / RTE_RETA_GROUP_SIZE;
483                 reta_idx = i % RTE_RETA_GROUP_SIZE;
484                 reta_conf[conf_idx].reta[reta_idx] = q_idx;
485                 reta_conf[conf_idx].mask |= ((uint64_t)1 << reta_idx);
486         }
487
488         lio_dev_rss_reta_update(eth_dev, reta_conf, LIO_RSS_MAX_TABLE_SZ);
489 }
490
491 static void
492 lio_dev_mq_rx_configure(struct rte_eth_dev *eth_dev)
493 {
494         struct lio_device *lio_dev = LIO_DEV(eth_dev);
495         struct lio_rss_ctx *rss_state = &lio_dev->rss_state;
496         struct rte_eth_rss_conf rss_conf;
497
498         switch (eth_dev->data->dev_conf.rxmode.mq_mode) {
499         case ETH_MQ_RX_RSS:
500                 lio_dev_rss_configure(eth_dev);
501                 break;
502         case ETH_MQ_RX_NONE:
503         /* if mq_mode is none, disable rss mode. */
504         default:
505                 memset(&rss_conf, 0, sizeof(rss_conf));
506                 rss_state->hash_disable = 1;
507                 lio_dev_rss_hash_update(eth_dev, &rss_conf);
508         }
509 }
510
511 /**
512  * Setup our receive queue/ringbuffer. This is the
513  * queue the Octeon uses to send us packets and
514  * responses. We are given a memory pool for our
515  * packet buffers that are used to populate the receive
516  * queue.
517  *
518  * @param eth_dev
519  *    Pointer to the structure rte_eth_dev
520  * @param q_no
521  *    Queue number
522  * @param num_rx_descs
523  *    Number of entries in the queue
524  * @param socket_id
525  *    Where to allocate memory
526  * @param rx_conf
527  *    Pointer to the struction rte_eth_rxconf
528  * @param mp
529  *    Pointer to the packet pool
530  *
531  * @return
532  *    - On success, return 0
533  *    - On failure, return -1
534  */
535 static int
536 lio_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
537                        uint16_t num_rx_descs, unsigned int socket_id,
538                        const struct rte_eth_rxconf *rx_conf __rte_unused,
539                        struct rte_mempool *mp)
540 {
541         struct lio_device *lio_dev = LIO_DEV(eth_dev);
542         struct rte_pktmbuf_pool_private *mbp_priv;
543         uint32_t fw_mapped_oq;
544         uint16_t buf_size;
545
546         if (q_no >= lio_dev->nb_rx_queues) {
547                 lio_dev_err(lio_dev, "Invalid rx queue number %u\n", q_no);
548                 return -EINVAL;
549         }
550
551         lio_dev_dbg(lio_dev, "setting up rx queue %u\n", q_no);
552
553         fw_mapped_oq = lio_dev->linfo.rxpciq[q_no].s.q_no;
554
555         if ((lio_dev->droq[fw_mapped_oq]) &&
556             (num_rx_descs != lio_dev->droq[fw_mapped_oq]->max_count)) {
557                 lio_dev_err(lio_dev,
558                             "Reconfiguring Rx descs not supported. Configure descs to same value %u or restart application\n",
559                             lio_dev->droq[fw_mapped_oq]->max_count);
560                 return -ENOTSUP;
561         }
562
563         mbp_priv = rte_mempool_get_priv(mp);
564         buf_size = mbp_priv->mbuf_data_room_size - RTE_PKTMBUF_HEADROOM;
565
566         if (lio_setup_droq(lio_dev, fw_mapped_oq, num_rx_descs, buf_size, mp,
567                            socket_id)) {
568                 lio_dev_err(lio_dev, "droq allocation failed\n");
569                 return -1;
570         }
571
572         eth_dev->data->rx_queues[q_no] = lio_dev->droq[fw_mapped_oq];
573
574         return 0;
575 }
576
577 /**
578  * Release the receive queue/ringbuffer. Called by
579  * the upper layers.
580  *
581  * @param rxq
582  *    Opaque pointer to the receive queue to release
583  *
584  * @return
585  *    - nothing
586  */
587 static void
588 lio_dev_rx_queue_release(void *rxq)
589 {
590         struct lio_droq *droq = rxq;
591         struct lio_device *lio_dev = droq->lio_dev;
592         int oq_no;
593
594         /* Run time queue deletion not supported */
595         if (lio_dev->port_configured)
596                 return;
597
598         if (droq != NULL) {
599                 oq_no = droq->q_no;
600                 lio_delete_droq_queue(droq->lio_dev, oq_no);
601         }
602 }
603
604 /**
605  * Allocate and initialize SW ring. Initialize associated HW registers.
606  *
607  * @param eth_dev
608  *   Pointer to structure rte_eth_dev
609  *
610  * @param q_no
611  *   Queue number
612  *
613  * @param num_tx_descs
614  *   Number of ringbuffer descriptors
615  *
616  * @param socket_id
617  *   NUMA socket id, used for memory allocations
618  *
619  * @param tx_conf
620  *   Pointer to the structure rte_eth_txconf
621  *
622  * @return
623  *   - On success, return 0
624  *   - On failure, return -errno value
625  */
626 static int
627 lio_dev_tx_queue_setup(struct rte_eth_dev *eth_dev, uint16_t q_no,
628                        uint16_t num_tx_descs, unsigned int socket_id,
629                        const struct rte_eth_txconf *tx_conf __rte_unused)
630 {
631         struct lio_device *lio_dev = LIO_DEV(eth_dev);
632         int fw_mapped_iq = lio_dev->linfo.txpciq[q_no].s.q_no;
633         int retval;
634
635         if (q_no >= lio_dev->nb_tx_queues) {
636                 lio_dev_err(lio_dev, "Invalid tx queue number %u\n", q_no);
637                 return -EINVAL;
638         }
639
640         lio_dev_dbg(lio_dev, "setting up tx queue %u\n", q_no);
641
642         if ((lio_dev->instr_queue[fw_mapped_iq] != NULL) &&
643             (num_tx_descs != lio_dev->instr_queue[fw_mapped_iq]->max_count)) {
644                 lio_dev_err(lio_dev,
645                             "Reconfiguring Tx descs not supported. Configure descs to same value %u or restart application\n",
646                             lio_dev->instr_queue[fw_mapped_iq]->max_count);
647                 return -ENOTSUP;
648         }
649
650         retval = lio_setup_iq(lio_dev, q_no, lio_dev->linfo.txpciq[q_no],
651                               num_tx_descs, lio_dev, socket_id);
652
653         if (retval) {
654                 lio_dev_err(lio_dev, "Runtime IQ(TxQ) creation failed.\n");
655                 return retval;
656         }
657
658         retval = lio_setup_sglists(lio_dev, q_no, fw_mapped_iq,
659                                 lio_dev->instr_queue[fw_mapped_iq]->max_count,
660                                 socket_id);
661
662         if (retval) {
663                 lio_delete_instruction_queue(lio_dev, fw_mapped_iq);
664                 return retval;
665         }
666
667         eth_dev->data->tx_queues[q_no] = lio_dev->instr_queue[fw_mapped_iq];
668
669         return 0;
670 }
671
672 /**
673  * Release the transmit queue/ringbuffer. Called by
674  * the upper layers.
675  *
676  * @param txq
677  *    Opaque pointer to the transmit queue to release
678  *
679  * @return
680  *    - nothing
681  */
682 static void
683 lio_dev_tx_queue_release(void *txq)
684 {
685         struct lio_instr_queue *tq = txq;
686         struct lio_device *lio_dev = tq->lio_dev;
687         uint32_t fw_mapped_iq_no;
688
689         /* Run time queue deletion not supported */
690         if (lio_dev->port_configured)
691                 return;
692
693         if (tq != NULL) {
694                 /* Free sg_list */
695                 lio_delete_sglist(tq);
696
697                 fw_mapped_iq_no = tq->txpciq.s.q_no;
698                 lio_delete_instruction_queue(tq->lio_dev, fw_mapped_iq_no);
699         }
700 }
701
702 /**
703  * Api to check link state.
704  */
705 static void
706 lio_dev_get_link_status(struct rte_eth_dev *eth_dev)
707 {
708         struct lio_device *lio_dev = LIO_DEV(eth_dev);
709         uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
710         struct lio_link_status_resp *resp;
711         union octeon_link_status *ls;
712         struct lio_soft_command *sc;
713         uint32_t resp_size;
714
715         if (!lio_dev->intf_open)
716                 return;
717
718         resp_size = sizeof(struct lio_link_status_resp);
719         sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
720         if (sc == NULL)
721                 return;
722
723         resp = (struct lio_link_status_resp *)sc->virtrptr;
724         lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
725                                  LIO_OPCODE_INFO, 0, 0, 0);
726
727         /* Setting wait time in seconds */
728         sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
729
730         if (lio_send_soft_command(lio_dev, sc) == LIO_IQ_SEND_FAILED)
731                 goto get_status_fail;
732
733         while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
734                 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
735                 rte_delay_ms(1);
736         }
737
738         if (resp->status)
739                 goto get_status_fail;
740
741         ls = &resp->link_info.link;
742
743         lio_swap_8B_data((uint64_t *)ls, sizeof(union octeon_link_status) >> 3);
744
745         if (lio_dev->linfo.link.link_status64 != ls->link_status64) {
746                 lio_dev->linfo.link.link_status64 = ls->link_status64;
747                 lio_dev_link_update(eth_dev, 0);
748         }
749
750         lio_free_soft_command(sc);
751
752         return;
753
754 get_status_fail:
755         lio_free_soft_command(sc);
756 }
757
758 /* This function will be invoked every LSC_TIMEOUT ns (100ms)
759  * and will update link state if it changes.
760  */
761 static void
762 lio_sync_link_state_check(void *eth_dev)
763 {
764         struct lio_device *lio_dev =
765                 (((struct rte_eth_dev *)eth_dev)->data->dev_private);
766
767         if (lio_dev->port_configured)
768                 lio_dev_get_link_status(eth_dev);
769
770         /* Schedule periodic link status check.
771          * Stop check if interface is close and start again while opening.
772          */
773         if (lio_dev->intf_open)
774                 rte_eal_alarm_set(LIO_LSC_TIMEOUT, lio_sync_link_state_check,
775                                   eth_dev);
776 }
777
778 static int
779 lio_dev_start(struct rte_eth_dev *eth_dev)
780 {
781         struct lio_device *lio_dev = LIO_DEV(eth_dev);
782         int ret = 0;
783
784         lio_dev_info(lio_dev, "Starting port %d\n", eth_dev->data->port_id);
785
786         if (lio_dev->fn_list.enable_io_queues(lio_dev))
787                 return -1;
788
789         if (lio_send_rx_ctrl_cmd(eth_dev, 1))
790                 return -1;
791
792         /* Ready for link status updates */
793         lio_dev->intf_open = 1;
794         rte_mb();
795
796         /* Configure RSS if device configured with multiple RX queues. */
797         lio_dev_mq_rx_configure(eth_dev);
798
799         /* start polling for lsc */
800         ret = rte_eal_alarm_set(LIO_LSC_TIMEOUT,
801                                 lio_sync_link_state_check,
802                                 eth_dev);
803         if (ret) {
804                 lio_dev_err(lio_dev,
805                             "link state check handler creation failed\n");
806                 goto dev_lsc_handle_error;
807         }
808
809         return 0;
810
811 dev_lsc_handle_error:
812         lio_dev->intf_open = 0;
813         lio_send_rx_ctrl_cmd(eth_dev, 0);
814
815         return ret;
816 }
817
818 static int lio_dev_configure(struct rte_eth_dev *eth_dev)
819 {
820         struct lio_device *lio_dev = LIO_DEV(eth_dev);
821         uint16_t timeout = LIO_MAX_CMD_TIMEOUT;
822         int retval, num_iqueues, num_oqueues;
823         uint8_t mac[ETHER_ADDR_LEN], i;
824         struct lio_if_cfg_resp *resp;
825         struct lio_soft_command *sc;
826         union lio_if_cfg if_cfg;
827         uint32_t resp_size;
828
829         PMD_INIT_FUNC_TRACE();
830
831         /* Re-configuring firmware not supported.
832          * Can't change tx/rx queues per port from initial value.
833          */
834         if (lio_dev->port_configured) {
835                 if ((lio_dev->nb_rx_queues != eth_dev->data->nb_rx_queues) ||
836                     (lio_dev->nb_tx_queues != eth_dev->data->nb_tx_queues)) {
837                         lio_dev_err(lio_dev,
838                                     "rxq/txq re-conf not supported. Restart application with new value.\n");
839                         return -ENOTSUP;
840                 }
841                 return 0;
842         }
843
844         lio_dev->nb_rx_queues = eth_dev->data->nb_rx_queues;
845         lio_dev->nb_tx_queues = eth_dev->data->nb_tx_queues;
846
847         resp_size = sizeof(struct lio_if_cfg_resp);
848         sc = lio_alloc_soft_command(lio_dev, 0, resp_size, 0);
849         if (sc == NULL)
850                 return -ENOMEM;
851
852         resp = (struct lio_if_cfg_resp *)sc->virtrptr;
853
854         /* Firmware doesn't have capability to reconfigure the queues,
855          * Claim all queues, and use as many required
856          */
857         if_cfg.if_cfg64 = 0;
858         if_cfg.s.num_iqueues = lio_dev->nb_tx_queues;
859         if_cfg.s.num_oqueues = lio_dev->nb_rx_queues;
860         if_cfg.s.base_queue = 0;
861
862         if_cfg.s.gmx_port_id = lio_dev->pf_num;
863
864         lio_prepare_soft_command(lio_dev, sc, LIO_OPCODE,
865                                  LIO_OPCODE_IF_CFG, 0,
866                                  if_cfg.if_cfg64, 0);
867
868         /* Setting wait time in seconds */
869         sc->wait_time = LIO_MAX_CMD_TIMEOUT / 1000;
870
871         retval = lio_send_soft_command(lio_dev, sc);
872         if (retval == LIO_IQ_SEND_FAILED) {
873                 lio_dev_err(lio_dev, "iq/oq config failed status: %x\n",
874                             retval);
875                 /* Soft instr is freed by driver in case of failure. */
876                 goto nic_config_fail;
877         }
878
879         /* Sleep on a wait queue till the cond flag indicates that the
880          * response arrived or timed-out.
881          */
882         while ((*sc->status_word == LIO_COMPLETION_WORD_INIT) && --timeout) {
883                 lio_flush_iq(lio_dev, lio_dev->instr_queue[sc->iq_no]);
884                 lio_process_ordered_list(lio_dev);
885                 rte_delay_ms(1);
886         }
887
888         retval = resp->status;
889         if (retval) {
890                 lio_dev_err(lio_dev, "iq/oq config failed\n");
891                 goto nic_config_fail;
892         }
893
894         lio_swap_8B_data((uint64_t *)(&resp->cfg_info),
895                          sizeof(struct octeon_if_cfg_info) >> 3);
896
897         num_iqueues = lio_hweight64(resp->cfg_info.iqmask);
898         num_oqueues = lio_hweight64(resp->cfg_info.oqmask);
899
900         if (!(num_iqueues) || !(num_oqueues)) {
901                 lio_dev_err(lio_dev,
902                             "Got bad iqueues (%016lx) or oqueues (%016lx) from firmware.\n",
903                             (unsigned long)resp->cfg_info.iqmask,
904                             (unsigned long)resp->cfg_info.oqmask);
905                 goto nic_config_fail;
906         }
907
908         lio_dev_dbg(lio_dev,
909                     "interface %d, iqmask %016lx, oqmask %016lx, numiqueues %d, numoqueues %d\n",
910                     eth_dev->data->port_id,
911                     (unsigned long)resp->cfg_info.iqmask,
912                     (unsigned long)resp->cfg_info.oqmask,
913                     num_iqueues, num_oqueues);
914
915         lio_dev->linfo.num_rxpciq = num_oqueues;
916         lio_dev->linfo.num_txpciq = num_iqueues;
917
918         for (i = 0; i < num_oqueues; i++) {
919                 lio_dev->linfo.rxpciq[i].rxpciq64 =
920                     resp->cfg_info.linfo.rxpciq[i].rxpciq64;
921                 lio_dev_dbg(lio_dev, "index %d OQ %d\n",
922                             i, lio_dev->linfo.rxpciq[i].s.q_no);
923         }
924
925         for (i = 0; i < num_iqueues; i++) {
926                 lio_dev->linfo.txpciq[i].txpciq64 =
927                     resp->cfg_info.linfo.txpciq[i].txpciq64;
928                 lio_dev_dbg(lio_dev, "index %d IQ %d\n",
929                             i, lio_dev->linfo.txpciq[i].s.q_no);
930         }
931
932         lio_dev->linfo.hw_addr = resp->cfg_info.linfo.hw_addr;
933         lio_dev->linfo.gmxport = resp->cfg_info.linfo.gmxport;
934         lio_dev->linfo.link.link_status64 =
935                         resp->cfg_info.linfo.link.link_status64;
936
937         /* 64-bit swap required on LE machines */
938         lio_swap_8B_data(&lio_dev->linfo.hw_addr, 1);
939         for (i = 0; i < ETHER_ADDR_LEN; i++)
940                 mac[i] = *((uint8_t *)(((uint8_t *)&lio_dev->linfo.hw_addr) +
941                                        2 + i));
942
943         /* Copy the permanent MAC address */
944         ether_addr_copy((struct ether_addr *)mac, &eth_dev->data->mac_addrs[0]);
945
946         lio_dev->glist_lock =
947             rte_zmalloc(NULL, sizeof(*lio_dev->glist_lock) * num_iqueues, 0);
948         if (lio_dev->glist_lock == NULL)
949                 return -ENOMEM;
950
951         lio_dev->glist_head =
952                 rte_zmalloc(NULL, sizeof(*lio_dev->glist_head) * num_iqueues,
953                             0);
954         if (lio_dev->glist_head == NULL) {
955                 rte_free(lio_dev->glist_lock);
956                 lio_dev->glist_lock = NULL;
957                 return -ENOMEM;
958         }
959
960         lio_dev_link_update(eth_dev, 0);
961
962         lio_dev->port_configured = 1;
963
964         lio_free_soft_command(sc);
965
966         /* Disable iq_0 for reconf */
967         lio_dev->fn_list.disable_io_queues(lio_dev);
968
969         /* Reset ioq regs */
970         lio_dev->fn_list.setup_device_regs(lio_dev);
971
972         /* Free iq_0 used during init */
973         lio_free_instr_queue0(lio_dev);
974
975         return 0;
976
977 nic_config_fail:
978         lio_dev_err(lio_dev, "Failed retval %d\n", retval);
979         lio_free_soft_command(sc);
980         lio_free_instr_queue0(lio_dev);
981
982         return -ENODEV;
983 }
984
985 /* Define our ethernet definitions */
986 static const struct eth_dev_ops liovf_eth_dev_ops = {
987         .dev_configure          = lio_dev_configure,
988         .dev_start              = lio_dev_start,
989         .link_update            = lio_dev_link_update,
990         .rx_queue_setup         = lio_dev_rx_queue_setup,
991         .rx_queue_release       = lio_dev_rx_queue_release,
992         .tx_queue_setup         = lio_dev_tx_queue_setup,
993         .tx_queue_release       = lio_dev_tx_queue_release,
994         .reta_update            = lio_dev_rss_reta_update,
995         .reta_query             = lio_dev_rss_reta_query,
996         .rss_hash_conf_get      = lio_dev_rss_hash_conf_get,
997         .rss_hash_update        = lio_dev_rss_hash_update,
998 };
999
1000 static void
1001 lio_check_pf_hs_response(void *lio_dev)
1002 {
1003         struct lio_device *dev = lio_dev;
1004
1005         /* check till response arrives */
1006         if (dev->pfvf_hsword.coproc_tics_per_us)
1007                 return;
1008
1009         cn23xx_vf_handle_mbox(dev);
1010
1011         rte_eal_alarm_set(1, lio_check_pf_hs_response, lio_dev);
1012 }
1013
1014 /**
1015  * \brief Identify the LIO device and to map the BAR address space
1016  * @param lio_dev lio device
1017  */
1018 static int
1019 lio_chip_specific_setup(struct lio_device *lio_dev)
1020 {
1021         struct rte_pci_device *pdev = lio_dev->pci_dev;
1022         uint32_t dev_id = pdev->id.device_id;
1023         const char *s;
1024         int ret = 1;
1025
1026         switch (dev_id) {
1027         case LIO_CN23XX_VF_VID:
1028                 lio_dev->chip_id = LIO_CN23XX_VF_VID;
1029                 ret = cn23xx_vf_setup_device(lio_dev);
1030                 s = "CN23XX VF";
1031                 break;
1032         default:
1033                 s = "?";
1034                 lio_dev_err(lio_dev, "Unsupported Chip\n");
1035         }
1036
1037         if (!ret)
1038                 lio_dev_info(lio_dev, "DEVICE : %s\n", s);
1039
1040         return ret;
1041 }
1042
1043 static int
1044 lio_first_time_init(struct lio_device *lio_dev,
1045                     struct rte_pci_device *pdev)
1046 {
1047         int dpdk_queues;
1048
1049         PMD_INIT_FUNC_TRACE();
1050
1051         /* set dpdk specific pci device pointer */
1052         lio_dev->pci_dev = pdev;
1053
1054         /* Identify the LIO type and set device ops */
1055         if (lio_chip_specific_setup(lio_dev)) {
1056                 lio_dev_err(lio_dev, "Chip specific setup failed\n");
1057                 return -1;
1058         }
1059
1060         /* Initialize soft command buffer pool */
1061         if (lio_setup_sc_buffer_pool(lio_dev)) {
1062                 lio_dev_err(lio_dev, "sc buffer pool allocation failed\n");
1063                 return -1;
1064         }
1065
1066         /* Initialize lists to manage the requests of different types that
1067          * arrive from applications for this lio device.
1068          */
1069         lio_setup_response_list(lio_dev);
1070
1071         if (lio_dev->fn_list.setup_mbox(lio_dev)) {
1072                 lio_dev_err(lio_dev, "Mailbox setup failed\n");
1073                 goto error;
1074         }
1075
1076         /* Check PF response */
1077         lio_check_pf_hs_response((void *)lio_dev);
1078
1079         /* Do handshake and exit if incompatible PF driver */
1080         if (cn23xx_pfvf_handshake(lio_dev))
1081                 goto error;
1082
1083         /* Initial reset */
1084         cn23xx_vf_ask_pf_to_do_flr(lio_dev);
1085         /* Wait for FLR for 100ms per SRIOV specification */
1086         rte_delay_ms(100);
1087
1088         if (cn23xx_vf_set_io_queues_off(lio_dev)) {
1089                 lio_dev_err(lio_dev, "Setting io queues off failed\n");
1090                 goto error;
1091         }
1092
1093         if (lio_dev->fn_list.setup_device_regs(lio_dev)) {
1094                 lio_dev_err(lio_dev, "Failed to configure device registers\n");
1095                 goto error;
1096         }
1097
1098         if (lio_setup_instr_queue0(lio_dev)) {
1099                 lio_dev_err(lio_dev, "Failed to setup instruction queue 0\n");
1100                 goto error;
1101         }
1102
1103         dpdk_queues = (int)lio_dev->sriov_info.rings_per_vf;
1104
1105         lio_dev->max_tx_queues = dpdk_queues;
1106         lio_dev->max_rx_queues = dpdk_queues;
1107
1108         /* Enable input and output queues for this device */
1109         if (lio_dev->fn_list.enable_io_queues(lio_dev))
1110                 goto error;
1111
1112         return 0;
1113
1114 error:
1115         lio_free_sc_buffer_pool(lio_dev);
1116         if (lio_dev->mbox[0])
1117                 lio_dev->fn_list.free_mbox(lio_dev);
1118         if (lio_dev->instr_queue[0])
1119                 lio_free_instr_queue0(lio_dev);
1120
1121         return -1;
1122 }
1123
1124 static int
1125 lio_eth_dev_uninit(struct rte_eth_dev *eth_dev)
1126 {
1127         struct lio_device *lio_dev = LIO_DEV(eth_dev);
1128
1129         PMD_INIT_FUNC_TRACE();
1130
1131         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1132                 return -EPERM;
1133
1134         /* lio_free_sc_buffer_pool */
1135         lio_free_sc_buffer_pool(lio_dev);
1136
1137         rte_free(eth_dev->data->mac_addrs);
1138         eth_dev->data->mac_addrs = NULL;
1139
1140         eth_dev->rx_pkt_burst = NULL;
1141         eth_dev->tx_pkt_burst = NULL;
1142
1143         return 0;
1144 }
1145
1146 static int
1147 lio_eth_dev_init(struct rte_eth_dev *eth_dev)
1148 {
1149         struct rte_pci_device *pdev = RTE_DEV_TO_PCI(eth_dev->device);
1150         struct lio_device *lio_dev = LIO_DEV(eth_dev);
1151
1152         PMD_INIT_FUNC_TRACE();
1153
1154         eth_dev->rx_pkt_burst = &lio_dev_recv_pkts;
1155         eth_dev->tx_pkt_burst = &lio_dev_xmit_pkts;
1156
1157         /* Primary does the initialization. */
1158         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1159                 return 0;
1160
1161         rte_eth_copy_pci_info(eth_dev, pdev);
1162         eth_dev->data->dev_flags |= RTE_ETH_DEV_DETACHABLE;
1163
1164         if (pdev->mem_resource[0].addr) {
1165                 lio_dev->hw_addr = pdev->mem_resource[0].addr;
1166         } else {
1167                 PMD_INIT_LOG(ERR, "ERROR: Failed to map BAR0\n");
1168                 return -ENODEV;
1169         }
1170
1171         lio_dev->eth_dev = eth_dev;
1172         /* set lio device print string */
1173         snprintf(lio_dev->dev_string, sizeof(lio_dev->dev_string),
1174                  "%s[%02x:%02x.%x]", pdev->driver->driver.name,
1175                  pdev->addr.bus, pdev->addr.devid, pdev->addr.function);
1176
1177         lio_dev->port_id = eth_dev->data->port_id;
1178
1179         if (lio_first_time_init(lio_dev, pdev)) {
1180                 lio_dev_err(lio_dev, "Device init failed\n");
1181                 return -EINVAL;
1182         }
1183
1184         eth_dev->dev_ops = &liovf_eth_dev_ops;
1185         eth_dev->data->mac_addrs = rte_zmalloc("lio", ETHER_ADDR_LEN, 0);
1186         if (eth_dev->data->mac_addrs == NULL) {
1187                 lio_dev_err(lio_dev,
1188                             "MAC addresses memory allocation failed\n");
1189                 eth_dev->dev_ops = NULL;
1190                 eth_dev->rx_pkt_burst = NULL;
1191                 eth_dev->tx_pkt_burst = NULL;
1192                 return -ENOMEM;
1193         }
1194
1195         rte_atomic64_set(&lio_dev->status, LIO_DEV_RUNNING);
1196         rte_wmb();
1197
1198         lio_dev->port_configured = 0;
1199         /* Always allow unicast packets */
1200         lio_dev->ifflags |= LIO_IFFLAG_UNICAST;
1201
1202         return 0;
1203 }
1204
1205 /* Set of PCI devices this driver supports */
1206 static const struct rte_pci_id pci_id_liovf_map[] = {
1207         { RTE_PCI_DEVICE(PCI_VENDOR_ID_CAVIUM, LIO_CN23XX_VF_VID) },
1208         { .vendor_id = 0, /* sentinel */ }
1209 };
1210
1211 static struct eth_driver rte_liovf_pmd = {
1212         .pci_drv = {
1213                 .id_table       = pci_id_liovf_map,
1214                 .drv_flags      = RTE_PCI_DRV_NEED_MAPPING,
1215                 .probe          = rte_eth_dev_pci_probe,
1216                 .remove         = rte_eth_dev_pci_remove,
1217         },
1218         .eth_dev_init           = lio_eth_dev_init,
1219         .eth_dev_uninit         = lio_eth_dev_uninit,
1220         .dev_private_size       = sizeof(struct lio_device),
1221 };
1222
1223 RTE_PMD_REGISTER_PCI(net_liovf, rte_liovf_pmd.pci_drv);
1224 RTE_PMD_REGISTER_PCI_TABLE(net_liovf, pci_id_liovf_map);
1225 RTE_PMD_REGISTER_KMOD_DEP(net_liovf, "* igb_uio | vfio");