skbuff.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /******************************************************************************
  2. * Copyright (c) 2013-2016 Realtek Semiconductor Corp.
  3. *
  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. #ifndef __SKBUFF_H__
  17. #define __SKBUFF_H__
  18. struct sk_buff_head {
  19. struct list_head *next, *prev;
  20. unsigned int qlen;
  21. };
  22. #if CONFIG_TRACE_SKB
  23. #define TRACE_SKB_DEPTH 8
  24. #endif
  25. struct sk_buff {
  26. /* These two members must be first. */
  27. struct sk_buff *next; /* Next buffer in list */
  28. struct sk_buff *prev; /* Previous buffer in list */
  29. struct sk_buff_head *list; /* List we are on */
  30. unsigned char *head; /* Head of buffer */
  31. unsigned char *data; /* Data head pointer */
  32. unsigned char *tail; /* Tail pointer */
  33. unsigned char *end; /* End pointer */
  34. void *dev; /* Device we arrived on/are leaving by */
  35. unsigned int len; /* Length of actual data */
  36. #if CONFIG_TRACE_SKB
  37. unsigned int liston[TRACE_SKB_DEPTH]; /* Trace the Lists we went through */
  38. const char *funcname[TRACE_SKB_DEPTH];
  39. unsigned int list_idx; /* Trace the List we are on */
  40. #endif
  41. int zerocp_flag;
  42. int dyalloc_flag;
  43. unsigned char type_flag;
  44. };
  45. unsigned char *skb_put(struct sk_buff *skb, unsigned int len);
  46. unsigned char *skb_pull(struct sk_buff *skb, unsigned int len);
  47. void skb_reserve(struct sk_buff *skb, unsigned int len);
  48. void skb_assign_buf(struct sk_buff *skb, unsigned char *buf, unsigned int len);
  49. unsigned char *skb_tail_pointer(const struct sk_buff *skb);
  50. void skb_set_tail_pointer(struct sk_buff *skb, const int offset);
  51. unsigned char *skb_end_pointer(const struct sk_buff *skb);
  52. void skb_queue_head_init(struct sk_buff_head *list);
  53. struct sk_buff *skb_dequeue(struct sk_buff_head *list);
  54. void skb_reset_tail_pointer(struct sk_buff *skb);
  55. void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk);
  56. signed int skb_queue_len(const struct sk_buff_head *list_);
  57. void init_skb_pool(void);
  58. void init_skb_data_pool(void);
  59. #ifdef CONFIG_TX_ZERO_COPY
  60. struct sk_buff *dev_alloc_tx_skb_0copy();
  61. #endif
  62. struct sk_buff *dev_alloc_tx_skb(unsigned int length, unsigned int reserve_len);
  63. struct sk_buff *dev_alloc_rx_skb(unsigned int length, unsigned int reserve_len);
  64. void kfree_skb(struct sk_buff *skb);
  65. #endif //__SKBUFF_H__