FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
vmxnet3.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vppinfra/types.h>
17 #include <vlib/vlib.h>
18 #include <vlib/pci/pci.h>
19 #include <vnet/ethernet/ethernet.h>
20 #include <vnet/plugin/plugin.h>
21 #include <vpp/app/version.h>
24 #include <vmxnet3/vmxnet3.h>
25 
26 #define PCI_VENDOR_ID_VMWARE 0x15ad
27 #define PCI_DEVICE_ID_VMWARE_VMXNET3 0x07b0
28 
30 
32  {
34  .device_id = PCI_DEVICE_ID_VMWARE_VMXNET3},
35  {0},
36 };
37 
38 static clib_error_t *
40  u32 flags)
41 {
42  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
44  vmxnet3_device_t *vd = vec_elt_at_index (vmxm->devices, hi->dev_instance);
46 
47  if (vd->flags & VMXNET3_DEVICE_F_ERROR)
48  return clib_error_return (0, "device is in error state");
49 
50  if (is_up)
51  {
54  vd->flags |= VMXNET3_DEVICE_F_ADMIN_UP;
55  }
56  else
57  {
59  vd->flags &= ~VMXNET3_DEVICE_F_ADMIN_UP;
60  }
61  return 0;
62 }
63 
64 static clib_error_t *
67 {
69  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
71  vmxnet3_rxq_t *rxq = vec_elt_at_index (vd->rxqs, qid);
73 
74  if (mode == rxq->mode)
75  return 0;
78  return clib_error_return (0, "Rx mode %U not supported",
80  rxq->mode = mode;
81  ptd = vec_elt_at_index (vmxm->per_thread_data, rxq->thread_index);
82  if (rxq->mode == VNET_HW_IF_RX_MODE_POLLING)
83  ptd->polling_q_count++;
84  else
85  {
86  ASSERT (ptd->polling_q_count != 0);
87  ptd->polling_q_count--;
88  }
89 
90  return 0;
91 }
92 
93 static void
96 {
98  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
100 
101  /* Shut off redirection */
102  if (node_index == ~0)
103  {
105  return;
106  }
107 
110  node_index);
111 }
112 
113 static void
115 {
116  vmxnet3_main_t *vmxm = &vmxnet3_main;
118  vmxnet3_tx_queue *tx = VMXNET3_TX_START (vd);
119  vmxnet3_rx_queue *rx = VMXNET3_RX_START (vd);
120  u16 qid;
121 
122  /*
123  * Set the "last_cleared_stats" to the current stats, so that
124  * things appear to clear from a display perspective.
125  */
126  vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_GET_STATS);
127 
128  vec_foreach_index (qid, vd->txqs)
129  {
130  vmxnet3_tx_stats *txs = vec_elt_at_index (vd->tx_stats, qid);
131  clib_memcpy (txs, &tx->stats, sizeof (*txs));
132  tx++;
133  }
134  vec_foreach_index (qid, vd->rxqs)
135  {
136  vmxnet3_rx_stats *rxs = vec_elt_at_index (vd->rx_stats, qid);
137  clib_memcpy (rxs, &rx->stats, sizeof (*rxs));
138  rx++;
139  }
140 }
141 
143 #define _(n,s) s,
145 #undef _
146 };
147 
148 /* *INDENT-OFF* */
150 {
151  .name = "VMXNET3 interface",
152  .format_device = format_vmxnet3_device,
153  .format_device_name = format_vmxnet3_device_name,
154  .admin_up_down_function = vmxnet3_interface_admin_up_down,
155  .clear_counters = vmxnet3_clear_hw_interface_counters,
156  .rx_mode_change_function = vmxnet3_interface_rx_mode_change,
157  .rx_redirect_to_node = vmxnet3_set_interface_next_node,
158  .tx_function_n_errors = VMXNET3_TX_N_ERROR,
159  .tx_function_error_strings = vmxnet3_tx_func_error_strings,
160 };
161 /* *INDENT-ON* */
162 
163 static u32
165 {
166  return 0;
167 }
168 
169 static void
171 {
172  u32 val;
173 
174  memcpy (&val, vd->mac_addr, 4);
175  vmxnet3_reg_write (vd, 1, VMXNET3_REG_MACL, val);
176 
177  val = 0;
178  memcpy (&val, vd->mac_addr + 4, 2);
179  vmxnet3_reg_write (vd, 1, VMXNET3_REG_MACH, val);
180 }
181 
182 static clib_error_t *
184 {
185  vmxnet3_shared *shared;
186  u64 shared_dma;
187  u16 qid, rid;
188  vmxnet3_tx_queue *tx = VMXNET3_TX_START (vd);
189  vmxnet3_rx_queue *rx = VMXNET3_RX_START (vd);
190 
191  vd->driver_shared =
193  vd->numa_node);
194  if (vd->driver_shared == 0)
195  return vlib_physmem_last_error (vm);
196 
197  clib_memset (vd->driver_shared, 0, sizeof (*vd->driver_shared));
198 
199  vec_foreach_index (qid, vd->txqs)
200  {
201  vmxnet3_txq_t *txq = vec_elt_at_index (vd->txqs, qid);
202 
203  tx->cfg.desc_address = vmxnet3_dma_addr (vm, vd, txq->tx_desc);
204  tx->cfg.comp_address = vmxnet3_dma_addr (vm, vd, txq->tx_comp);
205  tx->cfg.num_desc = txq->size;
206  tx->cfg.num_comp = txq->size;
207  tx++;
208  }
209 
210  vec_foreach_index (qid, vd->rxqs)
211  {
212  vmxnet3_rxq_t *rxq = vec_elt_at_index (vd->rxqs, qid);
213 
214  for (rid = 0; rid < VMXNET3_RX_RING_SIZE; rid++)
215  {
216  rx->cfg.desc_address[rid] = vmxnet3_dma_addr (vm, vd,
217  rxq->rx_desc[rid]);
218  rx->cfg.num_desc[rid] = rxq->size;
219  }
220  rx->cfg.comp_address = vmxnet3_dma_addr (vm, vd, rxq->rx_comp);
221  rx->cfg.num_comp = rxq->size;
222  rx->cfg.intr_index = qid;
223  rx++;
224  }
225 
226  shared = vd->driver_shared;
227  shared->magic = VMXNET3_SHARED_MAGIC;
228  shared->misc.version = VMXNET3_VERSION_MAGIC;
229  if (sizeof (void *) == 4)
230  shared->misc.guest_info = VMXNET3_GOS_BITS_32;
231  else
232  shared->misc.guest_info = VMXNET3_GOS_BITS_64;
233  shared->misc.guest_info |= VMXNET3_GOS_TYPE_LINUX;
234  shared->misc.version_support = VMXNET3_VERSION_SELECT;
235  shared->misc.upt_features = VMXNET3_F_RXCSUM;
236  if (vd->gso_enable)
237  shared->misc.upt_features |= VMXNET3_F_LRO;
238  if (vd->num_rx_queues > 1)
239  {
240  shared->misc.upt_features |= VMXNET3_F_RSS;
241  shared->rss.version = 1;
242  shared->rss.address = vmxnet3_dma_addr (vm, vd, vd->rss);
243  shared->rss.length = sizeof (*vd->rss);
244  }
245  shared->misc.max_num_rx_sg = 0;
246  shared->misc.upt_version_support = VMXNET3_UPT_VERSION_SELECT;
247  shared->misc.queue_desc_address = vmxnet3_dma_addr (vm, vd, vd->queues);
248  shared->misc.queue_desc_len = sizeof (*tx) * vd->num_tx_queues +
249  sizeof (*rx) * vd->num_rx_queues;
250  shared->misc.mtu = VMXNET3_MTU;
251  shared->misc.num_tx_queues = vd->num_tx_queues;
252  shared->misc.num_rx_queues = vd->num_rx_queues;
253  shared->interrupt.num_intrs = vd->num_intrs;
254  shared->interrupt.event_intr_index = vd->num_rx_queues;
255  shared->interrupt.control = VMXNET3_IC_DISABLE_ALL;
256  shared->rx_filter.mode = VMXNET3_RXMODE_UCAST | VMXNET3_RXMODE_BCAST |
257  VMXNET3_RXMODE_ALL_MULTI | VMXNET3_RXMODE_PROMISC;
258  shared_dma = vmxnet3_dma_addr (vm, vd, shared);
259 
260  vmxnet3_reg_write (vd, 1, VMXNET3_REG_DSAL, shared_dma);
261  vmxnet3_reg_write (vd, 1, VMXNET3_REG_DSAH, shared_dma >> 32);
262 
263  return 0;
264 }
265 
266 static inline void
268 {
269  int i;
270  vmxnet3_shared *shared = vd->driver_shared;
271 
272  shared->interrupt.control &= ~VMXNET3_IC_DISABLE_ALL;
273  for (i = 0; i < vd->num_intrs; i++)
274  vmxnet3_reg_write (vd, 0, VMXNET3_REG_IMR + i * 8, 0);
275 }
276 
277 static inline void
279 {
280  int i;
281  vmxnet3_shared *shared = vd->driver_shared;
282 
283  shared->interrupt.control |= VMXNET3_IC_DISABLE_ALL;
284  for (i = 0; i < vd->num_intrs; i++)
285  vmxnet3_reg_write (vd, 0, VMXNET3_REG_IMR + i * 8, 1);
286 }
287 
288 static clib_error_t *
290 {
291  vmxnet3_rxq_t *rxq;
292  vmxnet3_rx_stats *rxs;
293  u16 rid;
294 
295  vec_validate (vd->rx_stats, qid);
296  rxs = vec_elt_at_index (vd->rx_stats, qid);
297  clib_memset (rxs, 0, sizeof (*rxs));
298 
300  rxq = vec_elt_at_index (vd->rxqs, qid);
301  clib_memset (rxq, 0, sizeof (*rxq));
302  rxq->size = qsz;
304  for (rid = 0; rid < VMXNET3_RX_RING_SIZE; rid++)
305  {
307  (vm, qsz * sizeof (*rxq->rx_desc[rid]), 512, vd->numa_node);
308 
309  if (rxq->rx_desc[rid] == 0)
310  return vlib_physmem_last_error (vm);
311 
312  clib_memset (rxq->rx_desc[rid], 0, qsz * sizeof (*rxq->rx_desc[rid]));
313  }
314  rxq->rx_comp =
315  vlib_physmem_alloc_aligned_on_numa (vm, qsz * sizeof (*rxq->rx_comp), 512,
316  vd->numa_node);
317  if (rxq->rx_comp == 0)
318  return vlib_physmem_last_error (vm);
319 
320  clib_memset (rxq->rx_comp, 0, qsz * sizeof (*rxq->rx_comp));
321  for (rid = 0; rid < VMXNET3_RX_RING_SIZE; rid++)
322  {
323  vmxnet3_rx_ring *ring;
324 
325  ring = &rxq->rx_ring[rid];
326  ring->gen = VMXNET3_RXF_GEN;
327  ring->rid = rid;
329  }
331 
332  return 0;
333 }
334 
335 static clib_error_t *
337 {
338  vmxnet3_txq_t *txq;
339  vmxnet3_tx_stats *txs;
340  u32 size;
341 
343  txq = vec_elt_at_index (vd->txqs, qid);
344  clib_memset (txq, 0, sizeof (*txq));
345  clib_spinlock_init (&txq->lock);
346 
347  vec_validate (vd->tx_stats, qid);
348  txs = vec_elt_at_index (vd->tx_stats, qid);
349  clib_memset (txs, 0, sizeof (*txs));
350 
351  txq->size = qsz;
352  txq->reg_txprod = qid * 8 + VMXNET3_REG_TXPROD;
353 
354  size = qsz * sizeof (*txq->tx_desc);
355  txq->tx_desc =
357  if (txq->tx_desc == 0)
358  return vlib_physmem_last_error (vm);
359 
360  clib_memset (txq->tx_desc, 0, size);
361 
362  size = qsz * sizeof (*txq->tx_comp);
363  txq->tx_comp =
365  if (txq->tx_comp == 0)
366  return vlib_physmem_last_error (vm);
367 
368  clib_memset (txq->tx_comp, 0, size);
370  txq->tx_ring.gen = VMXNET3_TXF_GEN;
372 
373  return 0;
374 }
375 
377  0x3b, 0x56, 0xd1, 0x56, 0x13, 0x4a, 0xe7, 0xac,
378  0xe8, 0x79, 0x09, 0x75, 0xe8, 0x65, 0x79, 0x28,
379  0x35, 0x12, 0xb9, 0x56, 0x7c, 0x76, 0x4b, 0x70,
380  0xd8, 0x56, 0xa3, 0x18, 0x9b, 0x0a, 0xee, 0xf3,
381  0x96, 0xa6, 0x9f, 0x8f, 0x9e, 0x8c, 0x90, 0xc9,
382 };
383 
384 static clib_error_t *
386 {
387  vmxnet3_rss_shared *rss;
388  size_t size = sizeof (*rss);
389  u8 i;
390 
392  if (vd->rss == 0)
393  return vlib_physmem_last_error (vm);
394 
395  clib_memset (vd->rss, 0, size);
396  rss = vd->rss;
397  rss->hash_type =
398  VMXNET3_RSS_HASH_TYPE_IPV4 | VMXNET3_RSS_HASH_TYPE_TCP_IPV4 |
399  VMXNET3_RSS_HASH_TYPE_IPV6 | VMXNET3_RSS_HASH_TYPE_TCP_IPV6;
400  rss->hash_func = VMXNET3_RSS_HASH_FUNC_TOEPLITZ;
401  rss->hash_key_sz = VMXNET3_RSS_MAX_KEY_SZ;
402  rss->ind_table_sz = VMXNET3_RSS_MAX_IND_TABLE_SZ;
404  for (i = 0; i < rss->ind_table_sz; i++)
405  rss->ind_table[i] = i % vd->num_rx_queues;
406 
407  return 0;
408 }
409 
410 static clib_error_t *
413 {
414  clib_error_t *error = 0;
415  u32 ret, i, size;
416 
417  /* Quiesce the device */
418  vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_QUIESCE_DEV);
419  ret = vmxnet3_reg_read (vd, 1, VMXNET3_REG_CMD);
420  if (ret != 0)
421  {
422  error = clib_error_return (0, "error on quiescing device rc (%u)", ret);
423  return error;
424  }
425 
426  /* Reset the device */
427  vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV);
428  ret = vmxnet3_reg_read (vd, 1, VMXNET3_REG_CMD);
429  if (ret != 0)
430  {
431  error = clib_error_return (0, "error on resetting device rc (%u)", ret);
432  return error;
433  }
434 
435  ret = vmxnet3_reg_read (vd, 1, VMXNET3_REG_VRRS);
436  vd->version = count_leading_zeros (ret);
437  vd->version = uword_bits - vd->version;
438 
439  if (vd->version == 0)
440  {
441  error = clib_error_return (0, "unsupported hardware version %u",
442  vd->version);
443  return error;
444  }
445 
446  /* cap support version to 3 */
448  1 << (clib_min (3, vd->version) - 1));
449 
450  ret = vmxnet3_reg_read (vd, 1, VMXNET3_REG_UVRS);
451  if (ret & 1)
453  else
454  {
455  error = clib_error_return (0, "unsupported upt version %u", ret);
456  return error;
457  }
458 
459  /* GSO is only supported for version >= 3 */
460  if (args->enable_gso)
461  {
462  if (vd->version >= 3)
463  vd->gso_enable = 1;
464  else
465  {
466  error =
468  "GSO is not supported because hardware version"
469  " is %u. It must be >= 3", vd->version);
470  return error;
471  }
472  }
473 
474  vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_GET_LINK);
475  ret = vmxnet3_reg_read (vd, 1, VMXNET3_REG_CMD);
476  if (ret & 1)
477  {
478  vd->flags |= VMXNET3_DEVICE_F_LINK_UP;
479  vd->link_speed = ret >> 16;
480  }
481  else
482  vd->flags &= ~VMXNET3_DEVICE_F_LINK_UP;
483 
484  /* Get the mac address */
485  ret = vmxnet3_reg_read (vd, 1, VMXNET3_REG_MACL);
486  clib_memcpy (vd->mac_addr, &ret, 4);
487  ret = vmxnet3_reg_read (vd, 1, VMXNET3_REG_MACH);
488  clib_memcpy (vd->mac_addr + 4, &ret, 2);
489 
490  size = sizeof (vmxnet3_rx_queue) * vd->num_rx_queues +
491  sizeof (vmxnet3_tx_queue) * vd->num_tx_queues;
492 
493  vd->queues =
495  if (vd->queues == 0)
496  return vlib_physmem_last_error (vm);
497 
498  clib_memset (vd->queues, 0, size);
499 
500  if (vd->num_rx_queues > 1)
501  {
502  error = vmxnet3_rss_init (vm, vd);
503  if (error)
504  return error;
505  }
506 
507  for (i = 0; i < vd->num_rx_queues; i++)
508  {
509  error = vmxnet3_rxq_init (vm, vd, i, args->rxq_size);
510  if (error)
511  return error;
512  }
513 
514  for (i = 0; i < vd->num_tx_queues; i++)
515  {
516  error = vmxnet3_txq_init (vm, vd, i, args->txq_size);
517  if (error)
518  return error;
519  }
520 
522  if (error)
523  return error;
524 
525  vmxnet3_write_mac (vd);
526 
527  /* Activate device */
528  vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_ACTIVATE_DEV);
529  ret = vmxnet3_reg_read (vd, 1, VMXNET3_REG_CMD);
530  if (ret != 0)
531  {
532  error =
533  clib_error_return (0, "error on activating device rc (%u)", ret);
534  return error;
535  }
536 
537  return error;
538 }
539 
540 static void
542 {
543  vnet_main_t *vnm = vnet_get_main ();
544  vmxnet3_main_t *vmxm = &vmxnet3_main;
546  vmxnet3_device_t *vd = pool_elt_at_index (vmxm->devices, pd);
547  u16 qid = line;
548  vmxnet3_rxq_t *rxq = vec_elt_at_index (vd->rxqs, qid);
549 
550  if (vec_len (vd->rxqs) > qid && (rxq->mode != VNET_HW_IF_RX_MODE_POLLING))
551  {
554  if (ptd->polling_q_count == 0)
556  }
557 }
558 
559 static void
561  u16 line)
562 {
563  vnet_main_t *vnm = vnet_get_main ();
564  vmxnet3_main_t *vmxm = &vmxnet3_main;
566  vmxnet3_device_t *vd = pool_elt_at_index (vmxm->devices, pd);
567  u32 ret;
568 
569  vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_GET_LINK);
570  ret = vmxnet3_reg_read (vd, 1, VMXNET3_REG_CMD);
571  if (ret & 1)
572  {
573  vd->flags |= VMXNET3_DEVICE_F_LINK_UP;
574  vd->link_speed = ret >> 16;
576  vd->link_speed * 1000);
579  }
580  else
581  {
582  vd->flags &= ~VMXNET3_DEVICE_F_LINK_UP;
584  }
585 }
586 
587 static u8
589 {
590  if (qsz < 64 || qsz > 4096)
591  return 0;
592  if ((qsz % 64) != 0)
593  return 0;
594  return 1;
595 }
596 
597 static u8
599 {
601 
602  if ((num > VMXNET3_TXQ_MAX) || (num > tm->n_vlib_mains))
603  return 0;
604  return 1;
605 }
606 
607 static u8
609 {
610  if (num > VMXNET3_RXQ_MAX)
611  return 0;
612  return 1;
613 }
614 
615 void
617 {
618  vnet_main_t *vnm = vnet_get_main ();
619  vmxnet3_main_t *vmxm = &vmxnet3_main;
620  vmxnet3_device_t *vd;
622  clib_error_t *error = 0;
623  u16 qid;
624  u32 num_intr;
625 
626  if (args->txq_num == 0)
627  args->txq_num = 1;
628  if (args->rxq_num == 0)
629  args->rxq_num = 1;
630  if (!vmxnet3_rx_queue_num_valid (args->rxq_num))
631  {
632  args->rv = VNET_API_ERROR_INVALID_VALUE;
633  args->error =
634  clib_error_return (error, "number of rx queues must be <= %u",
636  vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default, "%U: %s",
637  format_vlib_pci_addr, &args->addr,
638  "number of rx queues must be <= %u", VMXNET3_RXQ_MAX);
639  return;
640  }
641 
642  if (!vmxnet3_tx_queue_num_valid (args->txq_num))
643  {
644  args->rv = VNET_API_ERROR_INVALID_VALUE;
645  args->error =
647  "number of tx queues must be <= %u and <= number of "
648  "CPU's assigned to VPP", VMXNET3_TXQ_MAX);
649  vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default, "%U: %s",
650  format_vlib_pci_addr, &args->addr,
651  "number of tx queues must be <= %u and <= number of "
652  "CPU's assigned to VPP", VMXNET3_TXQ_MAX);
653  return;
654  }
655  if (args->rxq_size == 0)
657  if (args->txq_size == 0)
659 
660  if (!vmxnet3_queue_size_valid (args->rxq_size) ||
662  {
663  args->rv = VNET_API_ERROR_INVALID_VALUE;
664  args->error =
666  "queue size must be <= 4096, >= 64, "
667  "and multiples of 64");
668  vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default, "%U: %s",
669  format_vlib_pci_addr, &args->addr,
670  "queue size must be <= 4096, >= 64, and multiples of 64");
671  return;
672  }
673 
674  /* *INDENT-OFF* */
675  pool_foreach (vd, vmxm->devices) {
676  if (vd->pci_addr.as_u32 == args->addr.as_u32)
677  {
678  args->rv = VNET_API_ERROR_ADDRESS_IN_USE;
679  args->error =
681  &args->addr, "pci address in use");
682  vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default, "%U: %s",
683  format_vlib_pci_addr, &args->addr, "pci address in use");
684  return;
685  }
686  }
687  /* *INDENT-ON* */
688 
689  if (args->bind)
690  {
691  error = vlib_pci_bind_to_uio (vm, &args->addr, (char *) "auto");
692  if (error)
693  {
694  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
695  args->error =
697  &args->addr,
698  "error encountered on binding pci device");
699  vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default, "%U: %s",
700  format_vlib_pci_addr, &args->addr,
701  "error encountered on binding pci devicee");
702  return;
703  }
704  }
705 
706  if ((error =
708  {
709  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
710  args->error =
712  &args->addr,
713  "error encountered on pci device open");
714  vlib_log (VLIB_LOG_LEVEL_ERR, vmxm->log_default, "%U: %s",
715  format_vlib_pci_addr, &args->addr,
716  "error encountered on pci device open");
717  return;
718  }
719 
720  /*
721  * Do not use vmxnet3_log_error prior to this line since the macro
722  * references vd->pci_dev_handle
723  */
724  pool_get (vmxm->devices, vd);
725  vd->num_tx_queues = args->txq_num;
726  vd->num_rx_queues = args->rxq_num;
727  vd->dev_instance = vd - vmxm->devices;
728  vd->per_interface_next_index = ~0;
729  vd->pci_addr = args->addr;
730 
731  if (args->enable_elog)
732  vd->flags |= VMXNET3_DEVICE_F_ELOG;
733 
734  vd->pci_dev_handle = h;
736  vd->num_intrs = vd->num_rx_queues + 1; // +1 for the event interrupt
737 
739 
741  {
742  vmxnet3_log_error (vd, "error encountered on pci bus master enable");
743  goto error;
744  }
745 
746  if ((error = vlib_pci_map_region (vm, h, 0, (void **) &vd->bar[0])))
747  {
748  vmxnet3_log_error (vd, "error encountered on pci map region for bar 0");
749  goto error;
750  }
751 
752  if ((error = vlib_pci_map_region (vm, h, 1, (void **) &vd->bar[1])))
753  {
754  vmxnet3_log_error (vd, "error encountered on pci map region for bar 1");
755  goto error;
756  }
757 
758  num_intr = vlib_pci_get_num_msix_interrupts (vm, h);
759  if (num_intr < vd->num_rx_queues + 1)
760  {
761  vmxnet3_log_error (vd,
762  "No sufficient interrupt lines (%u) for rx queues",
763  num_intr);
764  error =
766  "No sufficient interrupt lines (%u) for rx queues",
767  num_intr);
768  goto error;
769  }
772  {
773  vmxnet3_log_error (vd,
774  "error encountered on pci register msix handler 0");
775  goto error;
776  }
777 
780  {
781  vmxnet3_log_error (vd,
782  "error encountered on pci register msix handler 1");
783  goto error;
784  }
785 
786  if ((error = vlib_pci_enable_msix_irq (vm, h, 0, vd->num_rx_queues + 1)))
787  {
788  vmxnet3_log_error (vd, "error encountered on pci enable msix irq");
789  goto error;
790  }
791 
792  if ((error = vlib_pci_intr_enable (vm, h)))
793  {
794  vmxnet3_log_error (vd, "error encountered on pci interrupt enable");
795  goto error;
796  }
797 
798  if ((error = vmxnet3_device_init (vm, vd, args)))
799  {
800  vmxnet3_log_error (vd, "error encountered on device init");
801  goto error;
802  }
803 
804  /* create interface */
806  vd->dev_instance, vd->mac_addr,
808 
809  if (error)
810  {
811  vmxnet3_log_error (vd,
812  "error encountered on ethernet register interface");
813  goto error;
814  }
815 
817  vd->sw_if_index = sw->sw_if_index;
818  args->sw_if_index = sw->sw_if_index;
819 
822  if (vd->gso_enable)
823  {
827  }
828 
830  /* Disable interrupts */
832  vec_foreach_index (qid, vd->rxqs)
833  {
834  vmxnet3_rxq_t *rxq = vec_elt_at_index (vd->rxqs, qid);
835  u32 qi, fi;
837 
838  qi = vnet_hw_if_register_rx_queue (vnm, vd->hw_if_index, qid,
842  rxq->queue_index = qi;
843  rxq->thread_index =
845  if (rxq->mode == VNET_HW_IF_RX_MODE_POLLING)
846  {
847  ptd = vec_elt_at_index (vmxm->per_thread_data, rxq->thread_index);
848  ptd->polling_q_count++;
849  }
850  rxq->buffer_pool_index =
852  vmxnet3_rxq_refill_ring0 (vm, vd, rxq);
853  vmxnet3_rxq_refill_ring1 (vm, vd, rxq);
854  }
855 
856  vec_foreach_index (qid, vd->txqs)
857  {
858  vmxnet3_txq_t *txq = vec_elt_at_index (vd->txqs, qid);
859  txq->queue_index =
861  }
862  for (u32 i = 0; i < vlib_get_n_threads (); i++)
863  {
864  u32 qi = vd->txqs[i % vd->num_tx_queues].queue_index;
866  }
868 
869  vd->flags |= VMXNET3_DEVICE_F_INITIALIZED;
871 
873  vd->link_speed * 1000);
874  if (vd->flags & VMXNET3_DEVICE_F_LINK_UP)
877  else
879  return;
880 
881 error:
882  vmxnet3_delete_if (vm, vd);
883  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
884  args->error = error;
885 }
886 
887 void
889 {
890  vnet_main_t *vnm = vnet_get_main ();
891  vmxnet3_main_t *vmxm = &vmxnet3_main;
892  u32 i, bi;
893  u16 desc_idx;
894 
895  /* Quiesce the device */
896  vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_QUIESCE_DEV);
897 
898  /* Reset the device */
899  vmxnet3_reg_write (vd, 1, VMXNET3_REG_CMD, VMXNET3_CMD_RESET_DEV);
900 
901  if (vd->hw_if_index)
902  {
905  }
906 
908 
909  /* *INDENT-OFF* */
910  vec_foreach_index (i, vd->rxqs)
911  {
912  vmxnet3_rxq_t *rxq = vec_elt_at_index (vd->rxqs, i);
913  u16 mask = rxq->size - 1;
914  u16 rid;
917 
918  if (rxq->mode == VNET_HW_IF_RX_MODE_POLLING)
919  {
920  ASSERT (ptd->polling_q_count != 0);
921  ptd->polling_q_count--;
922  }
923  for (rid = 0; rid < VMXNET3_RX_RING_SIZE; rid++)
924  {
925  vmxnet3_rx_ring *ring;
926 
927  ring = &rxq->rx_ring[rid];
928  desc_idx = (ring->consume + 1) & mask;
929  vlib_buffer_free_from_ring (vm, ring->bufs, desc_idx, rxq->size,
930  ring->fill);
931  vec_free (ring->bufs);
932  vlib_physmem_free (vm, rxq->rx_desc[rid]);
933  }
934  vlib_physmem_free (vm, rxq->rx_comp);
935  }
936  /* *INDENT-ON* */
937  vec_free (vd->rxqs);
938  vec_free (vd->rx_stats);
939 
940  /* *INDENT-OFF* */
941  vec_foreach_index (i, vd->txqs)
942  {
943  vmxnet3_txq_t *txq = vec_elt_at_index (vd->txqs, i);
944  u16 mask = txq->size - 1;
945  u16 end_idx;
946 
947  desc_idx = txq->tx_ring.consume;
948  end_idx = txq->tx_ring.produce;
949  while (desc_idx != end_idx)
950  {
951  bi = txq->tx_ring.bufs[desc_idx];
952  vlib_buffer_free_no_next (vm, &bi, 1);
953  desc_idx++;
954  desc_idx &= mask;
955  }
956  clib_spinlock_free (&txq->lock);
957  vec_free (txq->tx_ring.bufs);
958  vlib_physmem_free (vm, txq->tx_desc);
959  vlib_physmem_free (vm, txq->tx_comp);
960  }
961  /* *INDENT-ON* */
962  vec_free (vd->txqs);
963  vec_free (vd->tx_stats);
964 
966  vlib_physmem_free (vm, vd->queues);
967  vlib_physmem_free (vm, vd->rss);
968 
969  clib_error_free (vd->error);
970  clib_memset (vd, 0, sizeof (*vd));
971  pool_put (vmxm->devices, vd);
972 
973 }
974 
975 /*
976  * fd.io coding-style-patch-verification: ON
977  *
978  * Local Variables:
979  * eval: (c-set-style "gnu")
980  * End:
981  */
vmxnet3_main
vmxnet3_main_t vmxnet3_main
Definition: vmxnet3.c:29
vmxnet3_device_t::gso_enable
u8 gso_enable
Definition: vmxnet3.h:594
vmxnet3_device_t::dev_instance
u32 dev_instance
Definition: vmxnet3.h:569
vlib.h
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
vmxnet3_device_t::flags
u32 flags
Definition: vmxnet3.h:566
vlib_pci_set_private_data
void vlib_pci_set_private_data(vlib_main_t *vm, vlib_pci_dev_handle_t h, uword private_data)
Definition: pci.c:155
VNET_HW_IF_RXQ_THREAD_ANY
#define VNET_HW_IF_RXQ_THREAD_ANY
Definition: interface.h:598
foreach_vmxnet3_tx_func_error
#define foreach_vmxnet3_tx_func_error
Definition: vmxnet3.h:19
VMXNET3_MTU
#define VMXNET3_MTU
Definition: vmxnet3.h:116
VMXNET3_GOS_BITS_32
#define VMXNET3_GOS_BITS_32
Definition: vmxnet3.h:172
vmxnet3_rx_ring::gen
u32 gen
Definition: vmxnet3.h:499
vmxnet3_rxq_refill_ring1
static_always_inline clib_error_t * vmxnet3_rxq_refill_ring1(vlib_main_t *vm, vmxnet3_device_t *vd, vmxnet3_rxq_t *rxq)
Definition: vmxnet3.h:744
vmxnet3_device_t::num_rx_queues
u16 num_rx_queues
Definition: vmxnet3.h:582
format_vmxnet3_device_name
format_function_t format_vmxnet3_device_name
Definition: vmxnet3.h:641
vmxnet3_create_if
void vmxnet3_create_if(vlib_main_t *vm, vmxnet3_create_if_args_t *args)
Definition: vmxnet3.c:616
vmxnet3_dma_addr
static_always_inline uword vmxnet3_dma_addr(vlib_main_t *vm, vmxnet3_device_t *vd, void *p)
Definition: vmxnet3.h:680
VMXNET3_NUM_TX_DESC
#define VMXNET3_NUM_TX_DESC
Definition: vmxnet3.h:160
vmxnet3_create_if_args_t::bind
u8 bind
Definition: vmxnet3.h:617
VMXNET3_REG_VRRS
#define VMXNET3_REG_VRRS
Definition: vmxnet3.h:104
vmxnet3_interface_admin_up_down
static clib_error_t * vmxnet3_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: vmxnet3.c:39
vnet_sw_interface_t
Definition: interface.h:869
vnet_hw_interface_t::caps
vnet_hw_interface_capabilities_t caps
Definition: interface.h:645
vmxnet3_rx_ring::rid
u16 rid
Definition: vmxnet3.h:501
vmxnet3_device_t::pci_dev_handle
vlib_pci_dev_handle_t pci_dev_handle
Definition: vmxnet3.h:573
vlib_node_add_next
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1177
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
VMXNET3_RXCF_GEN
#define VMXNET3_RXCF_GEN
Definition: vmxnet3.h:129
vmxnet3_rxq_refill_ring0
static_always_inline clib_error_t * vmxnet3_rxq_refill_ring0(vlib_main_t *vm, vmxnet3_device_t *vd, vmxnet3_rxq_t *rxq)
Definition: vmxnet3.h:698
types.h
vmxnet3_txq_t::lock
clib_spinlock_t lock
Definition: vmxnet3.h:555
vmxnet3_rxq_t::queue_index
u32 queue_index
Definition: vmxnet3.h:525
vmxnet3_reg_read
static_always_inline u32 vmxnet3_reg_read(vmxnet3_device_t *vd, u8 bar, u32 addr)
Definition: vmxnet3.h:669
vnet_hw_if_get_rx_queue_numa_node
static_always_inline u8 vnet_hw_if_get_rx_queue_numa_node(vnet_main_t *vnm, u32 queue_index)
Definition: rx_queue_funcs.h:84
vmxnet3_rx_ring::fill
u16 fill
Definition: vmxnet3.h:500
vlib_pci_get_numa_node
u32 vlib_pci_get_numa_node(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.c:170
vmxnet3_txq_t::tx_comp
vmxnet3_tx_comp * tx_comp
Definition: vmxnet3.h:558
pool_elt_at_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:549
VMXNET3_REG_TXPROD
#define VMXNET3_REG_TXPROD
Definition: vmxnet3.h:98
vmxnet3_event_irq_handler
static void vmxnet3_event_irq_handler(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 line)
Definition: vmxnet3.c:560
count_leading_zeros
#define count_leading_zeros(x)
Definition: clib.h:160
vmxnet3_device_t::tx_stats
vmxnet3_tx_stats * tx_stats
Definition: vmxnet3.h:595
vmxnet3_rss_init
static clib_error_t * vmxnet3_rss_init(vlib_main_t *vm, vmxnet3_device_t *vd)
Definition: vmxnet3.c:385
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
VMXNET3_RXQ_MAX
#define VMXNET3_RXQ_MAX
Definition: vmxnet3.h:91
vlib_pci_dev_handle_t
u32 vlib_pci_dev_handle_t
Definition: pci.h:97
vlib_pci_enable_msix_irq
clib_error_t * vlib_pci_enable_msix_irq(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 start, u16 count)
Definition: pci.c:895
VMXNET3_REG_MACL
#define VMXNET3_REG_MACL
Definition: vmxnet3.h:109
vmxnet3_device_t::pci_addr
vlib_pci_addr_t pci_addr
Definition: vmxnet3.h:574
vmxnet3_reg_write
static_always_inline void vmxnet3_reg_write(vmxnet3_device_t *vd, u8 bar, u32 addr, u32 val)
Definition: vmxnet3.h:662
vnet_hw_if_tx_queue_assign_thread
void vnet_hw_if_tx_queue_assign_thread(vnet_main_t *vnm, u32 queue_index, u32 thread_index)
Definition: tx_queue.c:109
vmxnet3_create_if_args_t::addr
vlib_pci_addr_t addr
Definition: vmxnet3.h:611
VMXNET3_RSS_MAX_KEY_SZ
#define VMXNET3_RSS_MAX_KEY_SZ
Definition: vmxnet3.h:87
u16
unsigned short u16
Definition: types.h:57
mode
vl_api_tunnel_mode_t mode
Definition: gre.api:48
vmxnet3_device_t::mac_addr
u8 mac_addr[6]
Definition: vmxnet3.h:586
vlib_physmem_free
static void vlib_physmem_free(vlib_main_t *vm, void *p)
Definition: physmem_funcs.h:89
VNET_SW_INTERFACE_FLAG_ADMIN_UP
@ VNET_SW_INTERFACE_FLAG_ADMIN_UP
Definition: interface.h:844
pool_put
#define pool_put(P, E)
Free an object E in pool P.
Definition: pool.h:305
VNET_HW_IF_RX_MODE_POLLING
@ VNET_HW_IF_RX_MODE_POLLING
Definition: interface.h:56
vmxnet3_interface_rx_mode_change
static clib_error_t * vmxnet3_interface_rx_mode_change(vnet_main_t *vnm, u32 hw_if_index, u32 qid, vnet_hw_if_rx_mode mode)
Definition: vmxnet3.c:65
vmxnet3_pci_device_ids
static pci_device_id_t vmxnet3_pci_device_ids[]
Definition: vmxnet3.c:31
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vmxnet3_main_t
Definition: vmxnet3.h:599
node_index
node node_index
Definition: interface_output.c:440
VMXNET3_RX_START
#define VMXNET3_RX_START(vd)
Definition: vmxnet3.h:93
VNET_HW_INTERFACE_FLAG_LINK_UP
@ VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:509
vmxnet3_device_t::error
clib_error_t * error
Definition: vmxnet3.h:588
vlib_pci_register_msix_handler
clib_error_t * vlib_pci_register_msix_handler(vlib_main_t *vm, vlib_pci_dev_handle_t h, u32 start, u32 count, pci_msix_handler_function_t *msix_handler)
Definition: pci.c:838
VMXNET3_TXQ_MAX
#define VMXNET3_TXQ_MAX
Definition: vmxnet3.h:90
vlib_pci_bind_to_uio
clib_error_t * vlib_pci_bind_to_uio(vlib_main_t *vm, vlib_pci_addr_t *addr, char *uio_drv_name)
Definition: pci.c:397
hi
vl_api_ip4_address_t hi
Definition: arp.api:37
vnet_hw_interface_set_link_speed
static void vnet_hw_interface_set_link_speed(vnet_main_t *vnm, u32 hw_if_index, u32 link_speed)
Definition: interface_funcs.h:372
vmxnet3_rxq_init
static clib_error_t * vmxnet3_rxq_init(vlib_main_t *vm, vmxnet3_device_t *vd, u16 qid, u16 qsz)
Definition: vmxnet3.c:289
vmxnet3_rxq_t::thread_index
u32 thread_index
Definition: vmxnet3.h:526
vnet_hw_interface_t::dev_instance
u32 dev_instance
Definition: interface.h:660
vmxnet3_device_t::queues
void * queues
Definition: vmxnet3.h:591
vlib_pci_map_region
clib_error_t * vlib_pci_map_region(vlib_main_t *vm, vlib_pci_dev_handle_t h, u32 resource, void **result)
Definition: pci.c:1182
pci_device_id_t::vendor_id
u16 vendor_id
Definition: pci.h:127
ethernet.h
VMXNET3_REG_DSAL
#define VMXNET3_REG_DSAL
Definition: vmxnet3.h:106
h
h
Definition: flowhash_template.h:372
error
Definition: cJSON.c:88
vmxnet3_set_interface_next_node
static void vmxnet3_set_interface_next_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Definition: vmxnet3.c:94
vmxnet3_create_if_args_t::rxq_size
u16 rxq_size
Definition: vmxnet3.h:613
vlib_pci_intr_enable
static clib_error_t * vlib_pci_intr_enable(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.h:239
vmxnet3_rxq_t::size
u16 size
Definition: vmxnet3.h:522
VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_TCP_CKSUM
Definition: interface.h:524
vlib_pci_bus_master_enable
static clib_error_t * vlib_pci_bus_master_enable(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.h:271
vnet_sw_interface_t::sw_if_index
u32 sw_if_index
Definition: interface.h:876
vlib_thread_main_t::n_vlib_mains
u32 n_vlib_mains
Definition: threads.h:262
vlib_buffer_free_from_ring
static void vlib_buffer_free_from_ring(vlib_main_t *vm, u32 *ring, u32 start, u32 ring_size, u32 n_buffers)
Free buffers from ring.
Definition: buffer_funcs.h:1026
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
vlib_pci_get_private_data
uword vlib_pci_get_private_data(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.c:148
vmxnet3_rx_ring
Definition: vmxnet3.h:495
vmxnet3_rxq_irq_handler
static void vmxnet3_rxq_irq_handler(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 line)
Definition: vmxnet3.c:541
vmxnet3_create_if_args_t::rv
i32 rv
Definition: vmxnet3.h:620
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
format_vnet_hw_if_rx_mode
format_function_t format_vnet_hw_if_rx_mode
Definition: interface_funcs.h:453
vmxnet3_rxq_t::buffer_pool_index
u8 buffer_pool_index
Definition: vmxnet3.h:524
vmxnet3_create_if_args_t
Definition: vmxnet3.h:609
vmxnet3_write_mac
static void vmxnet3_write_mac(vmxnet3_device_t *vd)
Definition: vmxnet3.c:170
vmxnet3_create_if_args_t::txq_num
u16 txq_num
Definition: vmxnet3.h:616
VMXNET3_GOS_BITS_64
#define VMXNET3_GOS_BITS_64
Definition: vmxnet3.h:173
VMXNET3_REG_CMD
#define VMXNET3_REG_CMD
Definition: vmxnet3.h:108
VMXNET3_IC_DISABLE_ALL
#define VMXNET3_IC_DISABLE_ALL
Definition: vmxnet3.h:170
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
vnet_get_hw_interface
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:44
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
vmxnet3_clear_hw_interface_counters
static void vmxnet3_clear_hw_interface_counters(u32 instance)
Definition: vmxnet3.c:114
VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO
Definition: interface.h:537
VMXNET3_UPT_VERSION_SELECT
#define VMXNET3_UPT_VERSION_SELECT
Definition: vmxnet3.h:168
vmxnet3_rss_key
static const u8 vmxnet3_rss_key[VMXNET3_RSS_MAX_KEY_SZ]
Definition: vmxnet3.c:376
VMXNET3_VERSION_SELECT
#define VMXNET3_VERSION_SELECT
Definition: vmxnet3.h:167
vmxnet3_main_t::log_default
vlib_log_class_t log_default
Definition: vmxnet3.h:603
rx_queue_funcs.h
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
vnet_hw_if_rx_mode
vnet_hw_if_rx_mode
Definition: interface.h:53
vmxnet3_txq_t::tx_comp_ring
vmxnet3_tx_comp_ring tx_comp_ring
Definition: vmxnet3.h:560
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
uword
u64 uword
Definition: types.h:112
vmxnet3_rx_ring::bufs
u32 * bufs
Definition: vmxnet3.h:498
vnet_hw_if_update_runtime_data
void vnet_hw_if_update_runtime_data(vnet_main_t *vnm, u32 hw_if_index)
Definition: runtime.c:58
vmxnet3_rxq_t::rx_comp_ring
vmxnet3_rx_comp_ring rx_comp_ring
Definition: vmxnet3.h:530
vmxnet3_device_t::driver_shared
vmxnet3_shared * driver_shared
Definition: vmxnet3.h:590
vmxnet3_tx_ring::produce
u16 produce
Definition: vmxnet3.h:538
vmxnet3_rx_ring::consume
u16 consume
Definition: vmxnet3.h:503
vmxnet3_device_init
static clib_error_t * vmxnet3_device_init(vlib_main_t *vm, vmxnet3_device_t *vd, vmxnet3_create_if_args_t *args)
Definition: vmxnet3.c:411
VNET_HW_IF_RX_MODE_INTERRUPT
@ VNET_HW_IF_RX_MODE_INTERRUPT
Definition: interface.h:57
vmxnet3_main_t::per_thread_data
vmxnet3_per_thread_data_t * per_thread_data
Definition: vmxnet3.h:604
vmxnet3_queue_size_valid
static u8 vmxnet3_queue_size_valid(u16 qsz)
Definition: vmxnet3.c:588
VMXNET3_REG_UVRS
#define VMXNET3_REG_UVRS
Definition: vmxnet3.h:105
VMXNET3_GOS_TYPE_LINUX
#define VMXNET3_GOS_TYPE_LINUX
Definition: vmxnet3.h:174
clib_spinlock_free
static void clib_spinlock_free(clib_spinlock_t *p)
Definition: lock.h:72
mask
vl_api_pnat_mask_t mask
Definition: pnat.api:45
vmxnet3_rxq_t::mode
u32 mode
Definition: vmxnet3.h:523
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
vmxnet3_rx_comp_ring::gen
u32 gen
Definition: vmxnet3.h:509
vec_validate
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment)
Definition: vec.h:523
vnet_hw_if_rx_queue_set_int_pending
static_always_inline void vnet_hw_if_rx_queue_set_int_pending(vnet_main_t *vnm, u32 queue_index)
Definition: rx_queue_funcs.h:52
VMXNET3_REG_IMR
#define VMXNET3_REG_IMR
Definition: vmxnet3.h:97
vmxnet3_device_t::bar
void * bar[2]
Definition: vmxnet3.h:575
VMXNET3_RSS_HASH_FUNC_TOEPLITZ
#define VMXNET3_RSS_HASH_FUNC_TOEPLITZ
Definition: vmxnet3.h:86
vmxnet3_create_if_args_t::txq_size
u16 txq_size
Definition: vmxnet3.h:615
VMXNET3_REG_MACH
#define VMXNET3_REG_MACH
Definition: vmxnet3.h:110
clib_min
#define clib_min(x, y)
Definition: clib.h:342
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
vlib_pci_get_num_msix_interrupts
u32 vlib_pci_get_num_msix_interrupts(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.c:177
vnet_hw_if_set_rx_queue_file_index
void vnet_hw_if_set_rx_queue_file_index(vnet_main_t *vnm, u32 queue_index, u32 file_index)
Definition: rx_queue.c:144
vmxnet3_device_t::num_intrs
u16 num_intrs
Definition: vmxnet3.h:583
vmxnet3_rxq_t::rx_comp
vmxnet3_rx_comp * rx_comp
Definition: vmxnet3.h:529
vmxnet3_disable_interrupt
static void vmxnet3_disable_interrupt(vmxnet3_device_t *vd)
Definition: vmxnet3.c:278
vmxnet3_device_t::rss
vmxnet3_rss_shared * rss
Definition: vmxnet3.h:592
vmxnet3_provision_driver_shared
static clib_error_t * vmxnet3_provision_driver_shared(vlib_main_t *vm, vmxnet3_device_t *vd)
Definition: vmxnet3.c:183
plugin.h
format_vmxnet3_device
format_function_t format_vmxnet3_device
Definition: vmxnet3.h:640
vmxnet3_tx_comp_ring::gen
u32 gen
Definition: vmxnet3.h:545
vmxnet3_enable_interrupt
static void vmxnet3_enable_interrupt(vmxnet3_device_t *vd)
Definition: vmxnet3.c:267
VMXNET3_RX_RING_SIZE
#define VMXNET3_RX_RING_SIZE
Definition: vmxnet3.h:158
VMXNET3_SHARED_MAGIC
#define VMXNET3_SHARED_MAGIC
Definition: vmxnet3.h:166
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
size
u32 size
Definition: vhost_user.h:125
VNET_DEVICE_CLASS
VNET_DEVICE_CLASS(vmxnet3_device_class,)
vmxnet3_device_t::per_interface_next_index
u32 per_interface_next_index
Definition: vmxnet3.h:567
format_vlib_pci_addr
format_function_t format_vlib_pci_addr
Definition: pci.h:326
u64
unsigned long u64
Definition: types.h:89
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vmxnet3_device_t::rxqs
vmxnet3_rxq_t * rxqs
Definition: vmxnet3.h:578
VMXNET3_TXF_GEN
#define VMXNET3_TXF_GEN
Definition: vmxnet3.h:146
vmxnet3_txq_t::tx_ring
vmxnet3_tx_ring tx_ring
Definition: vmxnet3.h:559
vmxnet3_create_if_args_t::enable_elog
u32 enable_elog
Definition: vmxnet3.h:612
VMXNET3_RSS_MAX_IND_TABLE_SZ
#define VMXNET3_RSS_MAX_IND_TABLE_SZ
Definition: vmxnet3.h:88
vnet_get_hw_sw_interface
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface_funcs.h:72
u32
unsigned int u32
Definition: types.h:88
vmxnet3_txq_t
Definition: vmxnet3.h:549
ethernet_delete_interface
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:393
vmxnet3_create_if_args_t::sw_if_index
u32 sw_if_index
Definition: vmxnet3.h:621
vlib_thread_main_t
Definition: threads.h:243
VMXNET3_VERSION_MAGIC
#define VMXNET3_VERSION_MAGIC
Definition: vmxnet3.h:165
VMXNET3_TX_N_ERROR
@ VMXNET3_TX_N_ERROR
Definition: vmxnet3.h:29
vlib_buffer_free_no_next
static void vlib_buffer_free_no_next(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers, does not free the buffer chain for each buffer.
Definition: buffer_funcs.h:996
vmxnet3_rx_queue_num_valid
static u8 vmxnet3_rx_queue_num_valid(u16 num)
Definition: vmxnet3.c:608
vmxnet3_tx_queue_num_valid
static u8 vmxnet3_tx_queue_num_valid(u16 num)
Definition: vmxnet3.c:598
vmxnet3_rxq_t::rx_ring
vmxnet3_rx_ring rx_ring[VMXNET3_RX_RING_SIZE]
Definition: vmxnet3.h:527
pci.h
VMXNET3_NUM_RX_DESC
#define VMXNET3_NUM_RX_DESC
Definition: vmxnet3.h:162
instance
u32 instance
Definition: gre.api:51
vmxnet3_tx_ring::bufs
u32 * bufs
Definition: vmxnet3.h:536
vmxnet3_device_t::rx_stats
vmxnet3_rx_stats * rx_stats
Definition: vmxnet3.h:596
vmxnet3_flag_change
static u32 vmxnet3_flag_change(vnet_main_t *vnm, vnet_hw_interface_t *hw, u32 flags)
Definition: vmxnet3.c:164
vmxnet3_per_thread_data_t::polling_q_count
u32 polling_q_count
Definition: vmxnet3.h:516
PCI_DEVICE_ID_VMWARE_VMXNET3
#define PCI_DEVICE_ID_VMWARE_VMXNET3
Definition: vmxnet3.c:27
vmxnet3_log_error
#define vmxnet3_log_error(dev, f,...)
Definition: vmxnet3.h:649
vlib_log
void vlib_log(vlib_log_level_t level, vlib_log_class_t class, char *fmt,...)
Definition: log.c:131
VMXNET3_TXCF_GEN
#define VMXNET3_TXCF_GEN
Definition: vmxnet3.h:155
PCI_VENDOR_ID_VMWARE
#define PCI_VENDOR_ID_VMWARE
Definition: vmxnet3.c:26
vmxnet3_create_if_args_t::enable_gso
u8 enable_gso
Definition: vmxnet3.h:618
vmxnet3_device_t::txqs
vmxnet3_txq_t * txqs
Definition: vmxnet3.h:579
vmxnet3_device_t::sw_if_index
u32 sw_if_index
Definition: vmxnet3.h:570
vlib_physmem_last_error
static clib_error_t * vlib_physmem_last_error(struct vlib_main_t *vm)
Definition: physmem_funcs.h:110
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
vlib_get_n_threads
static u32 vlib_get_n_threads()
Definition: global_funcs.h:23
vnet_hw_if_register_rx_queue
u32 vnet_hw_if_register_rx_queue(vnet_main_t *vnm, u32 hw_if_index, u32 queue_id, u32 thread_index)
Definition: rx_queue.c:64
vmxnet3_rxq_t
Definition: vmxnet3.h:519
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vnet_hw_interface_set_flags
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
Definition: interface.c:513
vmxnet3_create_if_args_t::error
clib_error_t * error
Definition: vmxnet3.h:622
VMXNET3_REG_DSAH
#define VMXNET3_REG_DSAH
Definition: vmxnet3.h:107
vlib_pci_get_msix_file_index
uword vlib_pci_get_msix_file_index(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 index)
Definition: pci.c:917
i
int i
Definition: flowhash_template.h:376
VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TX_UDP_CKSUM
Definition: interface.h:525
vlib_physmem_alloc_aligned_on_numa
static void * vlib_physmem_alloc_aligned_on_numa(vlib_main_t *vm, uword n_bytes, uword alignment, u32 numa_node)
Definition: physmem_funcs.h:63
VMXNET3_RXF_GEN
#define VMXNET3_RXF_GEN
Definition: vmxnet3.h:119
vmxnet3_txq_t::tx_desc
vmxnet3_tx_desc * tx_desc
Definition: vmxnet3.h:557
vlib_pci_device_open
clib_error_t * vlib_pci_device_open(vlib_main_t *vm, vlib_pci_addr_t *addr, pci_device_id_t ids[], vlib_pci_dev_handle_t *handle)
Definition: pci.c:1251
VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE
@ VNET_HW_INTERFACE_CAP_SUPPORTS_INT_MODE
Definition: interface.h:550
clib_error_free
#define clib_error_free(e)
Definition: error.h:86
vmxnet3_txq_t::queue_index
u32 queue_index
Definition: vmxnet3.h:553
vmxnet3_device_t::numa_node
u32 numa_node
Definition: vmxnet3.h:572
tx_queue_funcs.h
vmxnet3_delete_if
void vmxnet3_delete_if(vlib_main_t *vm, vmxnet3_device_t *vd)
Definition: vmxnet3.c:888
vmxnet3_device_t::link_speed
u32 link_speed
Definition: vmxnet3.h:593
vmxnet3_tx_func_error_strings
static char * vmxnet3_tx_func_error_strings[]
Definition: vmxnet3.c:142
vlib_pci_device_close
void vlib_pci_device_close(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.c:1311
vmxnet3_per_thread_data_t
Definition: vmxnet3.h:513
vmxnet3_txq_init
static clib_error_t * vmxnet3_txq_init(vlib_main_t *vm, vmxnet3_device_t *vd, u16 qid, u16 qsz)
Definition: vmxnet3.c:336
vmxnet3_txq_t::reg_txprod
u32 reg_txprod
Definition: vmxnet3.h:554
vmxnet3_input_node
vlib_node_registration_t vmxnet3_input_node
(constructor) VLIB_REGISTER_NODE (vmxnet3_input_node)
Definition: input.c:491
vnet_hw_if_get_rx_queue_thread_index
static_always_inline u32 vnet_hw_if_get_rx_queue_thread_index(vnet_main_t *vnm, u32 queue_index)
Definition: rx_queue_funcs.h:92
vnet_hw_if_register_tx_queue
u32 vnet_hw_if_register_tx_queue(vnet_main_t *vnm, u32 hw_if_index, u32 queue_id)
Definition: tx_queue.c:35
vlib_get_thread_main
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:56
vmxnet3_device_t::version
u8 version
Definition: vmxnet3.h:585
vmxnet3_txq_t::size
u16 size
Definition: vmxnet3.h:552
vmxnet3_device_t
Definition: vmxnet3.h:563
vmxnet3_device_t::num_tx_queues
u16 num_tx_queues
Definition: vmxnet3.h:581
vmxnet3_tx_ring::gen
u32 gen
Definition: vmxnet3.h:537
vmxnet3_main_t::devices
vmxnet3_device_t * devices
Definition: vmxnet3.h:601
uword_bits
#define uword_bits
Definition: types.h:102
ethernet_register_interface
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
Definition: interface.c:348
vmxnet3.h
vnet_hw_if_set_input_node
void vnet_hw_if_set_input_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Definition: rx_queue.c:157
VMXNET3_TX_START
#define VMXNET3_TX_START(vd)
Definition: vmxnet3.h:92
vmxnet3_device_t::hw_if_index
u32 hw_if_index
Definition: vmxnet3.h:571
vmxnet3_create_if_args_t::rxq_num
u16 rxq_num
Definition: vmxnet3.h:614
vmxnet3_rxq_t::rx_desc
vmxnet3_rx_desc * rx_desc[VMXNET3_RX_RING_SIZE]
Definition: vmxnet3.h:528
pci_device_id_t
Definition: pci.h:125
vmxnet3_device_class
vnet_device_class_t vmxnet3_device_class
vmxnet3_tx_ring::consume
u16 consume
Definition: vmxnet3.h:539
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105