FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
device.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2018 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17 
18 #include <vlib/vlib.h>
19 #include <vppinfra/ring.h>
20 #include <vlib/unix/unix.h>
21 #include <vlib/pci/pci.h>
22 #include <vnet/ethernet/ethernet.h>
25 
26 #include <avf/avf.h>
27 
28 #define AVF_MBOX_LEN 64
29 #define AVF_MBOX_BUF_SZ 4096
30 #define AVF_RXQ_SZ 512
31 #define AVF_TXQ_SZ 512
32 #define AVF_ITR_INT 250
33 
34 #define PCI_VENDOR_ID_INTEL 0x8086
35 #define PCI_DEVICE_ID_INTEL_AVF 0x1889
36 #define PCI_DEVICE_ID_INTEL_X710_VF 0x154c
37 #define PCI_DEVICE_ID_INTEL_X722_VF 0x37cd
38 
40  .class_name = "avf",
41 };
42 
44  .class_name = "avf",
45  .subclass_name = "stats",
46 };
47 
49 void avf_delete_if (vlib_main_t * vm, avf_device_t * ad, int with_barrier);
50 
53  {.vendor_id = PCI_VENDOR_ID_INTEL,.device_id = PCI_DEVICE_ID_INTEL_X710_VF},
54  {.vendor_id = PCI_VENDOR_ID_INTEL,.device_id = PCI_DEVICE_ID_INTEL_X722_VF},
55  {0},
56 };
57 
58 const static char *virtchnl_event_names[] = {
59 #define _(v, n) [v] = #n,
61 #undef _
62 };
63 
64 typedef enum
65 {
70 
71 static inline void
73 {
74  u32 dyn_ctl0 = 0, icr0_ena = 0;
75 
76  dyn_ctl0 |= (3 << 3); /* 11b = No ITR update */
77 
78  avf_reg_write (ad, AVFINT_ICR0_ENA1, icr0_ena);
79  avf_reg_write (ad, AVFINT_DYN_CTL0, dyn_ctl0);
80  avf_reg_flush (ad);
81 
83  return;
84 
85  dyn_ctl0 = 0;
86  icr0_ena = 0;
87 
88  icr0_ena |= (1 << 30); /* [30] Admin Queue Enable */
89 
90  dyn_ctl0 |= (1 << 0); /* [0] Interrupt Enable */
91  dyn_ctl0 |= (1 << 1); /* [1] Clear PBA */
92  dyn_ctl0 |= (2 << 3); /* [4:3] ITR Index, 11b = No ITR update */
93  dyn_ctl0 |= ((AVF_ITR_INT / 2) << 5); /* [16:5] ITR Interval in 2us steps */
94 
95  avf_reg_write (ad, AVFINT_ICR0_ENA1, icr0_ena);
96  avf_reg_write (ad, AVFINT_DYN_CTL0, dyn_ctl0);
97  avf_reg_flush (ad);
98 }
99 
100 static inline void
102 {
103  u32 dyn_ctln = 0;
104 
105  /* disable */
106  avf_reg_write (ad, AVFINT_DYN_CTLN (line), dyn_ctln);
107  avf_reg_flush (ad);
108 
110  return;
111 
112  dyn_ctln |= (1 << 1); /* [1] Clear PBA */
114  {
115  /* minimal ITR interval, use ITR1 */
116  dyn_ctln |= (1 << 3); /* [4:3] ITR Index */
117  dyn_ctln |= ((32 / 2) << 5); /* [16:5] ITR Interval in 2us steps */
118  dyn_ctln |= (1 << 30); /* [30] Writeback on ITR */
119  }
120  else
121  {
122  /* configured ITR interval, use ITR0 */
123  dyn_ctln |= (1 << 0); /* [0] Interrupt Enable */
124  dyn_ctln |= ((AVF_ITR_INT / 2) << 5); /* [16:5] ITR Interval in 2us steps */
125  }
126 
127  avf_reg_write (ad, AVFINT_DYN_CTLN (line), dyn_ctln);
128  avf_reg_flush (ad);
129 }
130 
131 
132 clib_error_t *
134  void *data, int len)
135 {
136  clib_error_t *err = 0;
137  avf_aq_desc_t *d, dc;
138  f64 t0, suspend_time = AVF_AQ_ENQ_SUSPEND_TIME;
139 
140  d = &ad->atq[ad->atq_next_slot];
141  clib_memcpy_fast (d, dt, sizeof (avf_aq_desc_t));
142  d->flags |= AVF_AQ_F_RD | AVF_AQ_F_SI;
143  if (len)
144  d->datalen = len;
145  if (len)
146  {
147  u64 pa;
148  pa = ad->atq_bufs_pa + ad->atq_next_slot * AVF_MBOX_BUF_SZ;
149  d->addr_hi = (u32) (pa >> 32);
150  d->addr_lo = (u32) pa;
152  data, len);
153  d->flags |= AVF_AQ_F_BUF;
154  }
155 
156  if (ad->flags & AVF_DEVICE_F_ELOG)
157  clib_memcpy_fast (&dc, d, sizeof (avf_aq_desc_t));
158 
160  ad->atq_next_slot = (ad->atq_next_slot + 1) % AVF_MBOX_LEN;
162  avf_reg_flush (ad);
163 
164  t0 = vlib_time_now (vm);
165 retry:
166  vlib_process_suspend (vm, suspend_time);
167 
168  if (((d->flags & AVF_AQ_F_DD) == 0) || ((d->flags & AVF_AQ_F_CMP) == 0))
169  {
170  f64 t = vlib_time_now (vm) - t0;
171  if (t > AVF_AQ_ENQ_MAX_WAIT_TIME)
172  {
173  avf_log_err (ad, "aq_desc_enq failed (timeout %.3fs)", t);
174  err = clib_error_return (0, "adminq enqueue timeout [opcode 0x%x]",
175  d->opcode);
176  goto done;
177  }
178  suspend_time *= 2;
179  goto retry;
180  }
181 
182  clib_memcpy_fast (dt, d, sizeof (avf_aq_desc_t));
183  if (d->flags & AVF_AQ_F_ERR)
184  return clib_error_return (0, "adminq enqueue error [opcode 0x%x, retval "
185  "%d]", d->opcode, d->retval);
186 
187 done:
188  if (ad->flags & AVF_DEVICE_F_ELOG)
189  {
190  ELOG_TYPE_DECLARE (el) =
191  {
192  .format = "avf[%d] aq enq: s_flags 0x%x r_flags 0x%x opcode 0x%x "
193  "datalen %d retval %d",
194  .format_args = "i4i2i2i2i2i2",
195  };
196  struct
197  {
198  u32 dev_instance;
199  u16 s_flags;
200  u16 r_flags;
201  u16 opcode;
202  u16 datalen;
203  u16 retval;
204  } *ed;
206  ed->dev_instance = ad->dev_instance;
207  ed->s_flags = dc.flags;
208  ed->r_flags = d->flags;
209  ed->opcode = dc.opcode;
210  ed->datalen = dc.datalen;
211  ed->retval = d->retval;
212  }
213 
214  return err;
215 }
216 
217 clib_error_t *
219  u32 val)
220 {
221  clib_error_t *err;
222  avf_aq_desc_t d = {.opcode = 0x207,.param1 = reg,.param3 = val };
223  err = avf_aq_desc_enq (vm, ad, &d, 0, 0);
224 
225  if (ad->flags & AVF_DEVICE_F_ELOG)
226  {
227  ELOG_TYPE_DECLARE (el) =
228  {
229  .format = "avf[%d] rx ctl reg write: reg 0x%x val 0x%x ",
230  .format_args = "i4i4i4",
231  };
232  struct
233  {
234  u32 dev_instance;
235  u32 reg;
236  u32 val;
237  } *ed;
239  ed->dev_instance = ad->dev_instance;
240  ed->reg = reg;
241  ed->val = val;
242  }
243  return err;
244 }
245 
246 clib_error_t *
247 avf_rxq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 rxq_size)
248 {
249  clib_error_t *err;
250  avf_rxq_t *rxq;
251  u32 n_alloc, i;
252 
254  rxq = vec_elt_at_index (ad->rxqs, qid);
255  rxq->size = rxq_size;
256  rxq->next = 0;
258  sizeof (avf_rx_desc_t),
260  ad->numa_node);
261 
262  rxq->buffer_pool_index =
264 
265  if (rxq->descs == 0)
266  return vlib_physmem_last_error (vm);
267 
268  if ((err = vlib_pci_map_dma (vm, ad->pci_dev_handle, (void *) rxq->descs)))
269  return err;
270 
271  clib_memset ((void *) rxq->descs, 0, rxq->size * sizeof (avf_rx_desc_t));
273  rxq->qrx_tail = ad->bar0 + AVF_QRX_TAIL (qid);
274 
275  n_alloc = vlib_buffer_alloc_from_pool (vm, rxq->bufs, rxq->size - 8,
276  rxq->buffer_pool_index);
277 
278  if (n_alloc == 0)
279  return clib_error_return (0, "buffer allocation error");
280 
281  rxq->n_enqueued = n_alloc;
282  avf_rx_desc_t *d = rxq->descs;
283  for (i = 0; i < n_alloc; i++)
284  {
285  vlib_buffer_t *b = vlib_get_buffer (vm, rxq->bufs[i]);
286  if (ad->flags & AVF_DEVICE_F_VA_DMA)
287  d->qword[0] = vlib_buffer_get_va (b);
288  else
289  d->qword[0] = vlib_buffer_get_pa (vm, b);
290  d++;
291  }
292 
293  return 0;
294 }
295 
296 clib_error_t *
297 avf_txq_init (vlib_main_t * vm, avf_device_t * ad, u16 qid, u16 txq_size)
298 {
299  clib_error_t *err;
300  avf_txq_t *txq;
301  u16 n;
303  ad->numa_node);
304 
306  txq = vec_elt_at_index (ad->txqs, qid);
307  txq->size = txq_size;
308  txq->next = 0;
309  clib_spinlock_init (&txq->lock);
310 
311  /* Prepare a placeholder buffer(s) to maintain a 1-1 relationship between
312  * bufs and descs when a context descriptor is added in descs. Worst case
313  * every second descriptor is context descriptor and due to b->ref_count
314  * being u8 we need one for each block of 510 descriptors */
315 
316  n = (txq->size / 510) + 1;
318 
319  if (!vlib_buffer_alloc_from_pool (vm, txq->ph_bufs, n, bpi))
320  return clib_error_return (0, "buffer allocation error");
321 
323  sizeof (avf_tx_desc_t),
325  ad->numa_node);
326  if (txq->descs == 0)
327  return vlib_physmem_last_error (vm);
328 
329  if ((err = vlib_pci_map_dma (vm, ad->pci_dev_handle, (void *) txq->descs)))
330  return err;
331 
333  txq->qtx_tail = ad->bar0 + AVF_QTX_TAIL (qid);
334 
335  /* initialize ring of pending RS slots */
337 
340 
341  return 0;
342 }
343 
344 typedef struct
345 {
349 
350 void
352 {
353  avf_aq_desc_t *d;
354  u64 pa = ad->arq_bufs_pa + slot * AVF_MBOX_BUF_SZ;
355  d = &ad->arq[slot];
356  clib_memset (d, 0, sizeof (avf_aq_desc_t));
357  d->flags = AVF_AQ_F_BUF;
359  d->addr_hi = (u32) (pa >> 32);
360  d->addr_lo = (u32) pa;
361 }
362 
363 static inline uword
365 {
366  return (ad->flags & AVF_DEVICE_F_VA_DMA) ?
368 }
369 
370 static void
372 {
373  u64 pa;
374  int i;
375 
376  /* VF MailBox Transmit */
377  clib_memset (ad->atq, 0, sizeof (avf_aq_desc_t) * AVF_MBOX_LEN);
378  ad->atq_bufs_pa = avf_dma_addr (vm, ad, ad->atq_bufs);
379 
380  pa = avf_dma_addr (vm, ad, ad->atq);
381  avf_reg_write (ad, AVF_ATQT, 0); /* Tail */
382  avf_reg_write (ad, AVF_ATQH, 0); /* Head */
383  avf_reg_write (ad, AVF_ATQLEN, AVF_MBOX_LEN | (1ULL << 31)); /* len & ena */
384  avf_reg_write (ad, AVF_ATQBAL, (u32) pa); /* Base Address Low */
385  avf_reg_write (ad, AVF_ATQBAH, (u32) (pa >> 32)); /* Base Address High */
386 
387  /* VF MailBox Receive */
388  clib_memset (ad->arq, 0, sizeof (avf_aq_desc_t) * AVF_MBOX_LEN);
389  ad->arq_bufs_pa = avf_dma_addr (vm, ad, ad->arq_bufs);
390 
391  for (i = 0; i < AVF_MBOX_LEN; i++)
392  avf_arq_slot_init (ad, i);
393 
394  pa = avf_dma_addr (vm, ad, ad->arq);
395 
396  avf_reg_write (ad, AVF_ARQH, 0); /* Head */
397  avf_reg_write (ad, AVF_ARQT, 0); /* Head */
398  avf_reg_write (ad, AVF_ARQLEN, AVF_MBOX_LEN | (1ULL << 31)); /* len & ena */
399  avf_reg_write (ad, AVF_ARQBAL, (u32) pa); /* Base Address Low */
400  avf_reg_write (ad, AVF_ARQBAH, (u32) (pa >> 32)); /* Base Address High */
401  avf_reg_write (ad, AVF_ARQT, AVF_MBOX_LEN - 1); /* Tail */
402 
403  ad->atq_next_slot = 0;
404  ad->arq_next_slot = 0;
405 }
406 
407 clib_error_t *
409  void *in, int in_len, void *out, int out_len)
410 {
411  clib_error_t *err;
412  avf_aq_desc_t *d, dt = {.opcode = 0x801,.v_opcode = op };
413  u32 head;
414  f64 t0, suspend_time = AVF_SEND_TO_PF_SUSPEND_TIME;
415 
416  /* adminq operations should be only done from process node after device
417  * is initialized */
418  ASSERT ((ad->flags & AVF_DEVICE_F_INITIALIZED) == 0 ||
420 
421  /* suppress interrupt in the next adminq receive slot
422  as we are going to wait for response
423  we only need interrupts when event is received */
424  d = &ad->arq[ad->arq_next_slot];
425  d->flags |= AVF_AQ_F_SI;
426 
427  if ((err = avf_aq_desc_enq (vm, ad, &dt, in, in_len)))
428  return err;
429 
430  t0 = vlib_time_now (vm);
431 retry:
432  head = avf_get_u32 (ad->bar0, AVF_ARQH);
433 
434  if (ad->arq_next_slot == head)
435  {
436  f64 t = vlib_time_now (vm) - t0;
438  {
439  avf_log_err (ad, "send_to_pf failed (timeout %.3fs)", t);
440  return clib_error_return (0, "timeout");
441  }
442  vlib_process_suspend (vm, suspend_time);
443  suspend_time *= 2;
444  goto retry;
445  }
446 
447  d = &ad->arq[ad->arq_next_slot];
448 
449  if (d->v_opcode == VIRTCHNL_OP_EVENT)
450  {
451  void *buf = ad->arq_bufs + ad->arq_next_slot * AVF_MBOX_BUF_SZ;
453 
454  if ((d->datalen != sizeof (virtchnl_pf_event_t)) ||
455  ((d->flags & AVF_AQ_F_BUF) == 0))
456  return clib_error_return (0, "event message error");
457 
458  vec_add2 (ad->events, e, 1);
461  ad->arq_next_slot++;
462  /* reset timer */
463  t0 = vlib_time_now (vm);
464  suspend_time = AVF_SEND_TO_PF_SUSPEND_TIME;
465  goto retry;
466  }
467 
468  if (d->v_opcode != op)
469  {
470  err = clib_error_return (0,
471  "unexpected message received [v_opcode = %u, "
472  "expected %u, v_retval %d]",
473  d->v_opcode, op, d->v_retval);
474  goto done;
475  }
476 
477  if (d->v_retval)
478  {
479  err = clib_error_return (0, "error [v_opcode = %u, v_retval %d]",
480  d->v_opcode, d->v_retval);
481  goto done;
482  }
483 
484  if (out_len && d->flags & AVF_AQ_F_BUF)
485  {
486  void *buf = ad->arq_bufs + ad->arq_next_slot * AVF_MBOX_BUF_SZ;
487  clib_memcpy_fast (out, buf, out_len);
488  }
489 
492  avf_reg_flush (ad);
493  ad->arq_next_slot = (ad->arq_next_slot + 1) % AVF_MBOX_LEN;
494 
495 done:
496 
497  if (ad->flags & AVF_DEVICE_F_ELOG)
498  {
499  ELOG_TYPE_DECLARE (el) =
500  {
501  .format = "avf[%d] send to pf: v_opcode %s (%d) v_retval 0x%x",
502  .format_args = "i4t4i4i4",
503  .n_enum_strings = VIRTCHNL_N_OPS,
504  .enum_strings = {
505 #define _(v, n) [v] = #n,
507 #undef _
508  },
509  };
510  struct
511  {
512  u32 dev_instance;
513  u32 v_opcode;
514  u32 v_opcode_val;
515  u32 v_retval;
516  } *ed;
518  ed->dev_instance = ad->dev_instance;
519  ed->v_opcode = op;
520  ed->v_opcode_val = op;
521  ed->v_retval = d->v_retval;
522  }
523  return err;
524 }
525 
526 clib_error_t *
529 {
530  clib_error_t *err = 0;
531  virtchnl_version_info_t myver = {
533  .minor = VIRTCHNL_VERSION_MINOR,
534  };
535 
536  avf_log_debug (ad, "version: major %u minor %u", myver.major, myver.minor);
537 
538  err = avf_send_to_pf (vm, ad, VIRTCHNL_OP_VERSION, &myver,
539  sizeof (virtchnl_version_info_t), ver,
540  sizeof (virtchnl_version_info_t));
541 
542  if (err)
543  return err;
544 
545  return err;
546 }
547 
548 clib_error_t *
551 {
552  clib_error_t *err = 0;
553  u32 bitmap = (VIRTCHNL_VF_OFFLOAD_L2 | VIRTCHNL_VF_OFFLOAD_RSS_PF |
554  VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | VIRTCHNL_VF_OFFLOAD_VLAN |
555  VIRTCHNL_VF_OFFLOAD_RX_POLLING |
556  VIRTCHNL_VF_CAP_ADV_LINK_SPEED | VIRTCHNL_VF_OFFLOAD_FDIR_PF |
557  VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF | VIRTCHNL_VF_OFFLOAD_VLAN_V2);
558 
559  avf_log_debug (ad, "get_vf_resources: bitmap 0x%x (%U)", bitmap,
560  format_avf_vf_cap_flags, bitmap);
561  err = avf_send_to_pf (vm, ad, VIRTCHNL_OP_GET_VF_RESOURCES, &bitmap,
562  sizeof (u32), res, sizeof (virtchnl_vf_resource_t));
563 
564  if (err == 0)
565  {
566  int i;
567  avf_log_debug (ad,
568  "get_vf_resources: num_vsis %u num_queue_pairs %u "
569  "max_vectors %u max_mtu %u vf_cap_flags 0x%x (%U) "
570  "rss_key_size %u rss_lut_size %u",
571  res->num_vsis, res->num_queue_pairs, res->max_vectors,
573  res->vf_cap_flags, res->rss_key_size, res->rss_lut_size);
574  for (i = 0; i < res->num_vsis; i++)
575  avf_log_debug (
576  ad,
577  "get_vf_resources_vsi[%u]: vsi_id %u num_queue_pairs %u vsi_type %u "
578  "qset_handle %u default_mac_addr %U",
579  i, res->vsi_res[i].vsi_id, res->vsi_res[i].num_queue_pairs,
580  res->vsi_res[i].vsi_type, res->vsi_res[i].qset_handle,
582  }
583 
584  return err;
585 }
586 
587 clib_error_t *
589 {
590  int msg_len = sizeof (virtchnl_rss_lut_t) + ad->rss_lut_size - 1;
591  int i;
592  u8 msg[msg_len];
593  virtchnl_rss_lut_t *rl;
594 
595  clib_memset (msg, 0, msg_len);
596  rl = (virtchnl_rss_lut_t *) msg;
597  rl->vsi_id = ad->vsi_id;
598  rl->lut_entries = ad->rss_lut_size;
599  for (i = 0; i < ad->rss_lut_size; i++)
600  rl->lut[i] = i % ad->n_rx_queues;
601 
602  avf_log_debug (ad, "config_rss_lut: vsi_id %u rss_lut_size %u lut 0x%U",
603  rl->vsi_id, rl->lut_entries, format_hex_bytes_no_wrap,
604  rl->lut, rl->lut_entries);
605 
606  return avf_send_to_pf (vm, ad, VIRTCHNL_OP_CONFIG_RSS_LUT, msg, msg_len, 0,
607  0);
608 }
609 
610 clib_error_t *
612 {
613  /* from DPDK i40e... */
614  static uint32_t rss_key_default[] = { 0x6b793944, 0x23504cb5, 0x5bea75b6,
615  0x309f4f12, 0x3dc0a2b8, 0x024ddcdf,
616  0x339b8ca0, 0x4c4af64a, 0x34fac605,
617  0x55d85839, 0x3a58997d, 0x2ec938e1,
618  0x66031581 };
619  int msg_len = sizeof (virtchnl_rss_key_t) + ad->rss_key_size - 1;
620  u8 msg[msg_len];
621  virtchnl_rss_key_t *rk;
622 
623  if (sizeof (rss_key_default) != ad->rss_key_size)
624  return clib_error_create ("unsupported RSS key size (expected %d, got %d)",
625  sizeof (rss_key_default), ad->rss_key_size);
626 
627  clib_memset (msg, 0, msg_len);
628  rk = (virtchnl_rss_key_t *) msg;
629  rk->vsi_id = ad->vsi_id;
630  rk->key_len = ad->rss_key_size;
631  memcpy_s (rk->key, rk->key_len, rss_key_default, sizeof (rss_key_default));
632 
633  avf_log_debug (ad, "config_rss_key: vsi_id %u rss_key_size %u key 0x%U",
634  rk->vsi_id, rk->key_len, format_hex_bytes_no_wrap, rk->key,
635  rk->key_len);
636 
637  return avf_send_to_pf (vm, ad, VIRTCHNL_OP_CONFIG_RSS_KEY, msg, msg_len, 0,
638  0);
639 }
640 
641 clib_error_t *
643 {
644  avf_log_debug (ad, "disable_vlan_stripping");
645 
646  return avf_send_to_pf (vm, ad, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING, 0, 0, 0,
647  0);
648 }
649 
650 clib_error_t *
652  int is_enable)
653 {
654  virtchnl_promisc_info_t pi = { 0 };
655 
656  pi.vsi_id = ad->vsi_id;
657 
658  if (is_enable)
659  pi.flags = FLAG_VF_UNICAST_PROMISC | FLAG_VF_MULTICAST_PROMISC;
660 
661  avf_log_debug (ad, "config_promisc_mode: unicast %s multicast %s",
662  pi.flags & FLAG_VF_UNICAST_PROMISC ? "on" : "off",
663  pi.flags & FLAG_VF_MULTICAST_PROMISC ? "on" : "off");
664 
665  return avf_send_to_pf (vm, ad, VIRTCHNL_OP_CONFIG_PROMISCUOUS_MODE, &pi,
666  sizeof (virtchnl_promisc_info_t), 0, 0);
667 }
668 
669 
670 clib_error_t *
672 {
673  int i;
674  int n_qp = clib_max (vec_len (ad->rxqs), vec_len (ad->txqs));
675  int msg_len = sizeof (virtchnl_vsi_queue_config_info_t) + n_qp *
677  u8 msg[msg_len];
679 
680  clib_memset (msg, 0, msg_len);
682  ci->vsi_id = ad->vsi_id;
683  ci->num_queue_pairs = n_qp;
684 
685  avf_log_debug (ad, "config_vsi_queues: vsi_id %u num_queue_pairs %u",
686  ad->vsi_id, ci->num_queue_pairs);
687 
688  for (i = 0; i < n_qp; i++)
689  {
690  virtchnl_txq_info_t *txq = &ci->qpair[i].txq;
691  virtchnl_rxq_info_t *rxq = &ci->qpair[i].rxq;
692 
693  rxq->vsi_id = ad->vsi_id;
694  rxq->queue_id = i;
696  if (i < vec_len (ad->rxqs))
697  {
698  avf_rxq_t *q = vec_elt_at_index (ad->rxqs, i);
699  rxq->ring_len = q->size;
701  rxq->dma_ring_addr = avf_dma_addr (vm, ad, (void *) q->descs);
702  avf_reg_write (ad, AVF_QRX_TAIL (i), q->size - 1);
703  }
704  avf_log_debug (ad, "config_vsi_queues_rx[%u]: max_pkt_size %u "
705  "ring_len %u databuffer_size %u dma_ring_addr 0x%llx",
706  i, rxq->max_pkt_size, rxq->ring_len,
707  rxq->databuffer_size, rxq->dma_ring_addr);
708 
709  txq->vsi_id = ad->vsi_id;
710  txq->queue_id = i;
711  if (i < vec_len (ad->txqs))
712  {
713  avf_txq_t *q = vec_elt_at_index (ad->txqs, i);
714  txq->ring_len = q->size;
715  txq->dma_ring_addr = avf_dma_addr (vm, ad, (void *) q->descs);
716  }
717  avf_log_debug (ad, "config_vsi_queues_tx[%u]: ring_len %u "
718  "dma_ring_addr 0x%llx", i, txq->ring_len,
719  txq->dma_ring_addr);
720  }
721 
722  return avf_send_to_pf (vm, ad, VIRTCHNL_OP_CONFIG_VSI_QUEUES, msg, msg_len,
723  0, 0);
724 }
725 
726 clib_error_t *
728 {
729  int msg_len = sizeof (virtchnl_irq_map_info_t) +
730  (ad->n_rx_irqs) * sizeof (virtchnl_vector_map_t);
731  u8 msg[msg_len];
733 
734  clib_memset (msg, 0, msg_len);
735  imi = (virtchnl_irq_map_info_t *) msg;
736  imi->num_vectors = ad->n_rx_irqs;
737 
738  for (int i = 0; i < ad->n_rx_irqs; i++)
739  {
740  imi->vecmap[i].vector_id = i + 1;
741  imi->vecmap[i].vsi_id = ad->vsi_id;
742  if (ad->n_rx_irqs == ad->n_rx_queues)
743  imi->vecmap[i].rxq_map = 1 << i;
744  else
745  imi->vecmap[i].rxq_map = pow2_mask (ad->n_rx_queues);;
746 
747  avf_log_debug (ad, "config_irq_map[%u/%u]: vsi_id %u vector_id %u "
748  "rxq_map %u", i, ad->n_rx_irqs - 1, ad->vsi_id,
749  imi->vecmap[i].vector_id, imi->vecmap[i].rxq_map);
750  }
751 
752 
753  return avf_send_to_pf (vm, ad, VIRTCHNL_OP_CONFIG_IRQ_MAP, msg, msg_len, 0,
754  0);
755 }
756 
757 clib_error_t *
759  u8 * macs, int is_add)
760 {
761  int msg_len =
762  sizeof (virtchnl_ether_addr_list_t) +
763  count * sizeof (virtchnl_ether_addr_t);
764  u8 msg[msg_len];
766  int i;
767 
768  clib_memset (msg, 0, msg_len);
769  al = (virtchnl_ether_addr_list_t *) msg;
770  al->vsi_id = ad->vsi_id;
771  al->num_elements = count;
772 
773  avf_log_debug (ad, "add_del_eth_addr: vsi_id %u num_elements %u is_add %u",
774  ad->vsi_id, al->num_elements, is_add);
775 
776  for (i = 0; i < count; i++)
777  {
778  clib_memcpy_fast (&al->list[i].addr, macs + i * 6, 6);
779  avf_log_debug (ad, "add_del_eth_addr[%u]: %U", i,
781  }
782  return avf_send_to_pf (vm, ad, is_add ? VIRTCHNL_OP_ADD_ETH_ADDR :
783  VIRTCHNL_OP_DEL_ETH_ADDR, msg, msg_len, 0, 0);
784 }
785 
786 clib_error_t *
788 {
789  virtchnl_queue_select_t qs = { 0 };
790  int i = 0;
791  qs.vsi_id = ad->vsi_id;
792  qs.rx_queues = rx;
793  qs.tx_queues = tx;
794 
795  avf_log_debug (ad, "enable_queues: vsi_id %u rx_queues %u tx_queues %u",
796  ad->vsi_id, qs.rx_queues, qs.tx_queues);
797 
798  while (rx)
799  {
800  if (rx & (1 << i))
801  {
802  avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, i);
803  avf_reg_write (ad, AVF_QRX_TAIL (i), rxq->n_enqueued);
804  rx &= ~(1 << i);
805  }
806  i++;
807  }
808  return avf_send_to_pf (vm, ad, VIRTCHNL_OP_ENABLE_QUEUES, &qs,
809  sizeof (virtchnl_queue_select_t), 0, 0);
810 }
811 
812 clib_error_t *
815 {
816  virtchnl_queue_select_t qs = { 0 };
817  clib_error_t *err;
818  qs.vsi_id = ad->vsi_id;
819 
820  err = avf_send_to_pf (vm, ad, VIRTCHNL_OP_GET_STATS, &qs,
821  sizeof (virtchnl_queue_select_t), es,
822  sizeof (virtchnl_eth_stats_t));
823 
824  avf_stats_log_debug (ad, "get_stats: vsi_id %u\n %U", ad->vsi_id,
826 
827  return err;
828 }
829 
830 clib_error_t *
833 {
834  clib_error_t *err;
835 
836  err = avf_send_to_pf (vm, ad, VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS, 0, 0, vc,
837  sizeof (virtchnl_vlan_caps_t));
838 
839  avf_log_debug (ad, "get_offload_vlan_v2_caps:\n%U%U", format_white_space, 16,
841 
842  return err;
843 }
844 
845 clib_error_t *
847  u32 inner)
848 {
850  .outer_ethertype_setting = outer,
851  .inner_ethertype_setting = inner,
852  .vport_id = ad->vsi_id,
853  };
854 
855  avf_log_debug (ad, "disable_vlan_stripping_v2: outer: %U, inner %U",
857  inner);
858 
859  return avf_send_to_pf (vm, ad, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2, &vs,
860  sizeof (virtchnl_vlan_setting_t), 0, 0);
861 }
862 
863 clib_error_t *
865 {
866  avf_aq_desc_t d = { 0 };
868  u32 rstat;
869  f64 t0, t = 0, suspend_time = AVF_RESET_SUSPEND_TIME;
870 
871  avf_log_debug (ad, "reset");
872 
873  d.opcode = 0x801;
874  d.v_opcode = VIRTCHNL_OP_RESET_VF;
875  if ((error = avf_aq_desc_enq (vm, ad, &d, 0, 0)))
876  return error;
877 
878  t0 = vlib_time_now (vm);
879 retry:
880  vlib_process_suspend (vm, suspend_time);
881 
882  rstat = avf_get_u32 (ad->bar0, AVFGEN_RSTAT);
883 
884  if (rstat == 2 || rstat == 3)
885  {
886  avf_log_debug (ad, "reset completed in %.3fs", t);
887  return 0;
888  }
889 
890  t = vlib_time_now (vm) - t0;
891  if (t > AVF_RESET_MAX_WAIT_TIME)
892  {
893  avf_log_err (ad, "reset failed (timeout %.3fs)", t);
894  return clib_error_return (0, "reset failed (timeout)");
895  }
896 
897  suspend_time *= 2;
898  goto retry;
899 }
900 
901 clib_error_t *
903 {
904  virtchnl_vf_res_request_t res_req = { 0 };
906  u32 rstat;
907  f64 t0, t, suspend_time = AVF_RESET_SUSPEND_TIME;
908 
909  res_req.num_queue_pairs = num_queue_pairs;
910 
911  avf_log_debug (ad, "request_queues: num_queue_pairs %u", num_queue_pairs);
912 
913  error = avf_send_to_pf (vm, ad, VIRTCHNL_OP_REQUEST_QUEUES, &res_req,
914  sizeof (virtchnl_vf_res_request_t), &res_req,
915  sizeof (virtchnl_vf_res_request_t));
916 
917  /*
918  * if PF responds, the request failed
919  * else PF initializes restart and avf_send_to_pf returns an error
920  */
921  if (!error)
922  {
923  return clib_error_return (0, "requested more than %u queue pairs",
924  res_req.num_queue_pairs);
925  }
926 
927  t0 = vlib_time_now (vm);
928 retry:
929  vlib_process_suspend (vm, suspend_time);
930  t = vlib_time_now (vm) - t0;
931 
932  rstat = avf_get_u32 (ad->bar0, AVFGEN_RSTAT);
933 
934  if ((rstat == VIRTCHNL_VFR_COMPLETED) || (rstat == VIRTCHNL_VFR_VFACTIVE))
935  goto done;
936 
937  if (t > AVF_RESET_MAX_WAIT_TIME)
938  {
939  avf_log_err (ad, "request queues failed (timeout %.3f seconds)", t);
940  return clib_error_return (0, "request queues failed (timeout)");
941  }
942 
943  suspend_time *= 2;
944  goto retry;
945 
946 done:
947  return NULL;
948 }
949 
950 clib_error_t *
952  avf_create_if_args_t * args)
953 {
954  virtchnl_version_info_t ver = { 0 };
955  virtchnl_vf_resource_t res = { 0 };
957  int i, wb_on_itr;
958  u16 rxq_num, txq_num;
959 
960  avf_adminq_init (vm, ad);
961 
962  rxq_num = args->rxq_num ? args->rxq_num : 1;
963  txq_num = args->txq_num ? args->txq_num : vlib_get_n_threads ();
964 
965  if ((error = avf_request_queues (vm, ad, clib_max (txq_num, rxq_num))))
966  {
967  /* we failed to get more queues, but still we want to proceed */
969 
970  if ((error = avf_device_reset (vm, ad)))
971  return error;
972  }
973 
974  avf_adminq_init (vm, ad);
975 
976  /*
977  * OP_VERSION
978  */
979  if ((error = avf_op_version (vm, ad, &ver)))
980  return error;
981 
982  if (ver.major != VIRTCHNL_VERSION_MAJOR ||
984  return clib_error_return (0, "incompatible protocol version "
985  "(remote %d.%d)", ver.major, ver.minor);
986 
987  /*
988  * OP_GET_VF_RESOURCES
989  */
990  if ((error = avf_op_get_vf_resources (vm, ad, &res)))
991  return error;
992 
993  if (res.num_vsis != 1 || res.vsi_res[0].vsi_type != VIRTCHNL_VSI_SRIOV)
994  return clib_error_return (0, "unexpected GET_VF_RESOURCE reply received");
995 
996  ad->vsi_id = res.vsi_res[0].vsi_id;
997  ad->cap_flags = res.vf_cap_flags;
999  ad->n_rx_queues = clib_min (rxq_num, res.num_queue_pairs);
1000  ad->n_tx_queues = clib_min (txq_num, res.num_queue_pairs);
1001  ad->max_vectors = res.max_vectors;
1002  ad->max_mtu = res.max_mtu;
1003  ad->rss_key_size = res.rss_key_size;
1004  ad->rss_lut_size = res.rss_lut_size;
1005  ad->n_rx_irqs = ad->max_vectors > ad->n_rx_queues ? ad->n_rx_queues : 1;
1006 
1007  if (ad->max_vectors > ad->n_rx_queues)
1008  ad->flags |= AVF_DEVICE_F_RX_INT;
1009 
1010  wb_on_itr = (ad->cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR) != 0;
1011 
1013 
1014  if (args->rxq_num != 0 && ad->n_rx_queues != args->rxq_num)
1015  return clib_error_return (0,
1016  "Number of requested RX queues (%u) is "
1017  "higher than mumber of available queues (%u)",
1018  args->rxq_num, ad->num_queue_pairs);
1019 
1020  if (args->txq_num != 0 && ad->n_tx_queues != args->txq_num)
1021  return clib_error_return (0,
1022  "Number of requested TX queues (%u) is "
1023  "higher than mumber of available queues (%u)",
1024  args->txq_num, ad->num_queue_pairs);
1025 
1026  /*
1027  * Disable VLAN stripping
1028  */
1029  if (ad->cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN_V2)
1030  {
1031  virtchnl_vlan_caps_t vc = {};
1033  u32 mask = VIRTCHNL_VLAN_ETHERTYPE_8100;
1034 
1035  if ((error = avf_op_get_offload_vlan_v2_caps (vm, ad, &vc)))
1036  return error;
1037 
1038  outer = vc.offloads.stripping_support.outer & mask;
1039  inner = vc.offloads.stripping_support.inner & mask;
1040 
1041  if ((outer || inner) &&
1042  (error = avf_op_disable_vlan_stripping_v2 (vm, ad, outer, inner)))
1043  return error;
1044  }
1045  else if ((error = avf_op_disable_vlan_stripping (vm, ad)))
1046  return error;
1047 
1048  /*
1049  * Init Queues
1050  */
1051  for (i = 0; i < ad->n_rx_queues; i++)
1052  if ((error = avf_rxq_init (vm, ad, i, args->rxq_size)))
1053  return error;
1054 
1055  for (i = 0; i < ad->n_tx_queues; i++)
1056  if ((error = avf_txq_init (vm, ad, i, args->txq_size)))
1057  return error;
1058 
1059  if ((ad->cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) &&
1060  (error = avf_op_config_rss_lut (vm, ad)))
1061  return error;
1062 
1063  if ((ad->cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) &&
1064  (error = avf_op_config_rss_key (vm, ad)))
1065  return error;
1066 
1067  if ((error = avf_op_config_vsi_queues (vm, ad)))
1068  return error;
1069 
1070  if ((error = avf_op_config_irq_map (vm, ad)))
1071  return error;
1072 
1074 
1075  for (i = 0; i < ad->n_rx_irqs; i++)
1076  avf_irq_n_set_state (ad, i, wb_on_itr ? AVF_IRQ_STATE_WB_ON_ITR :
1078 
1079  if ((error = avf_op_add_del_eth_addr (vm, ad, 1, ad->hwaddr, 1 /* add */ )))
1080  return error;
1081 
1082  if ((error = avf_op_enable_queues (vm, ad, pow2_mask (ad->n_rx_queues),
1083  pow2_mask (ad->n_tx_queues))))
1084  return error;
1085 
1086  ad->flags |= AVF_DEVICE_F_INITIALIZED;
1087  return error;
1088 }
1089 
1090 void
1092 {
1093  vnet_main_t *vnm = vnet_get_main ();
1095  u32 r;
1096 
1097  if (ad->flags & AVF_DEVICE_F_ERROR)
1098  return;
1099 
1100  if ((ad->flags & AVF_DEVICE_F_INITIALIZED) == 0)
1101  return;
1102 
1103  ASSERT (ad->error == 0);
1104 
1105  /* do not process device in reset state */
1106  r = avf_get_u32 (ad->bar0, AVFGEN_RSTAT);
1107  if (r != VIRTCHNL_VFR_VFACTIVE)
1108  return;
1109 
1110  r = avf_get_u32 (ad->bar0, AVF_ARQLEN);
1111  if ((r & 0xf0000000) != (1ULL << 31))
1112  {
1113  ad->error = clib_error_return (0, "arq not enabled, arqlen = 0x%x", r);
1114  avf_log_err (ad, "error: %U", format_clib_error, ad->error);
1115  goto error;
1116  }
1117 
1118  r = avf_get_u32 (ad->bar0, AVF_ATQLEN);
1119  if ((r & 0xf0000000) != (1ULL << 31))
1120  {
1121  ad->error = clib_error_return (0, "atq not enabled, atqlen = 0x%x", r);
1122  avf_log_err (ad, "error: %U", format_clib_error, ad->error);
1123  goto error;
1124  }
1125 
1126  if (is_irq == 0)
1127  avf_op_get_stats (vm, ad, &ad->eth_stats);
1128 
1129  /* *INDENT-OFF* */
1130  vec_foreach (e, ad->events)
1131  {
1132  avf_log_debug (ad, "event: %s (%u) sev %d",
1134  if (e->event == VIRTCHNL_EVENT_LINK_CHANGE)
1135  {
1136  int link_up;
1137  virtchnl_link_speed_t speed = e->event_data.link_event.link_speed;
1138  u32 flags = 0;
1139  u32 mbps = 0;
1140 
1141  if (ad->cap_flags & VIRTCHNL_VF_CAP_ADV_LINK_SPEED)
1142  link_up = e->event_data.link_event_adv.link_status;
1143  else
1144  link_up = e->event_data.link_event.link_status;
1145 
1146  if (ad->cap_flags & VIRTCHNL_VF_CAP_ADV_LINK_SPEED)
1147  mbps = e->event_data.link_event_adv.link_speed;
1148  if (speed == VIRTCHNL_LINK_SPEED_40GB)
1149  mbps = 40000;
1150  else if (speed == VIRTCHNL_LINK_SPEED_25GB)
1151  mbps = 25000;
1152  else if (speed == VIRTCHNL_LINK_SPEED_10GB)
1153  mbps = 10000;
1154  else if (speed == VIRTCHNL_LINK_SPEED_5GB)
1155  mbps = 5000;
1156  else if (speed == VIRTCHNL_LINK_SPEED_2_5GB)
1157  mbps = 2500;
1158  else if (speed == VIRTCHNL_LINK_SPEED_1GB)
1159  mbps = 1000;
1160  else if (speed == VIRTCHNL_LINK_SPEED_100MB)
1161  mbps = 100;
1162 
1163  avf_log_debug (ad, "event_link_change: status %d speed %u mbps",
1164  link_up, mbps);
1165 
1166  if (link_up && (ad->flags & AVF_DEVICE_F_LINK_UP) == 0)
1167  {
1168  ad->flags |= AVF_DEVICE_F_LINK_UP;
1173  mbps * 1000);
1174  ad->link_speed = mbps;
1175  }
1176  else if (!link_up && (ad->flags & AVF_DEVICE_F_LINK_UP) != 0)
1177  {
1178  ad->flags &= ~AVF_DEVICE_F_LINK_UP;
1179  ad->link_speed = 0;
1180  }
1181 
1182  if (ad->flags & AVF_DEVICE_F_ELOG)
1183  {
1184  ELOG_TYPE_DECLARE (el) =
1185  {
1186  .format = "avf[%d] link change: link_status %d "
1187  "link_speed %d mbps",
1188  .format_args = "i4i1i4",
1189  };
1190  struct
1191  {
1192  u32 dev_instance;
1193  u8 link_status;
1194  u32 link_speed;
1195  } *ed;
1196  ed = ELOG_DATA (&vlib_global_main.elog_main, el);
1197  ed->dev_instance = ad->dev_instance;
1198  ed->link_status = link_up;
1199  ed->link_speed = mbps;
1200  }
1201  }
1202  else
1203  {
1204  if (ad->flags & AVF_DEVICE_F_ELOG)
1205  {
1206  ELOG_TYPE_DECLARE (el) =
1207  {
1208  .format = "avf[%d] unknown event: event %d severity %d",
1209  .format_args = "i4i4i1i1",
1210  };
1211  struct
1212  {
1213  u32 dev_instance;
1214  u32 event;
1215  u32 severity;
1216  } *ed;
1217  ed = ELOG_DATA (&vlib_global_main.elog_main, el);
1218  ed->dev_instance = ad->dev_instance;
1219  ed->event = e->event;
1220  ed->severity = e->severity;
1221  }
1222  }
1223  }
1224  /* *INDENT-ON* */
1225  vec_reset_length (ad->events);
1226 
1227  return;
1228 
1229 error:
1230  ad->flags |= AVF_DEVICE_F_ERROR;
1231  ASSERT (ad->error != 0);
1233 }
1234 
1235 clib_error_t *
1237  u8 *rule, u32 rule_len, u8 *program_status,
1238  u32 status_len)
1239 {
1240  avf_log_debug (ad, "avf_op_program_flow: vsi_id %u is_create %u", ad->vsi_id,
1241  is_create);
1242 
1243  return avf_send_to_pf (vm, ad,
1244  is_create ? VIRTCHNL_OP_ADD_FDIR_FILTER :
1245  VIRTCHNL_OP_DEL_FDIR_FILTER,
1246  rule, rule_len, program_status, status_len);
1247 }
1248 
1249 static void
1251 {
1253 
1255  req->error = avf_op_add_del_eth_addr (vm, ad, 1, req->eth_addr,
1256  req->is_add);
1257  else if (req->type == AVF_PROCESS_REQ_CONFIG_PROMISC_MDDE)
1258  req->error = avf_op_config_promisc_mode (vm, ad, req->is_enable);
1259  else if (req->type == AVF_PROCESS_REQ_PROGRAM_FLOW)
1260  req->error =
1261  avf_op_program_flow (vm, ad, req->is_add, req->rule, req->rule_len,
1262  req->program_status, req->status_len);
1263  else
1264  clib_panic ("BUG: unknown avf proceess request type");
1265 
1266  if (req->calling_process_index != avf_process_node.index)
1268 }
1269 
1270 static clib_error_t *
1272 {
1273  uword *event_data = 0;
1275 
1276  if (req->calling_process_index != avf_process_node.index)
1277  {
1279  AVF_PROCESS_EVENT_REQ, req);
1280 
1282 
1283  if (vlib_process_get_events (vm, &event_data) != 0)
1284  clib_panic ("avf process node failed to reply in 5 seconds");
1285  vec_free (event_data);
1286  }
1287  else
1289 
1290  return req->error;
1291 }
1292 
1293 static u32
1295 {
1296  avf_process_req_t req;
1299  clib_error_t *err;
1300 
1301  switch (flags)
1302  {
1304  ad->flags &= ~AVF_DEVICE_F_PROMISC;
1305  break;
1307  ad->flags |= AVF_DEVICE_F_PROMISC;
1308  break;
1309  default:
1310  return ~0;
1311  }
1312 
1313  req.is_enable = ((ad->flags & AVF_DEVICE_F_PROMISC) != 0);
1315  req.dev_instance = hw->dev_instance;
1316 
1317  if ((err = avf_process_request (vm, &req)))
1318  {
1319  avf_log_err (ad, "error: %U", format_clib_error, err);
1320  clib_error_free (err);
1321  return ~0;
1322  }
1323  return 0;
1324 }
1325 
1326 static uword
1328 {
1329  avf_main_t *am = &avf_main;
1330  uword *event_data = 0, event_type;
1331  int enabled = 0, irq;
1332  f64 last_run_duration = 0;
1333  f64 last_periodic_time = 0;
1334  avf_device_t **dev_pointers = 0;
1335  u32 i;
1336 
1337  while (1)
1338  {
1339  if (enabled)
1340  vlib_process_wait_for_event_or_clock (vm, 5.0 - last_run_duration);
1341  else
1343 
1344  event_type = vlib_process_get_events (vm, &event_data);
1345  irq = 0;
1346 
1347  switch (event_type)
1348  {
1349  case ~0:
1350  last_periodic_time = vlib_time_now (vm);
1351  break;
1353  enabled = 1;
1354  break;
1356  for (int i = 0; i < vec_len (event_data); i++)
1357  {
1358  avf_device_t *ad = avf_get_device (event_data[i]);
1359  avf_delete_if (vm, ad, /* with_barrier */ 1);
1360  }
1361  if (pool_elts (am->devices) < 1)
1362  enabled = 0;
1363  break;
1365  irq = 1;
1366  break;
1367  case AVF_PROCESS_EVENT_REQ:
1368  for (int i = 0; i < vec_len (event_data); i++)
1369  avf_process_handle_request (vm, (void *) event_data[i]);
1370  break;
1371 
1372  default:
1373  ASSERT (0);
1374  }
1375 
1376  vec_reset_length (event_data);
1377 
1378  if (enabled == 0)
1379  continue;
1380 
1381  /* create local list of device pointers as device pool may grow
1382  * during suspend */
1383  vec_reset_length (dev_pointers);
1384  /* *INDENT-OFF* */
1385  pool_foreach_index (i, am->devices)
1386  {
1387  vec_add1 (dev_pointers, avf_get_device (i));
1388  }
1389 
1390  vec_foreach_index (i, dev_pointers)
1391  {
1392  avf_process_one_device (vm, dev_pointers[i], irq);
1393  };
1394  /* *INDENT-ON* */
1395  last_run_duration = vlib_time_now (vm) - last_periodic_time;
1396  }
1397  return 0;
1398 }
1399 
1400 /* *INDENT-OFF* */
1402  .function = avf_process,
1403  .type = VLIB_NODE_TYPE_PROCESS,
1404  .name = "avf-process",
1405 };
1406 /* *INDENT-ON* */
1407 
1408 static void
1410 {
1412  avf_device_t *ad = avf_get_device (pd);
1413  u32 icr0;
1414 
1415  icr0 = avf_reg_read (ad, AVFINT_ICR0);
1416 
1417  if (ad->flags & AVF_DEVICE_F_ELOG)
1418  {
1419  /* *INDENT-OFF* */
1420  ELOG_TYPE_DECLARE (el) =
1421  {
1422  .format = "avf[%d] irq 0: icr0 0x%x",
1423  .format_args = "i4i4",
1424  };
1425  /* *INDENT-ON* */
1426  struct
1427  {
1428  u32 dev_instance;
1429  u32 icr0;
1430  } *ed;
1431 
1432  ed = ELOG_DATA (&vlib_global_main.elog_main, el);
1433  ed->dev_instance = ad->dev_instance;
1434  ed->icr0 = icr0;
1435  }
1436 
1438 
1439  /* bit 30 - Send/Receive Admin queue interrupt indication */
1440  if (icr0 & (1 << 30))
1443 }
1444 
1445 static void
1447 {
1448  vnet_main_t *vnm = vnet_get_main ();
1450  avf_device_t *ad = avf_get_device (pd);
1451  avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, line - 1);
1452 
1453  if (ad->flags & AVF_DEVICE_F_ELOG)
1454  {
1455  /* *INDENT-OFF* */
1456  ELOG_TYPE_DECLARE (el) =
1457  {
1458  .format = "avf[%d] irq %d: received",
1459  .format_args = "i4i2",
1460  };
1461  /* *INDENT-ON* */
1462  struct
1463  {
1464  u32 dev_instance;
1465  u16 line;
1466  } *ed;
1467 
1468  ed = ELOG_DATA (&vlib_global_main.elog_main, el);
1469  ed->dev_instance = ad->dev_instance;
1470  ed->line = line;
1471  }
1472 
1473  line--;
1474 
1475  if (ad->flags & AVF_DEVICE_F_RX_INT && rxq->int_mode)
1478 }
1479 
1480 void
1481 avf_delete_if (vlib_main_t * vm, avf_device_t * ad, int with_barrier)
1482 {
1483  vnet_main_t *vnm = vnet_get_main ();
1484  avf_main_t *am = &avf_main;
1485  int i;
1486  u32 dev_instance;
1487 
1488  ad->flags &= ~AVF_DEVICE_F_ADMIN_UP;
1489 
1490  if (ad->hw_if_index)
1491  {
1492  if (with_barrier)
1496  if (with_barrier)
1498  }
1499 
1501 
1502  vlib_physmem_free (vm, ad->atq);
1503  vlib_physmem_free (vm, ad->arq);
1504  vlib_physmem_free (vm, ad->atq_bufs);
1505  vlib_physmem_free (vm, ad->arq_bufs);
1506 
1507  /* *INDENT-OFF* */
1508  vec_foreach_index (i, ad->rxqs)
1509  {
1510  avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, i);
1511  vlib_physmem_free (vm, (void *) rxq->descs);
1512  if (rxq->n_enqueued)
1513  vlib_buffer_free_from_ring (vm, rxq->bufs, rxq->next, rxq->size,
1514  rxq->n_enqueued);
1515  vec_free (rxq->bufs);
1516  }
1517  /* *INDENT-ON* */
1518  vec_free (ad->rxqs);
1519 
1520  /* *INDENT-OFF* */
1521  vec_foreach_index (i, ad->txqs)
1522  {
1523  avf_txq_t *txq = vec_elt_at_index (ad->txqs, i);
1524  vlib_physmem_free (vm, (void *) txq->descs);
1525  if (txq->n_enqueued)
1526  {
1527  u16 first = (txq->next - txq->n_enqueued) & (txq->size -1);
1529  txq->n_enqueued);
1530  }
1531  /* Free the placeholder buffer */
1532  vlib_buffer_free (vm, txq->ph_bufs, vec_len (txq->ph_bufs));
1533  vec_free (txq->ph_bufs);
1534  vec_free (txq->bufs);
1535  clib_ring_free (txq->rs_slots);
1536  vec_free (txq->tmp_bufs);
1537  vec_free (txq->tmp_descs);
1538  clib_spinlock_free (&txq->lock);
1539  }
1540  /* *INDENT-ON* */
1541  vec_free (ad->txqs);
1542  vec_free (ad->name);
1543 
1544  clib_error_free (ad->error);
1545  dev_instance = ad->dev_instance;
1546  clib_memset (ad, 0, sizeof (*ad));
1547  pool_put_index (am->devices, dev_instance);
1548  clib_mem_free (ad);
1549 }
1550 
1551 static u8
1553 {
1554  clib_error_t *error = 0;
1555 
1556  args->rxq_size = (args->rxq_size == 0) ? AVF_RXQ_SZ : args->rxq_size;
1557  args->txq_size = (args->txq_size == 0) ? AVF_TXQ_SZ : args->txq_size;
1558 
1559  if ((args->rxq_size > AVF_QUEUE_SZ_MAX)
1560  || (args->txq_size > AVF_QUEUE_SZ_MAX))
1561  {
1562  args->rv = VNET_API_ERROR_INVALID_VALUE;
1563  args->error =
1564  clib_error_return (error, "queue size must not be greater than %u",
1566  return 1;
1567  }
1568  if ((args->rxq_size < AVF_QUEUE_SZ_MIN)
1569  || (args->txq_size < AVF_QUEUE_SZ_MIN))
1570  {
1571  args->rv = VNET_API_ERROR_INVALID_VALUE;
1572  args->error =
1573  clib_error_return (error, "queue size must not be smaller than %u",
1575  return 1;
1576  }
1577  if ((args->rxq_size & (args->rxq_size - 1)) ||
1578  (args->txq_size & (args->txq_size - 1)))
1579  {
1580  args->rv = VNET_API_ERROR_INVALID_VALUE;
1581  args->error =
1582  clib_error_return (error, "queue size must be a power of two");
1583  return 1;
1584  }
1585  return 0;
1586 }
1587 
1588 void
1590 {
1591  vnet_main_t *vnm = vnet_get_main ();
1592  avf_main_t *am = &avf_main;
1593  avf_device_t *ad, **adp;
1595  clib_error_t *error = 0;
1596  int i;
1597 
1598  /* check input args */
1599  if (avf_validate_queue_size (args) != 0)
1600  return;
1601 
1602  /* *INDENT-OFF* */
1603  pool_foreach (adp, am->devices) {
1604  if ((*adp)->pci_addr.as_u32 == args->addr.as_u32)
1605  {
1606  args->rv = VNET_API_ERROR_ADDRESS_IN_USE;
1607  args->error =
1609  &args->addr, "pci address in use");
1610  return;
1611  }
1612  }
1613  /* *INDENT-ON* */
1614 
1615  pool_get (am->devices, adp);
1616  adp[0] = ad = clib_mem_alloc_aligned (sizeof (avf_device_t),
1618  clib_memset (ad, 0, sizeof (avf_device_t));
1619  ad->dev_instance = adp - am->devices;
1620  ad->per_interface_next_index = ~0;
1621  ad->name = vec_dup (args->name);
1622 
1623  if (args->enable_elog)
1624  {
1625  ad->flags |= AVF_DEVICE_F_ELOG;
1626  avf_elog_init ();
1627  }
1628 
1630  &h)))
1631  {
1632  pool_put (am->devices, adp);
1633  clib_mem_free (ad);
1634  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
1635  args->error =
1636  clib_error_return (error, "pci-addr %U", format_vlib_pci_addr,
1637  &args->addr);
1638  return;
1639  }
1640  ad->pci_dev_handle = h;
1641  ad->pci_addr = args->addr;
1643 
1645 
1646  if ((error = vlib_pci_bus_master_enable (vm, h)))
1647  goto error;
1648 
1649  if ((error = vlib_pci_map_region (vm, h, 0, &ad->bar0)))
1650  goto error;
1651 
1653  AVF_MBOX_LEN,
1655  ad->numa_node);
1656  if (ad->atq == 0)
1657  {
1659  goto error;
1660  }
1661 
1662  if ((error = vlib_pci_map_dma (vm, h, ad->atq)))
1663  goto error;
1664 
1666  AVF_MBOX_LEN,
1668  ad->numa_node);
1669  if (ad->arq == 0)
1670  {
1672  goto error;
1673  }
1674 
1675  if ((error = vlib_pci_map_dma (vm, h, ad->arq)))
1676  goto error;
1677 
1679  AVF_MBOX_LEN,
1681  ad->numa_node);
1682  if (ad->atq_bufs == 0)
1683  {
1685  goto error;
1686  }
1687 
1688  if ((error = vlib_pci_map_dma (vm, h, ad->atq_bufs)))
1689  goto error;
1690 
1692  AVF_MBOX_LEN,
1694  ad->numa_node);
1695  if (ad->arq_bufs == 0)
1696  {
1698  goto error;
1699  }
1700 
1701  if ((error = vlib_pci_map_dma (vm, h, ad->arq_bufs)))
1702  goto error;
1703 
1705  ad->flags |= AVF_DEVICE_F_VA_DMA;
1706 
1707  if ((error = avf_device_init (vm, am, ad, args)))
1708  goto error;
1709 
1710  if ((error = vlib_pci_register_msix_handler (vm, h, 0, 1,
1711  &avf_irq_0_handler)))
1712  goto error;
1713 
1715  &avf_irq_n_handler)))
1716  goto error;
1717 
1718  if ((error = vlib_pci_enable_msix_irq (vm, h, 0, ad->n_rx_irqs + 1)))
1719  goto error;
1720 
1721  if ((error = vlib_pci_intr_enable (vm, h)))
1722  goto error;
1723 
1724  /* create interface */
1726  ad->dev_instance, ad->hwaddr,
1728 
1729  if (error)
1730  goto error;
1731 
1732  /* Indicate ability to support L3 DMAC filtering and
1733  * initialize interface to L3 non-promisc mode */
1738  ethernet_set_flags (vnm, ad->hw_if_index,
1740 
1742  args->sw_if_index = ad->sw_if_index = sw->sw_if_index;
1743 
1747 
1748  for (i = 0; i < ad->n_rx_queues; i++)
1749  {
1750  u32 qi, fi;
1751  qi = vnet_hw_if_register_rx_queue (vnm, ad->hw_if_index, i,
1753 
1754  if (ad->flags & AVF_DEVICE_F_RX_INT)
1755  {
1757  vnet_hw_if_set_rx_queue_file_index (vnm, qi, fi);
1758  }
1759  ad->rxqs[i].queue_index = qi;
1760  }
1761 
1762  for (i = 0; i < ad->n_tx_queues; i++)
1763  {
1764  u32 qi = vnet_hw_if_register_tx_queue (vnm, ad->hw_if_index, i);
1765  ad->txqs[i].queue_index = qi;
1766  }
1767 
1768  for (i = 0; i < vlib_get_n_threads (); i++)
1769  {
1770  u32 qi = ad->txqs[i % ad->n_tx_queues].queue_index;
1772  }
1773 
1775 
1776  if (pool_elts (am->devices) == 1)
1779 
1780  return;
1781 
1782 error:
1783  avf_delete_if (vm, ad, /* with_barrier */ 0);
1784  args->rv = VNET_API_ERROR_INVALID_INTERFACE;
1785  args->error = clib_error_return (error, "pci-addr %U",
1786  format_vlib_pci_addr, &args->addr);
1787  avf_log_err (ad, "error: %U", format_clib_error, args->error);
1788 }
1789 
1790 static clib_error_t *
1792 {
1793  vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index);
1794  avf_device_t *ad = avf_get_device (hi->dev_instance);
1795  uword is_up = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0;
1796 
1797  if (ad->flags & AVF_DEVICE_F_ERROR)
1798  return clib_error_return (0, "device is in error state");
1799 
1800  if (is_up)
1801  {
1804  ad->flags |= AVF_DEVICE_F_ADMIN_UP;
1805  }
1806  else
1807  {
1809  ad->flags &= ~AVF_DEVICE_F_ADMIN_UP;
1810  }
1811  return 0;
1812 }
1813 
1814 static clib_error_t *
1817 {
1818  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
1820  avf_rxq_t *rxq = vec_elt_at_index (ad->rxqs, qid);
1821 
1823  {
1824  if (rxq->int_mode == 0)
1825  return 0;
1826  if (ad->cap_flags & VIRTCHNL_VF_OFFLOAD_WB_ON_ITR)
1828  else
1830  rxq->int_mode = 0;
1831  }
1832  else
1833  {
1834  if (rxq->int_mode == 1)
1835  return 0;
1836  if (ad->n_rx_irqs != ad->n_rx_queues)
1837  return clib_error_return (0, "not enough interrupt lines");
1838  rxq->int_mode = 1;
1840  }
1841 
1842  return 0;
1843 }
1844 
1845 static void
1847  u32 node_index)
1848 {
1849  vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
1851 
1852  /* Shut off redirection */
1853  if (node_index == ~0)
1854  {
1856  return;
1857  }
1858 
1861 }
1862 
1863 static clib_error_t *
1865  const u8 * address, u8 is_add)
1866 {
1868  avf_process_req_t req;
1869 
1870  req.dev_instance = hw->dev_instance;
1872  req.is_add = is_add;
1873  clib_memcpy (req.eth_addr, address, 6);
1874 
1875  return avf_process_request (vm, &req);
1876 }
1877 
1878 static char *avf_tx_func_error_strings[] = {
1879 #define _(n,s) s,
1881 #undef _
1882 };
1883 
1884 static void
1886 {
1889  &ad->eth_stats, sizeof (ad->eth_stats));
1890 }
1891 
1892 clib_error_t *
1893 avf_program_flow (u32 dev_instance, int is_add, u8 *rule, u32 rule_len,
1894  u8 *program_status, u32 status_len)
1895 {
1897  avf_process_req_t req;
1898 
1899  req.dev_instance = dev_instance;
1901  req.is_add = is_add;
1902  req.rule = rule;
1903  req.rule_len = rule_len;
1904  req.program_status = program_status;
1905  req.status_len = status_len;
1906 
1907  return avf_process_request (vm, &req);
1908 }
1909 
1910 /* *INDENT-OFF* */
1912  .name = "Adaptive Virtual Function (AVF) interface",
1913  .clear_counters = avf_clear_hw_interface_counters,
1914  .format_device = format_avf_device,
1915  .format_device_name = format_avf_device_name,
1916  .admin_up_down_function = avf_interface_admin_up_down,
1917  .rx_mode_change_function = avf_interface_rx_mode_change,
1918  .rx_redirect_to_node = avf_set_interface_next_node,
1919  .mac_addr_add_del_function = avf_add_del_mac_address,
1920  .tx_function_n_errors = AVF_TX_N_ERROR,
1921  .tx_function_error_strings = avf_tx_func_error_strings,
1922  .flow_ops_function = avf_flow_ops_fn,
1923 };
1924 /* *INDENT-ON* */
1925 
1926 clib_error_t *
1928 {
1929  avf_main_t *am = &avf_main;
1931 
1932  vec_validate_aligned (am->per_thread_data, tm->n_vlib_mains - 1,
1934 
1935  return 0;
1936 }
1937 
1938 /* *INDENT-OFF* */
1940 {
1941  .runs_after = VLIB_INITS ("pci_bus_init"),
1942 };
1943 /* *INDENT-OFF* */
1944 
1945 /*
1946  * fd.io coding-style-patch-verification: ON
1947  *
1948  * Local Variables:
1949  * eval: (c-set-style "gnu")
1950  * End:
1951  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
avf_create_if_args_t::sw_if_index
u32 sw_if_index
Definition: avf.h:342
vlib.h
ETHERNET_INTERFACE_FLAG_DEFAULT_L3
#define ETHERNET_INTERFACE_FLAG_DEFAULT_L3
Definition: ethernet.h:159
clib_spinlock_init
static void clib_spinlock_init(clib_spinlock_t *p)
Definition: lock.h:65
avf_tx_func_error_strings
static char * avf_tx_func_error_strings[]
Definition: device.c:1878
avf_create_if_args_t::error
clib_error_t * error
Definition: avf.h:343
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
virtchnl_promisc_info_t::vsi_id
u16 vsi_id
Definition: device.c:346
format_avf_vlan_support
format_function_t format_avf_vlan_support
Definition: avf.h:363
VNET_HW_IF_RXQ_THREAD_ANY
#define VNET_HW_IF_RXQ_THREAD_ANY
Definition: interface.h:598
avf_aq_desc_t
Definition: virtchnl.h:262
avf_device_t::arq_bufs_pa
u64 arq_bufs_pa
Definition: avf.h:241
virtchnl_pf_event_t::link_event
struct virtchnl_pf_event_t::@36::@37 link_event
vlib_buffer_free
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
Definition: buffer_funcs.h:979
AVF_RESET_MAX_WAIT_TIME
#define AVF_RESET_MAX_WAIT_TIME
Definition: avf.h:42
avf_op_config_rss_key
clib_error_t * avf_op_config_rss_key(vlib_main_t *vm, avf_device_t *ad)
Definition: device.c:611
virtchnl_txq_info_t
Definition: virtchnl.h:294
vlib_worker_thread_barrier_release
void vlib_worker_thread_barrier_release(vlib_main_t *vm)
Definition: threads.c:1375
virtchnl_vf_res_request_t
Definition: virtchnl.h:419
avf_rxq_init
clib_error_t * avf_rxq_init(vlib_main_t *vm, avf_device_t *ad, u16 qid, u16 rxq_size)
Definition: device.c:247
avf_device_t::vsi_id
u16 vsi_id
Definition: avf.h:246
avf_interface_admin_up_down
static clib_error_t * avf_interface_admin_up_down(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: device.c:1791
avf_device_t::pci_dev_handle
vlib_pci_dev_handle_t pci_dev_handle
Definition: avf.h:224
vnet_sw_interface_t
Definition: interface.h:869
avf_txq_t
Definition: avf.h:183
avf_rxq_t::descs
avf_rx_desc_t * descs
Definition: avf.h:175
VNET_HW_INTERFACE_CAP_SUPPORTS_L4_TX_CKSUM
#define VNET_HW_INTERFACE_CAP_SUPPORTS_L4_TX_CKSUM
Definition: interface.h:555
vnet_hw_interface_t::caps
vnet_hw_interface_capabilities_t caps
Definition: interface.h:645
avf_txq_t::qtx_tail
volatile u32 * qtx_tail
Definition: avf.h:186
avf_main
avf_main_t avf_main
Definition: device.c:48
foreach_virtchnl_op
#define foreach_virtchnl_op
Definition: virtchnl.h:65
AVF_AQ_F_ERR
#define AVF_AQ_F_ERR
Definition: virtchnl.h:55
virtchnl_txq_info_t::ring_len
u16 ring_len
Definition: virtchnl.h:298
AVF_ATQLEN
#define AVF_ATQLEN
Definition: virtchnl.h:41
vlib_node_add_next
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1177
avf_elog_init
void avf_elog_init()
Definition: elog.c:176
avf_txq_t::ph_bufs
u32 * ph_bufs
Definition: avf.h:189
virtchnl_queue_select_t
Definition: virtchnl.h:338
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER
@ VNET_HW_INTERFACE_CAP_SUPPORTS_MAC_FILTER
Definition: interface.h:552
avf_rxq_t::next
u16 next
Definition: avf.h:173
AVF_MBOX_LEN
#define AVF_MBOX_LEN
Definition: device.c:28
clib_max
#define clib_max(x, y)
Definition: clib.h:335
avf_delete_if
void avf_delete_if(vlib_main_t *vm, avf_device_t *ad, int with_barrier)
Definition: device.c:1481
ethernet_set_flags
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
Definition: interface.c:441
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
avf_op_config_rss_lut
clib_error_t * avf_op_config_rss_lut(vlib_main_t *vm, avf_device_t *ad)
Definition: device.c:588
vlib_process_wait_for_event
static uword * vlib_process_wait_for_event(vlib_main_t *vm)
Definition: node_funcs.h:660
pow2_mask
static uword pow2_mask(uword x)
Definition: clib.h:252
f
vlib_frame_t * f
Definition: interface_output.c:1098
pointer_to_uword
static uword pointer_to_uword(const void *p)
Definition: types.h:131
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
avf_process_req_t::is_enable
int is_enable
Definition: avf.h:293
virtchnl_vector_map_t::vector_id
u16 vector_id
Definition: virtchnl.h:351
avf_device_t::txqs
avf_txq_t * txqs
Definition: avf.h:231
format_ethernet_address
u8 * format_ethernet_address(u8 *s, va_list *args)
Definition: format.c:44
avf_device_t::n_rx_queues
u16 n_rx_queues
Definition: avf.h:233
avf_device_t::n_rx_irqs
u16 n_rx_irqs
Definition: avf.h:251
avf_aq_desc_t::datalen
u16 datalen
Definition: virtchnl.h:266
avf_device_t::hw_if_index
u32 hw_if_index
Definition: avf.h:223
avf_txq_t::queue_index
u32 queue_index
Definition: avf.h:198
memcpy_s
__clib_export errno_t memcpy_s(void *__restrict__ dest, rsize_t dmax, const void *__restrict__ src, rsize_t n)
copy src to dest, at most n bytes, up to dmax
Definition: string.c:120
virtchnl_vsi_resource_t::qset_handle
u16 qset_handle
Definition: virtchnl.h:188
virtchnl_ops_t
virtchnl_ops_t
Definition: virtchnl.h:117
clib_mem_free
static void clib_mem_free(void *p)
Definition: mem.h:314
avf_rxq_t
Definition: avf.h:169
AVF_AQ_F_RD
#define AVF_AQ_F_RD
Definition: virtchnl.h:58
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
VNET_DEVICE_CLASS
VNET_DEVICE_CLASS(af_xdp_device_class)
avf_device_t::rss_lut_size
u32 rss_lut_size
Definition: avf.h:254
virtchnl_rss_lut_t
Definition: virtchnl.h:409
avf_main_t
Definition: avf.h:321
avf_irq_0_handler
static void avf_irq_0_handler(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 line)
Definition: device.c:1409
AVF_IRQ_STATE_ENABLED
@ AVF_IRQ_STATE_ENABLED
Definition: device.c:67
avf_device_t::num_queue_pairs
u16 num_queue_pairs
Definition: avf.h:249
AVF_ARQLEN
#define AVF_ARQLEN
Definition: virtchnl.h:47
virtchnl_pf_event_t
Definition: virtchnl.h:235
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
PCI_DEVICE_ID_INTEL_AVF
#define PCI_DEVICE_ID_INTEL_AVF
Definition: device.c:35
avf_device_t::n_tx_queues
u16 n_tx_queues
Definition: avf.h:232
avf_create_if_args_t::rxq_size
u16 rxq_size
Definition: avf.h:338
virtchnl_rss_key_t
Definition: virtchnl.h:400
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
virtchnl_pf_event_t::link_event_adv
struct virtchnl_pf_event_t::@36::@38 link_event_adv
u16
unsigned short u16
Definition: types.h:57
avf_input_node
vlib_node_registration_t avf_input_node
(constructor) VLIB_REGISTER_NODE (avf_input_node)
Definition: input.c:570
first
static heap_elt_t * first(heap_header_t *h)
Definition: heap.c:59
mode
vl_api_tunnel_mode_t mode
Definition: gre.api:48
avf_clear_hw_interface_counters
static void avf_clear_hw_interface_counters(u32 instance)
Definition: device.c:1885
am
app_main_t * am
Definition: application.c:489
vlib_physmem_free
static void vlib_physmem_free(vlib_main_t *vm, void *p)
Definition: physmem_funcs.h:89
virtchnl_eth_stats_t
Definition: virtchnl.h:393
AVF_IRQ_STATE_DISABLED
@ AVF_IRQ_STATE_DISABLED
Definition: device.c:66
virtchnl_vf_resource_t::max_vectors
u16 max_vectors
Definition: virtchnl.h:196
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
avf_process_req_t::rule_len
u32 rule_len
Definition: avf.h:297
VNET_HW_IF_RX_MODE_POLLING
@ VNET_HW_IF_RX_MODE_POLLING
Definition: interface.h:56
avf_op_disable_vlan_stripping_v2
clib_error_t * avf_op_disable_vlan_stripping_v2(vlib_main_t *vm, avf_device_t *ad, u32 outer, u32 inner)
Definition: device.c:846
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
AVFINT_DYN_CTLN
#define AVFINT_DYN_CTLN(x)
Definition: virtchnl.h:35
virtchnl_queue_pair_info_t::txq
virtchnl_txq_info_t txq
Definition: virtchnl.h:324
avf_rxq_t::bufs
u32 * bufs
Definition: avf.h:176
node_index
node node_index
Definition: interface_output.c:440
virtchnl_vsi_queue_config_info_t
Definition: virtchnl.h:328
VNET_HW_INTERFACE_FLAG_LINK_UP
@ VNET_HW_INTERFACE_FLAG_LINK_UP
Definition: interface.h:509
state
vl_api_dhcp_client_state_t state
Definition: dhcp.api:201
avf_txq_t::rs_slots
u16 * rs_slots
Definition: avf.h:194
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
avf_device_init
clib_error_t * avf_device_init(vlib_main_t *vm, avf_main_t *am, avf_device_t *ad, avf_create_if_args_t *args)
Definition: device.c:951
avf_device_t::name
u8 * name
Definition: avf.h:227
VIRTCHNL_VLAN_UNSUPPORTED
@ VIRTCHNL_VLAN_UNSUPPORTED
Definition: virtchnl.h:468
virtchnl_vector_map_t
Definition: virtchnl.h:348
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
vlib_buffer_get_pa
static uword vlib_buffer_get_pa(vlib_main_t *vm, vlib_buffer_t *b)
Definition: buffer_funcs.h:488
avf_op_config_vsi_queues
clib_error_t * avf_op_config_vsi_queues(vlib_main_t *vm, avf_device_t *ad)
Definition: device.c:671
avf_create_if_args_t::enable_elog
int enable_elog
Definition: avf.h:335
virtchnl_txq_info_t::vsi_id
u16 vsi_id
Definition: virtchnl.h:296
avf_op_version
clib_error_t * avf_op_version(vlib_main_t *vm, avf_device_t *ad, virtchnl_version_info_t *ver)
Definition: device.c:527
virtchnl_queue_pair_info_t
Definition: virtchnl.h:322
vnet_hw_interface_t::dev_instance
u32 dev_instance
Definition: interface.h:660
r
vnet_hw_if_output_node_runtime_t * r
Definition: interface_output.c:1089
vlib_frame_t
Definition: node.h:372
virtchnl_vsi_resource_t::num_queue_pairs
u16 num_queue_pairs
Definition: virtchnl.h:186
virtchnl_ether_addr_list_t::list
virtchnl_ether_addr_t list[1]
Definition: virtchnl.h:376
vlib_process_signal_event
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
Definition: node_funcs.h:1019
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
format_avf_device
format_function_t format_avf_device
Definition: avf.h:357
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
avf_create_if_args_t
Definition: avf.h:331
avf_process_node
vlib_node_registration_t avf_process_node
(constructor) VLIB_REGISTER_NODE (avf_process_node)
Definition: device.c:1401
pool_put_index
#define pool_put_index(p, i)
Free pool element with given index.
Definition: pool.h:337
pci_device_id_t::vendor_id
u16 vendor_id
Definition: pci.h:127
avf_log_debug
#define avf_log_debug(dev, f,...)
Definition: avf.h:100
avf_device_t
Definition: avf.h:215
virtchnl_vf_resource_t::vsi_res
virtchnl_vsi_resource_t vsi_res[1]
Definition: virtchnl.h:201
avf_op_program_flow
clib_error_t * avf_op_program_flow(vlib_main_t *vm, avf_device_t *ad, int is_create, u8 *rule, u32 rule_len, u8 *program_status, u32 status_len)
Definition: device.c:1236
avf_device_t::hwaddr
u8 hwaddr[6]
Definition: avf.h:248
avf_device_class
vnet_device_class_t avf_device_class
ethernet.h
h
h
Definition: flowhash_template.h:372
error
Definition: cJSON.c:88
virtchnl_promisc_info_t
Definition: device.c:344
AVF_AQ_ENQ_MAX_WAIT_TIME
#define AVF_AQ_ENQ_MAX_WAIT_TIME
Definition: avf.h:39
avf_device_t::rxqs
avf_rxq_t * rxqs
Definition: avf.h:230
vlib_log_err
#define vlib_log_err(...)
Definition: log.h:133
virtchnl_queue_select_t::vsi_id
u16 vsi_id
Definition: virtchnl.h:340
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
AVF_ATQH
#define AVF_ATQH
Definition: virtchnl.h:40
vlib_pci_map_dma
clib_error_t * vlib_pci_map_dma(vlib_main_t *vm, vlib_pci_dev_handle_t h, void *ptr)
Definition: pci.c:1232
virtchnl_rxq_info_t::ring_len
u32 ring_len
Definition: virtchnl.h:309
format_clib_error
__clib_export u8 * format_clib_error(u8 *s, va_list *va)
Definition: error.c:191
virtchnl_vf_resource_t::rss_key_size
u32 rss_key_size
Definition: virtchnl.h:199
virtchnl_vlan_supported_caps_t::outer
u32 outer
Definition: virtchnl.h:426
format_avf_vlan_caps
format_function_t format_avf_vlan_caps
Definition: avf.h:362
avf_irq_0_set_state
static void avf_irq_0_set_state(avf_device_t *ad, avf_irq_state_t state)
Definition: device.c:72
virtchnl_txq_info_t::dma_ring_addr
u64 dma_ring_addr
Definition: virtchnl.h:299
virtchnl_vf_resource_t::rss_lut_size
u32 rss_lut_size
Definition: virtchnl.h:200
format_hex_bytes_no_wrap
u8 * format_hex_bytes_no_wrap(u8 *s, va_list *va)
Definition: std-formats.c:112
avf_create_if
void avf_create_if(vlib_main_t *vm, avf_create_if_args_t *args)
Definition: device.c:1589
avf_add_del_mac_address
static clib_error_t * avf_add_del_mac_address(vnet_hw_interface_t *hw, const u8 *address, u8 is_add)
Definition: device.c:1864
virtchnl_rxq_info_t::queue_id
u16 queue_id
Definition: virtchnl.h:308
vlib_buffer_get_va
static uword vlib_buffer_get_va(vlib_buffer_t *b)
Definition: buffer.h:245
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_process_get_events
static uword vlib_process_get_events(vlib_main_t *vm, uword **data_vector)
Return the first event type which has occurred and a vector of per-event data of that type,...
Definition: node_funcs.h:583
avf_txq_t::tmp_descs
avf_tx_desc_t * tmp_descs
Definition: avf.h:196
AVF_QTX_TAIL
#define AVF_QTX_TAIL(q)
Definition: virtchnl.h:50
AVF_ATQT
#define AVF_ATQT
Definition: virtchnl.h:48
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
VIRTCHNL_VSI_SRIOV
@ VIRTCHNL_VSI_SRIOV
Definition: virtchnl.h:173
avf_txq_t::next
u16 next
Definition: avf.h:187
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
avf_device_t::error
clib_error_t * error
Definition: avf.h:267
VNET_HW_INTERFACE_FLAG_FULL_DUPLEX
@ VNET_HW_INTERFACE_FLAG_FULL_DUPLEX
Definition: interface.h:512
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
avf_txq_t::tmp_bufs
u32 * tmp_bufs
Definition: avf.h:197
avf_device_t::dev_instance
u32 dev_instance
Definition: avf.h:221
count
u8 count
Definition: dhcp.api:208
vlib_physmem_get_pa
static u64 vlib_physmem_get_pa(vlib_main_t *vm, void *mem)
Definition: physmem_funcs.h:103
avf_txq_t::size
u16 size
Definition: avf.h:188
clib_error_create
#define clib_error_create(args...)
Definition: error.h:96
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
virtchnl_pf_event_t::event_data
union virtchnl_pf_event_t::@36 event_data
avf_process_req_t::calling_process_index
u32 calling_process_index
Definition: avf.h:291
vlib_get_current_process_node_index
static u32 vlib_get_current_process_node_index(vlib_main_t *vm)
Definition: node_funcs.h:463
ELOG_TYPE_DECLARE
#define ELOG_TYPE_DECLARE(f)
Definition: elog.h:442
PCI_DEVICE_ID_INTEL_X710_VF
#define PCI_DEVICE_ID_INTEL_X710_VF
Definition: device.c:36
len
u8 len
Definition: ip_types.api:103
virtchnl_irq_map_info_t
Definition: virtchnl.h:358
slot
u8 slot
Definition: pci_types.api:22
avf_process_request
static clib_error_t * avf_process_request(vlib_main_t *vm, avf_process_req_t *req)
Definition: device.c:1271
vec_add2
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:644
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
avf_op_get_offload_vlan_v2_caps
clib_error_t * avf_op_get_offload_vlan_v2_caps(vlib_main_t *vm, avf_device_t *ad, virtchnl_vlan_caps_t *vc)
Definition: device.c:831
avf_aq_desc_t::flags
u16 flags
Definition: virtchnl.h:264
virtchnl_vf_res_request_t::num_queue_pairs
u16 num_queue_pairs
Definition: virtchnl.h:421
avf_create_if_args_t::addr
vlib_pci_addr_t addr
Definition: avf.h:333
VIRTCHNL_VERSION_MINOR
#define VIRTCHNL_VERSION_MINOR
Definition: virtchnl.h:22
avf_device_t::max_vectors
u16 max_vectors
Definition: avf.h:250
vec_dup
#define vec_dup(V)
Return copy of vector (no header, no alignment)
Definition: vec.h:444
vlib_process_signal_event_pointer
static void vlib_process_signal_event_pointer(vlib_main_t *vm, uword node_index, uword type_opaque, void *data)
Definition: node_funcs.h:1028
AVFINT_ICR0
#define AVFINT_ICR0
Definition: virtchnl.h:36
avf_txq_t::descs
avf_tx_desc_t * descs
Definition: avf.h:191
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
AVF_QRX_TAIL
#define AVF_QRX_TAIL(q)
Definition: virtchnl.h:51
AVF_RXQ_SZ
#define AVF_RXQ_SZ
Definition: device.c:30
vlib_worker_thread_barrier_sync
#define vlib_worker_thread_barrier_sync(X)
Definition: threads.h:173
VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO
@ VNET_HW_INTERFACE_CAP_SUPPORTS_TCP_GSO
Definition: interface.h:537
AVF_TX_N_ERROR
@ AVF_TX_N_ERROR
Definition: avf.h:487
clib_ring_new_aligned
#define clib_ring_new_aligned(ring, size, align)
Definition: ring.h:53
VIRTCHNL_VFR_VFACTIVE
@ VIRTCHNL_VFR_VFACTIVE
Definition: virtchnl.h:180
rx_queue_funcs.h
vlib_global_main
vlib_global_main_t vlib_global_main
Definition: main.c:1786
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
virtchnl_event_names
const static char * virtchnl_event_names[]
Definition: device.c:58
avf_irq_n_handler
static void avf_irq_n_handler(vlib_main_t *vm, vlib_pci_dev_handle_t h, u16 line)
Definition: device.c:1446
avf_init
clib_error_t * avf_init(vlib_main_t *vm)
Definition: device.c:1927
vnet_hw_if_rx_mode
vnet_hw_if_rx_mode
Definition: interface.h:53
avf_process_req_t::type
avf_process_req_type_t type
Definition: avf.h:289
AVF_ATQBAL
#define AVF_ATQBAL
Definition: virtchnl.h:46
avf_device_t::link_speed
virtchnl_link_speed_t link_speed
Definition: avf.h:255
avf_create_if_args_t::txq_num
u16 txq_num
Definition: avf.h:337
AVF_AQ_F_BUF
#define AVF_AQ_F_BUF
Definition: virtchnl.h:60
AVF_MBOX_BUF_SZ
#define AVF_MBOX_BUF_SZ
Definition: device.c:29
AVF_AQ_F_DD
#define AVF_AQ_F_DD
Definition: virtchnl.h:53
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
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
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
AVF_QUEUE_SZ_MIN
#define AVF_QUEUE_SZ_MIN
Definition: avf.h:36
avf_process_one_device
void avf_process_one_device(vlib_main_t *vm, avf_device_t *ad, int is_irq)
Definition: device.c:1091
virtchnl_ether_addr_t
Definition: virtchnl.h:366
AVF_ITR_INT
#define AVF_ITR_INT
Definition: device.c:32
virtchnl_vsi_resource_t::default_mac_addr
u8 default_mac_addr[6]
Definition: virtchnl.h:189
avf_create_if_args_t::rxq_num
u16 rxq_num
Definition: avf.h:336
virtchnl_vlan_offload_caps::stripping_support
virtchnl_vlan_supported_caps_t stripping_support
Definition: virtchnl.h:440
avf_interface_rx_mode_change
static clib_error_t * avf_interface_rx_mode_change(vnet_main_t *vnm, u32 hw_if_index, u32 qid, vnet_hw_if_rx_mode mode)
Definition: device.c:1815
f64
double f64
Definition: types.h:142
avf_op_enable_queues
clib_error_t * avf_op_enable_queues(vlib_main_t *vm, avf_device_t *ad, u32 rx, u32 tx)
Definition: device.c:787
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
virtchnl_vlan_caps_t
Definition: virtchnl.h:447
pool_get
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
avf_create_if_args_t::rv
int rv
Definition: avf.h:341
AVF_ARQBAL
#define AVF_ARQBAL
Definition: virtchnl.h:42
avf_process_req_t::rule
u8 * rule
Definition: avf.h:296
address
manual_print typedef address
Definition: ip_types.api:96
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
vlib_pci_supports_virtual_addr_dma
int vlib_pci_supports_virtual_addr_dma(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.c:1243
virtchnl_vf_resource_t::num_queue_pairs
u16 num_queue_pairs
Definition: virtchnl.h:195
avf_device_t::atq_next_slot
u16 atq_next_slot
Definition: avf.h:242
CLIB_MEMORY_BARRIER
#define CLIB_MEMORY_BARRIER()
Definition: clib.h:137
virtchnl_vector_map_t::vsi_id
u16 vsi_id
Definition: virtchnl.h:350
clib_ring_free
#define clib_ring_free(f)
Definition: ring.h:59
avf_txq_t::bufs
u32 * bufs
Definition: avf.h:192
virtchnl_vlan_caps_t::offloads
virtchnl_vlan_offload_caps_t offloads
Definition: virtchnl.h:450
virtchnl_queue_select_t::tx_queues
u32 tx_queues
Definition: virtchnl.h:343
clib_min
#define clib_min(x, y)
Definition: clib.h:342
avf_irq_state_t
avf_irq_state_t
Definition: device.c:64
avf.h
virtchnl_rxq_info_t::vsi_id
u16 vsi_id
Definition: virtchnl.h:307
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
virtchnl_vector_map_t::rxq_map
u16 rxq_map
Definition: virtchnl.h:352
virtchnl_irq_map_info_t::num_vectors
u16 num_vectors
Definition: virtchnl.h:360
virtchnl_vf_resource_t::num_vsis
u16 num_vsis
Definition: virtchnl.h:194
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
avf_rxq_t::size
u16 size
Definition: avf.h:174
virtchnl_vlan_setting_t
Definition: virtchnl.h:474
vlib_global_main_t::elog_main
elog_main_t elog_main
Definition: main.h:302
avf_rxq_t::n_enqueued
u16 n_enqueued
Definition: avf.h: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
avf_device_t::rss_key_size
u32 rss_key_size
Definition: avf.h:253
avf_process_handle_request
static void avf_process_handle_request(vlib_main_t *vm, avf_process_req_t *req)
Definition: device.c:1250
avf_device_t::max_mtu
u16 max_mtu
Definition: avf.h:252
avf_aq_desc_t::retval
u16 retval
Definition: virtchnl.h:267
avf_log_err
#define avf_log_err(dev, f,...)
Definition: avf.h:90
avf_device_t::last_cleared_eth_stats
virtchnl_eth_stats_t last_cleared_eth_stats
Definition: avf.h:264
avf_aq_desc_t::v_opcode
virtchnl_ops_t v_opcode
Definition: virtchnl.h:271
avf_validate_queue_size
static u8 avf_validate_queue_size(avf_create_if_args_t *args)
Definition: device.c:1552
avf_set_interface_next_node
static void avf_set_interface_next_node(vnet_main_t *vnm, u32 hw_if_index, u32 node_index)
Definition: device.c:1846
data
u8 data[128]
Definition: ipsec_types.api:95
AVF_SEND_TO_PF_MAX_WAIT_TIME
#define AVF_SEND_TO_PF_MAX_WAIT_TIME
Definition: avf.h:45
virtchnl_vsi_resource_t::vsi_id
u16 vsi_id
Definition: virtchnl.h:185
avf_rx_desc_t::qword
u64 qword[4]
Definition: avf.h:147
AVF_ATQBAH
#define AVF_ATQBAH
Definition: virtchnl.h:45
virtchnl_ether_addr_list_t
Definition: virtchnl.h:372
avf_txq_t::n_enqueued
u16 n_enqueued
Definition: avf.h:193
avf_op_add_del_eth_addr
clib_error_t * avf_op_add_del_eth_addr(vlib_main_t *vm, avf_device_t *ad, u8 count, u8 *macs, int is_add)
Definition: device.c:758
vnet_hw_interface_t
Definition: interface.h:638
vnet_main_t
Definition: vnet.h:76
avf_device_t::sw_if_index
u32 sw_if_index
Definition: avf.h:222
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
VIRTCHNL_VERSION_MAJOR
#define VIRTCHNL_VERSION_MAJOR
Definition: virtchnl.h:21
vlib_log_registration::class
vlib_log_class_t class
Definition: log.h:85
virtchnl_vf_resource_t::vf_cap_flags
u32 vf_cap_flags
Definition: virtchnl.h:198
avf_tx_desc_t
Definition: avf.h:156
avf_reg_write
static void avf_reg_write(avf_device_t *ad, u32 addr, u32 val)
Definition: avf.h:421
virtchnl_rxq_info_t::dma_ring_addr
u64 dma_ring_addr
Definition: virtchnl.h:315
virtchnl_vf_resource_t::max_mtu
u16 max_mtu
Definition: virtchnl.h:197
avf_flow_ops_fn
vnet_flow_dev_ops_function_t avf_flow_ops_fn
Definition: avf.h:365
avf_device_t::arq
avf_aq_desc_t * arq
Definition: avf.h:237
AVF_AQ_F_CMP
#define AVF_AQ_F_CMP
Definition: virtchnl.h:54
avf_reg_read
static u32 avf_reg_read(avf_device_t *ad, u32 addr)
Definition: avf.h:429
avf_flag_change
static u32 avf_flag_change(vnet_main_t *vnm, vnet_hw_interface_t *hw, u32 flags)
Definition: device.c:1294
pool_foreach_index
#define pool_foreach_index(i, v)
Definition: pool.h:572
virtchnl_ether_addr_t::addr
u8 addr[6]
Definition: virtchnl.h:368
format_vlib_pci_addr
format_function_t format_vlib_pci_addr
Definition: pci.h:326
avf_device_t::cap_flags
u32 cap_flags
Definition: avf.h:247
avf_rxq_t::int_mode
u8 int_mode
Definition: avf.h:178
virtchnl_version_info_t::minor
u32 minor
Definition: virtchnl.h:259
avf_aq_desc_t::addr_hi
u32 addr_hi
Definition: virtchnl.h:283
u64
unsigned long u64
Definition: types.h:89
AVF_PROCESS_REQ_CONFIG_PROMISC_MDDE
@ AVF_PROCESS_REQ_CONFIG_PROMISC_MDDE
Definition: avf.h:283
virtchnl_irq_map_info_t::vecmap
virtchnl_vector_map_t vecmap[1]
Definition: virtchnl.h:361
AVF_QUEUE_SZ_MAX
#define AVF_QUEUE_SZ_MAX
Definition: avf.h:35
virtchnl_link_speed_t
virtchnl_link_speed_t
Definition: virtchnl.h:227
ring.h
avf_device_reset
clib_error_t * avf_device_reset(vlib_main_t *vm, avf_device_t *ad)
Definition: device.c:864
vlib_process_wait_for_event_or_clock
static f64 vlib_process_wait_for_event_or_clock(vlib_main_t *vm, f64 dt)
Suspend a cooperative multi-tasking thread Waits for an event, or for the indicated number of seconds...
Definition: node_funcs.h:755
avf_process_req_t::dev_instance
u32 dev_instance
Definition: avf.h:290
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
avf_log
vlib_log_class_registration_t avf_log
PCI_VENDOR_ID_INTEL
#define PCI_VENDOR_ID_INTEL
Definition: device.c:34
vlib_process_suspend
static uword vlib_process_suspend(vlib_main_t *vm, f64 dt)
Suspend a vlib cooperative multi-tasking thread for a period of time.
Definition: node_funcs.h:486
virtchnl_rxq_info_t::max_pkt_size
u32 max_pkt_size
Definition: virtchnl.h:313
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
vlib_buffer_get_default_data_size
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
Definition: buffer_funcs.h:122
buf
u64 buf
Definition: application.c:493
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
format_avf_device_name
format_function_t format_avf_device_name
Definition: avf.h:358
avf_op_get_stats
clib_error_t * avf_op_get_stats(vlib_main_t *vm, avf_device_t *ad, virtchnl_eth_stats_t *es)
Definition: device.c:813
ethernet_delete_interface
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
Definition: interface.c:393
vlib_thread_main_t
Definition: threads.h:243
AVF_ARQH
#define AVF_ARQH
Definition: virtchnl.h:44
avf_process
static uword avf_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
Definition: device.c:1327
avf_stats_log
vlib_log_class_registration_t avf_stats_log
AVF_AQ_F_SI
#define AVF_AQ_F_SI
Definition: virtchnl.h:61
avf_aq_desc_t::v_retval
virtchnl_status_code_t v_retval
Definition: virtchnl.h:276
avf_op_config_promisc_mode
clib_error_t * avf_op_config_promisc_mode(vlib_main_t *vm, avf_device_t *ad, int is_enable)
Definition: device.c:651
avf_rxq_t::buffer_pool_index
u8 buffer_pool_index
Definition: avf.h:179
virtchnl_queue_pair_info_t::rxq
virtchnl_rxq_info_t rxq
Definition: virtchnl.h:325
avf_adminq_init
static void avf_adminq_init(vlib_main_t *vm, avf_device_t *ad)
Definition: device.c:371
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
pci.h
avf_aq_desc_t::addr_lo
u32 addr_lo
Definition: virtchnl.h:288
avf_device_t::atq_bufs
void * atq_bufs
Definition: avf.h:238
VLIB_NODE_TYPE_PROCESS
@ VLIB_NODE_TYPE_PROCESS
Definition: node.h:84
virtchnl_vlan_setting_t::outer_ethertype_setting
u32 outer_ethertype_setting
Definition: virtchnl.h:476
avf_pci_device_ids
static pci_device_id_t avf_pci_device_ids[]
Definition: device.c:51
instance
u32 instance
Definition: gre.api:51
AVFINT_DYN_CTL0
#define AVFINT_DYN_CTL0
Definition: virtchnl.h:38
pool_elts
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127
avf_op_get_vf_resources
clib_error_t * avf_op_get_vf_resources(vlib_main_t *vm, avf_device_t *ad, virtchnl_vf_resource_t *res)
Definition: device.c:549
virtchnl_txq_info_t::queue_id
u16 queue_id
Definition: virtchnl.h:297
avf_process_req_t::is_add
int is_add
Definition: avf.h:293
avf_op_disable_vlan_stripping
clib_error_t * avf_op_disable_vlan_stripping(vlib_main_t *vm, avf_device_t *ad)
Definition: device.c:642
avf_process_req_t::status_len
u32 status_len
Definition: avf.h:299
avf_device_t::pci_addr
vlib_pci_addr_t pci_addr
Definition: avf.h:256
avf_device_t::per_interface_next_index
u32 per_interface_next_index
Definition: avf.h:219
AVF_AQ_ENQ_SUSPEND_TIME
#define AVF_AQ_ENQ_SUSPEND_TIME
Definition: avf.h:38
format_avf_eth_stats
format_function_t format_avf_eth_stats
Definition: avf.h:364
avf_get_u32
static u32 avf_get_u32(void *start, int offset)
Definition: avf.h:381
avf_device_t::eth_stats
virtchnl_eth_stats_t eth_stats
Definition: avf.h:263
virtchnl_rxq_info_t::databuffer_size
u32 databuffer_size
Definition: virtchnl.h:312
avf_irq_n_set_state
static void avf_irq_n_set_state(avf_device_t *ad, u8 line, avf_irq_state_t state)
Definition: device.c:101
AVF_ARQT
#define AVF_ARQT
Definition: virtchnl.h:43
vlib_buffer_pool_get_default_for_numa
static u8 vlib_buffer_pool_get_default_for_numa(vlib_main_t *vm, u32 numa_node)
Definition: buffer_funcs.h:189
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
avf_process_req_t
Definition: avf.h:287
avf_op_config_irq_map
clib_error_t * avf_op_config_irq_map(vlib_main_t *vm, avf_device_t *ad)
Definition: device.c:727
avf_request_queues
clib_error_t * avf_request_queues(vlib_main_t *vm, avf_device_t *ad, u16 num_queue_pairs)
Definition: device.c:902
vlib_get_n_threads
static u32 vlib_get_n_threads()
Definition: global_funcs.h:23
avf_device_t::atq_bufs_pa
u64 atq_bufs_pa
Definition: avf.h:240
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
AVF_SEND_TO_PF_SUSPEND_TIME
#define AVF_SEND_TO_PF_SUSPEND_TIME
Definition: avf.h:44
VLIB_INITS
#define VLIB_INITS(...)
Definition: init.h:352
vlib_get_main
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
avf_device_t::flags
u32 flags
Definition: avf.h:218
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
AVFINT_ICR0_ENA1
#define AVFINT_ICR0_ENA1
Definition: virtchnl.h:37
u8
unsigned char u8
Definition: types.h:56
avf_process_req_t::error
clib_error_t * error
Definition: avf.h:301
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
unix.h
rt
vnet_interface_output_runtime_t * rt
Definition: interface_output.c:419
virtchnl_ether_addr_list_t::vsi_id
u16 vsi_id
Definition: virtchnl.h:374
avf_arq_slot_init
void avf_arq_slot_init(avf_device_t *ad, u16 slot)
Definition: device.c:351
avf_rxq_t::queue_index
u32 queue_index
Definition: avf.h:180
avf_aq_desc_t::opcode
u16 opcode
Definition: virtchnl.h:265
virtchnl_promisc_info_t::flags
u16 flags
Definition: device.c:347
avf_rx_desc_t
Definition: avf.h:127
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
Definition: ethernet.h:162
avf_device_t::bar0
void * bar0
Definition: avf.h:226
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
VLIB_REGISTER_LOG_CLASS
VLIB_REGISTER_LOG_CLASS(avf_log)
i
int i
Definition: flowhash_template.h:376
ETHERNET_MAX_PACKET_BYTES
#define ETHERNET_MAX_PACKET_BYTES
Definition: ethernet.h:132
AVF_PROCESS_EVENT_DELETE_IF
@ AVF_PROCESS_EVENT_DELETE_IF
Definition: avf.h:275
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
avf_device_t::events
virtchnl_pf_event_t * events
Definition: avf.h:244
clib_mem_alloc_aligned
static void * clib_mem_alloc_aligned(uword size, uword align)
Definition: mem.h:264
AVF_TXQ_SZ
#define AVF_TXQ_SZ
Definition: device.c:31
avf_device_t::atq
avf_aq_desc_t * atq
Definition: avf.h:236
avf_device_t::arq_next_slot
u16 arq_next_slot
Definition: avf.h:243
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
avf_process_req_t::program_status
u8 * program_status
Definition: avf.h:298
AVF_PROCESS_EVENT_AQ_INT
@ AVF_PROCESS_EVENT_AQ_INT
Definition: avf.h:276
foreach_avf_tx_func_error
#define foreach_avf_tx_func_error
Definition: avf.h:478
avf_rxq_t::qrx_tail
volatile u32 * qrx_tail
Definition: avf.h:172
ELOG_DATA
#define ELOG_DATA(em, f)
Definition: elog.h:484
tx_queue_funcs.h
avf_process_req_t::eth_addr
u8 eth_addr[6]
Definition: avf.h:292
virtchnl_pf_event_t::event
virtchnl_event_codes_t event
Definition: virtchnl.h:237
virtchnl_vsi_resource_t::vsi_type
virtchnl_vsi_type_t vsi_type
Definition: virtchnl.h:187
avf_device_t::numa_node
u32 numa_node
Definition: avf.h:225
avf_txq_t::lock
clib_spinlock_t lock
Definition: avf.h:190
avf_stats_log_debug
#define avf_stats_log_debug(dev, f,...)
Definition: avf.h:105
AVF_IRQ_STATE_WB_ON_ITR
@ AVF_IRQ_STATE_WB_ON_ITR
Definition: device.c:68
avf_txq_init
clib_error_t * avf_txq_init(vlib_main_t *vm, avf_device_t *ad, u16 qid, u16 txq_size)
Definition: device.c:297
AVF_PROCESS_REQ_PROGRAM_FLOW
@ AVF_PROCESS_REQ_PROGRAM_FLOW
Definition: avf.h:284
vlib_time_now
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:327
virtchnl_ether_addr_list_t::num_elements
u16 num_elements
Definition: virtchnl.h:375
vlib_pci_device_close
void vlib_pci_device_close(vlib_main_t *vm, vlib_pci_dev_handle_t h)
Definition: pci.c:1311
avf_dma_addr
static uword avf_dma_addr(vlib_main_t *vm, avf_device_t *ad, void *p)
Definition: device.c:364
format_avf_vf_cap_flags
format_function_t format_avf_vf_cap_flags
Definition: avf.h:360
vlib_node_runtime_t
Definition: node.h:454
clib_panic
#define clib_panic(format, args...)
Definition: error.h:72
virtchnl_version_info_t::major
u32 major
Definition: virtchnl.h:258
virtchnl_vsi_queue_config_info_t::vsi_id
u16 vsi_id
Definition: virtchnl.h:330
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
virtchnl_pf_event_t::severity
int severity
Definition: virtchnl.h:251
PCI_DEVICE_ID_INTEL_X722_VF
#define PCI_DEVICE_ID_INTEL_X722_VF
Definition: device.c:37
avf_send_to_pf
clib_error_t * avf_send_to_pf(vlib_main_t *vm, avf_device_t *ad, virtchnl_ops_t op, void *in, int in_len, void *out, int out_len)
Definition: device.c:408
virtchnl_vsi_queue_config_info_t::num_queue_pairs
u16 num_queue_pairs
Definition: virtchnl.h:331
virtchnl_version_info_t
Definition: virtchnl.h:256
VIRTCHNL_VFR_COMPLETED
@ VIRTCHNL_VFR_COMPLETED
Definition: virtchnl.h:179
AVF_PROCESS_REQ_ADD_DEL_ETH_ADDR
@ AVF_PROCESS_REQ_ADD_DEL_ETH_ADDR
Definition: avf.h:282
vlib_buffer_alloc_from_pool
static __clib_warn_unused_result u32 vlib_buffer_alloc_from_pool(vlib_main_t *vm, u32 *buffers, u32 n_buffers, u8 buffer_pool_index)
Allocate buffers from specific pool into supplied array.
Definition: buffer_funcs.h:597
virtchnl_rxq_info_t
Definition: virtchnl.h:305
VIRTCHNL_N_OPS
@ VIRTCHNL_N_OPS
Definition: virtchnl.h:122
avf_create_if_args_t::name
u8 * name
Definition: avf.h:334
virtchnl_vf_resource_t
Definition: virtchnl.h:192
AVF_RESET_SUSPEND_TIME
#define AVF_RESET_SUSPEND_TIME
Definition: avf.h:41
AVF_PROCESS_EVENT_REQ
@ AVF_PROCESS_EVENT_REQ
Definition: avf.h:277
avf_cmd_rx_ctl_reg_write
clib_error_t * avf_cmd_rx_ctl_reg_write(vlib_main_t *vm, avf_device_t *ad, u32 reg, u32 val)
Definition: device.c:218
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
avf_program_flow
clib_error_t * avf_program_flow(u32 dev_instance, int is_add, u8 *rule, u32 rule_len, u8 *program_status, u32 status_len)
Definition: device.c:1893
format_white_space
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
AVF_ARQBAH
#define AVF_ARQBAH
Definition: virtchnl.h:39
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
virtchnl_queue_select_t::rx_queues
u32 rx_queues
Definition: virtchnl.h:342
AVFGEN_RSTAT
#define AVFGEN_RSTAT
Definition: virtchnl.h:49
AVF_PROCESS_EVENT_START
@ AVF_PROCESS_EVENT_START
Definition: avf.h:274
avf_create_if_args_t::txq_size
u16 txq_size
Definition: avf.h:339
avf_get_device
static_always_inline avf_device_t * avf_get_device(u32 dev_instance)
Definition: avf.h:368
virtchnl_vlan_supported_caps_t::inner
u32 inner
Definition: virtchnl.h:427
avf_device_t::arq_bufs
void * arq_bufs
Definition: avf.h:239
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
virtchnl_vsi_queue_config_info_t::qpair
virtchnl_queue_pair_info_t qpair[1]
Definition: virtchnl.h:333
avf_reg_flush
static void avf_reg_flush(avf_device_t *ad)
Definition: avf.h:440
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
foreach_virtchnl_event_code
@ foreach_virtchnl_event_code
Definition: virtchnl.h:213
pci_device_id_t
Definition: pci.h:125
avf_aq_desc_enq
clib_error_t * avf_aq_desc_enq(vlib_main_t *vm, avf_device_t *ad, avf_aq_desc_t *dt, void *data, int len)
Definition: device.c:133
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105