Files @ d0a14f973771
Branch filter:

Location: vmkdrivers/BLD/build/HEADERS/vmkapi-current-all-public/vmkernel64/release/net/vmkapi_net_pktlist.h

unknown
ESXi-5.0-U1
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
/* **********************************************************
 * Copyright 2006 - 2010 VMware, Inc.  All rights reserved.
 * **********************************************************/

/*
 * @VMKAPIMOD_LICENSE@
 */

/*
 ***********************************************************************
 * PktList                                                        */ /**
 * \addtogroup Network
 *@{
 * \defgroup PktList Packet List Management
 *@{
 *
 * \par Packet Lists:
 *
 * Packet list are an important entity in vmkernel as any set of packets
 * are represented through this data structure.
 * Every module will need to deal with it as vmkernel expects it to
 * be able to.
 *
 * For example if a module is intended to manage device driver and want
 * vmkernel to use it in order to communicate with the external world,
 * it will receive packet lists for Tx process.
 *
 ***********************************************************************
 */

#ifndef _VMKAPI_NET_PKTLIST_H_
#define _VMKAPI_NET_PKTLIST_H_

/** \cond never */
#ifndef VMK_HEADER_INCLUDED_FROM_VMKAPI_H
#error This vmkapi file should never be included directly but only via vmkapi.h
#endif
/** \endcond never */

#include "net/vmkapi_net_pkt.h"

/**
 * \ingroup PktList
 * \brief Packet list representation.
 */
typedef struct PktList *vmk_PktList;

/**
 * \ingroup PktList
 * \brief Size of the vmk_PktList structure.
 * \note This value can be different between beta and release builds.
 */
extern const vmk_ByteCountSmall vmk_PktListSizeInBytes;

/**
 * \ingroup PktList
 * \brief Macro for defining a packet list on the stack.
 */
#define VMK_PKTLIST_STACK_DEF(listName)                            \
   char vmkPktList_##listName[vmk_PktListSizeInBytes];             \
   vmk_PktList listName = (vmk_PktList) &vmkPktList_##listName[0];

/**
 * \ingroup PktList
 * \brief Macro for defining a packet list on the stack and initializing it.
 */
#define VMK_PKTLIST_STACK_DEF_INIT(listName)                               \
           char vmkPktList_##listName[vmk_PktListSizeInBytes];             \
           vmk_PktList listName = (vmk_PktList) &vmkPktList_##listName[0]; \
           vmk_PktListInit(listName);

/**
 * \ingroup PktList
 * \brief Packet list iterator
 *
 * Iterators are used to browse packet lists and perform some operations such
 * as adding or removing packets.
 *
 * \note An iterator might be invalidated after a call to any PktList function
 * not using them.
 *
 * \note Only one iterator can be used on a PktList at any time. Furthermore,
 * iterators don't provide any serialization guarantee, it is up to the caller
 * to ensure that a vmk_PktList / vmk_PktListIter is being accessed by a single
 * thread at a time.
 */
typedef struct PktListIter *vmk_PktListIter;

/**
 * \ingroup PktList
 * \brief Macro for defining a packet iterator on the stack
 */
#define VMK_PKTLIST_ITER_STACK_DEF(iterName)                                  \
   char vmkPktListIter_##iterName[vmk_PktListIterSizeOf()];                   \
   vmk_PktListIter iterName = (vmk_PktListIter) &vmkPktListIter_##iterName[0];


/*
 ***********************************************************************
 * vmk_PktListInit --                                             */ /**
 *
 * \ingroup PktList
 * \brief Initialize a packet list.
 *
 * \param[in]  pktList Target packet list
 *
 ***********************************************************************
 */

void vmk_PktListInit(vmk_PktList pktList);

/*
 ***********************************************************************
 * vmk_PktListAlloc --                                            */ /**
 *
 * \ingroup PktList
 * \brief Allocate a new packet list from the heap.
 *
 * \note The new list is not initialized.
 *
 * \param[out]  list               Pointer to hold the allocated list.
 *
 * \retval      VMK_NO_MEMORY      The list could not be allocated.
 * \retval      VMK_OK             The list was successfully allocated.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListAlloc(vmk_PktList *list);


/*
 ***********************************************************************
 * vmk_PktListFree --                                             */ /**
 *
 * \ingroup PktList
 * \brief Free a packet list.
 *
 * \note The list should have previously been allocated with
 * vmk_PktListAlloc.
 *
 * \param[in]   list               Packet list to free.
 *
 * \retval      VMK_OK             The list was successfully freed.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListFree(vmk_PktList list);

/*
 ***********************************************************************
 * vmk_PktListGetCount --                                         */ /**
 *
 * \ingroup PktList
 * \brief Retrieve the number of packets in a packet list.
 *
 * \param[in]   list               Target packet list.
 *
 * \return                         Number of packets in the list.
 *
 ***********************************************************************
 */

vmk_uint32 vmk_PktListGetCount(vmk_PktList list);

/*
 ***********************************************************************
 * vmk_PktListIsEmpty --                                          */ /**
 *
 * \ingroup PktList
 * \brief Check whether a given packet list is empty.
 *
 * \param[in]   list               Target packet list.
 *
 * \retval      VMK_TRUE           List empty.
 * \retval      VMK_FALSE          List not empty.
 *
 ***********************************************************************
 */

static inline vmk_Bool vmk_PktListIsEmpty(vmk_PktList list)
{
   return vmk_PktListGetCount(list) == 0 ? VMK_TRUE : VMK_FALSE;
}

/*
 ***********************************************************************
 * vmk_PktListAppendPkt --                                        */ /**
 *
 * \ingroup PktList
 * \brief Add a packet at the end (tail) of a packet list.
 *
 * \param[in]   list               Target packet list.
 * \param[in]   pkt                Packet to be added.
 *
 ***********************************************************************
 */

void vmk_PktListAppendPkt(vmk_PktList list,
                          vmk_PktHandle *pkt);

/*
 ***********************************************************************
 * vmk_PktListPrependPkt --                                        */ /**
 *
 * \ingroup PktList
 * \brief Add a packet at the front (head) of a packet list.
 *
 * \param[in]  list                Target packet list.
 * \param[in]  pkt                 Packet to be added.
 *
 ***********************************************************************
 */

void vmk_PktListPrependPkt(vmk_PktList list,
                           vmk_PktHandle *pkt);

/*
 ***********************************************************************
 * vmk_PktListGetFirstPkt --                                      */ /**
 *
 * \ingroup PktList
 * \brief Return the first packet (head) of a packet list.
 *
 * \param[in]  list                Target packet list.
 *
 * \retval     NULL                The list is empty.
 * \return                         The first packet of the list.
 *
 ***********************************************************************
 */

vmk_PktHandle    *vmk_PktListGetFirstPkt(vmk_PktList list);

/*
 ***********************************************************************
 * vmk_PktListPopFirstPkt --                                      */ /**
 *
 * \ingroup PktList
 * \brief Return the first packet (head) of a packet list and remove it
 * from the list.
 *
 * \param[in]  list                Target list.
 *
 * \retval     NULL                The list is empty.
 * \return                         The former head of the list.
 *
 ***********************************************************************
 */

vmk_PktHandle    *vmk_PktListPopFirstPkt(vmk_PktList list);

/*
 ***********************************************************************
 * vmk_PktListGetLastPkt --                                       */ /**
 *
 * \ingroup PktList
 * \brief Return the last packet (tail) of a packet list.
 *
 * \param[in]  list                Target list.
 *
 * \retval     NULL                The list is empty.
 * \return                         The last packet of the list.
 *
 ***********************************************************************
 */

vmk_PktHandle    *vmk_PktListGetLastPkt(vmk_PktList list);

/*
 ***********************************************************************
 * vmk_PktListPopLastPkt --                                       */ /**
 *
 * \ingroup PktList
 * \brief Return the last packet (tail) of a packet list and remove it
 * from the list.
 *
 * \param[in]  list                Target list.
 *
 * \retval     NULL                The list is empty.
 * \return                         The former tail of the list.
 *
 ***********************************************************************
 */

vmk_PktHandle    *vmk_PktListPopLastPkt(vmk_PktList list);

/*
 ***********************************************************************
 * vmk_PktListIsConsistent --                                     */ /**
 *
 * \ingroup PktList
 * \brief Check whether the packet list is consistent.
 *
 * \param[in]  list                Target list.
 *
 * \retval     vmk_Bool            TRUE if the list is consistent,
 *                                 FALSE otherwise.
 *
 ***********************************************************************
 */

vmk_Bool         vmk_PktListIsConsistent(vmk_PktList list);

/*
 ***********************************************************************
 * vmk_PktListIterSizeOf --                                       */ /**
 *
 * \ingroup PktList
 * \brief Return the size of a packet list iterator.
 *
 * \return                         The size of a packet iterator.
 *
 ***********************************************************************
 */

vmk_ByteCount    vmk_PktListIterSizeOf(void);

/*
 ***********************************************************************
 * vmk_PktListIterAlloc --                                        */ /**
 *
 * \ingroup PktList
 * \brief Allocate a new packet list iterator from the heap.
 *
 * \param[out] iter                Pointer to hold the allocated
 *                                 iterator.
 *
 * \retval     VMK_NO_MEMORY       The iterator could not be allocated.
 * \retval     VMK_OK              The iterator was successfully
 *                                 allocated.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListIterAlloc(vmk_PktListIter *iter);

/*
 ***********************************************************************
 * vmk_PktListIterFree --                                         */ /**
 *
 * \ingroup PktList
 * \brief Free a packet list iterator.
 *
 * \note The list should have previously been allocated with
 * vmk_PktListAlloc.
 *
 * \param[in]  iter                Iterator to free.
 *
 ***********************************************************************
 */

void             vmk_PktListIterFree(vmk_PktListIter iter);

/*
 ***********************************************************************
 * vmk_PktListIterStart --                                        */ /**
 *
 * \ingroup PktList
 * \brief Set an iterator at the beginning of a packet list.
 *
 * \param[in]  iter                Packet iterator.
 * \param[in]  list                Target packet list.
 *
 ***********************************************************************
 */

void vmk_PktListIterStart(vmk_PktListIter iter,
                          vmk_PktList list);


/*
 ***********************************************************************
 * vmk_PktListIterMove --                                         */ /**
 *
 * \brief Move a packet list iterator to the next packet in the list.
 *
 * \param[in]  iter                Packet iterator.
 *
 * \retval     VMK_LIMIT_EXCEEDED  The iterator does not point to any
 *                                 packet or is at the end of the list.
 * \retval     VMK_OK              Iterator successfully moved.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListIterMove(vmk_PktListIter iter);


/*
 ***********************************************************************
 * vmk_PktListIterIsAtEnd --                                      */ /**
 *
 * \brief Check whether a packet list iterator has reached the end of
 * a packet list.
 *
 * \param[in]  iter                Packet iterator.
 *
 * \retval     vmk_Bool            TRUE if it is at the end of the list,
 *                                 FALSE otherwise
 *
 ***********************************************************************
 */

vmk_Bool         vmk_PktListIterIsAtEnd(vmk_PktListIter iter);


/*
 ***********************************************************************
 * vmk_PktListIterGetPkt --                                       */ /**
 *
 * \brief Retrieve the packet pointed by a packet list iterator.
 *
 * \param[in]  iter          Packet iterator.
 *
 * \retval     NULL          The iterator is not pointing to any packet.
 * \return                   The retrieved packet.
 *
 ***********************************************************************
 */

vmk_PktHandle   *vmk_PktListIterGetPkt(vmk_PktListIter iter);


/*
 ***********************************************************************
 * vmk_PktListIterRemovePkt --                                    */ /**
 *
 * \brief Retrieve the packet pointed by an iterator and remove it from
 * the packet list.
 *
 * \note The iterator is moved to the next packet.
 *
 * \param[in]  iter          Packet iterator.
 * \param[out] pkt           Address of pointer to update with a pointer
 *                           to the removed pkt. Can be NULL, in which
 *                           case it will be ignored.
 *
 * \retval     VMK_LIMIT_EXCEEDED The iterator does not point to any
 *                                packet or is at the end of the list.
 * \retval     VMK_OK             If successful.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListIterRemovePkt(vmk_PktListIter iter,
                                          vmk_PktHandle **pkt);

/*
 ***********************************************************************
 * vmk_PktListIterReplace --                                      */ /**
 *
 * \brief Replace the packet pointed by an iterator and release it.
 *
 * \note The iterator is moved to the new packet.
 *
 * \param[in]  iter                Packet iterator.
 * \param[in]  pkt                 Packet to be inserted.
 *
 * \retval     VMK_LIMIT_EXCEEDED  The iterator does not point to any
 *                                 packet or is at the end of the list.
 * \retval     VMK_OK              The packet was successfully replaced.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListIterReplace(vmk_PktListIter iter,
                                        vmk_PktHandle *pkt);

/*
 ***********************************************************************
 * vmk_PktListIterInsertPktAfter --                               */ /**
 *
 * \brief Insert a packet after the iterator.
 *
 * \note If the packet list was empty, the iterator is moved to the new
 * packet.
 *
 * \param[in]  iter                Packet iterator.
 * \param[in]  pkt                 Packet to be inserted.
 *
 * \retval     VMK_LIMIT_EXCEEDED  The iterator is at the end of the
 *                                 list.
 * \retval     VMK_OK              The packet was successfully inserted.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListIterInsertPktAfter(vmk_PktListIter iter,
                                               vmk_PktHandle *pkt);

/*
 ***********************************************************************
 * vmk_PktListIterInsertPktBefore --                              */ /**
 *
 * \brief Insert a packet before the iterator.
 *
 * \note If the list was empty, the iterator is moved at the new end.
 *
 * \param[in]  iter                Packet iterator.
 * \param[in]  pkt                 Packet to be inserted.
 *
 * \retval     VMK_OK              Always succeeds.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListIterInsertPktBefore(vmk_PktListIter iter,
                                                vmk_PktHandle *pkt);


/*
 ***********************************************************************
 * vmk_PktListIterInsertListAfter --                              */ /**
 *
 * \brief Insert a packet list after the iterator.

 * \note If the original packet list was empty, the iterator is moved to
 * the first element of the inserted list.
 *
 * \note The inserted list is reinitialized.
 *
 * \param[in]  iter                Packet iterator.
 * \param[in]  list                Packet list to be inserted.
 *
 * \retval     VMK_LIMIT_EXCEEDED  The iterator is at the end of the
 *                                 list.
 * \retval     VMK_OK              The packet was successfully inserted.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListIterInsertListAfter(vmk_PktListIter iter,
                                                vmk_PktList list);


/*
 ***********************************************************************
 * vmk_PktListIterInsertListBefore --                             */ /**
 *
 * \brief Insert a packet list before the iterator.

 * \note If the packet list was empty, the iterator is now at the end of
 * the new packet list.

 * \note The inserted list is reinitialized.
 *
 * \param[in]  iter                Packet iterator.
 * \param[in]  list                Packet list to be inserted.
 *
 * \retval     VMK_OK              Always succeeds.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListIterInsertListBefore(vmk_PktListIter iter,
                                                 vmk_PktList list);


/*
 ***********************************************************************
 * vmk_PktListIterSplitListAfter --                               */ /**
 *
 * \brief Split the current list after iterator.
 *
 * All the packets after the iterator will be moved to a new list.
 *
 * \note The iterator is set at the end of the original list.
 *
 * \note The split list will be clobbered.
 *
 * \param[in]  iter                Packet iterator.
 * \param[out] splitList           Pointer to hold the new list.
 *
 * \retval     VMK_LIMIT_EXCEEDED  The iterator does not point to any
 *                                 packet or is at the end of the list.
 * \retval     VMK_OK              List successfully split.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListIterSplitListAfter(vmk_PktListIter iter,
                                               vmk_PktList *splitList);


/*
 ***********************************************************************
 * vmk_PktListIterSplitListBefore --                              */ /**
 *
 * \brief Split the current list before iterator.
 *
 * All the packets before the iterator will be moved to a new list.
 *
 * \note The iterator is set at the beginning of the original list.
 *
 * \note The split list will be clobbered.
 *
 * \param[in]  iter                Packet iterator.
 * \param[out] splitList           Pointer to hold the new list.
 *
 * \retval     VMK_OK              Always succeeds.
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktListIterSplitListBefore(vmk_PktListIter iter,
                                                vmk_PktList *splitList);


/*
 ***********************************************************************
 * vmk_PktListAppend --                                           */ /**
 *
 * \ingroup PktList
 * \brief Append a packet list behind another list.
 *
 * \note srcList is appended to the end of dstList.
 *
 * \note srcList is emptied and reinitialized.
 *
 * \param[in]  dstList     Target list to append to
 * \param[in]  srcList     List to append from
 *
 ***********************************************************************
 */

void vmk_PktListAppend(vmk_PktList dstList,
                       vmk_PktList srcList);


/*
 ***********************************************************************
 * vmk_PktListPrepend --                                          */ /**
 *
 * \ingroup PktList
 * \brief Prepend a packet list in front of another list.
 *
 * \note srcList is prepended to the beginning of dstList.
 *
 * \note srcList is emptied and reinitialized.
 *
 * \param[in]  dstList     Target list to prepend to
 * \param[in]  srcList     List to prepend from
 *
 ***********************************************************************
 */

void vmk_PktListPrepend(vmk_PktList dstList,
                        vmk_PktList srcList);


/*
 ***********************************************************************
 * vmk_PktListReleaseAllPkts --                                   */ /**
 *
 * \ingroup PktList
 * \brief Release all the packets and empty the list.
 *
 * \param[in]  list     Target list
 *
 ***********************************************************************
 */

void vmk_PktListReleaseAllPkts(vmk_PktList list);


/*
 ***********************************************************************
 * vmk_PktTcpSegmentation --                                      */ /**
 *
 * \ingroup PktList
 * \brief Perform Software TSO.
 *
 * The TSO friendly TCP/IP stack will make sure the next IP frame won't
 * have a conflicting IP id #. ipId are incremented starting with the
 * ident of the original (non-segmented) packet.
 *
 * \note The list must be empty.
 *
 * \note It is the responsibility of the caller to ensure the entire
 *       ip/tcp header is contained within frameVA/frameMappedLen.
 *
 * \param[in]   pkt         Packet to segment
 * \param[out]  list        List of segment packets
 *
 * \retval      VMK_OK      If the segmentation was successful
 * \retval      VMK_FAILURE Otherwise
 *
 ***********************************************************************
 */

VMK_ReturnStatus vmk_PktTcpSegmentation(vmk_PktHandle *pkt,
                                        vmk_PktList list);

#endif /* _VMKAPI_NET_PKTLIST_H_ */
/** @} */
/** @} */