ccci_bm.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef __CCCI_BM_H__
  2. #define __CCCI_BM_H__
  3. #include "ccci_core.h"
  4. #include "ccci_config.h"
  5. /*
  6. * the actually allocated skb's buffer is much bigger than what we request, so when we judge
  7. * which pool it belongs, the comparision is quite tricky...
  8. * another trikcy part is, ccci_fsd use CCCI_MTU as its payload size, but it treat both ccci_header
  9. * and op_id as header, so the total packet size will be CCCI_MTU+sizeof(ccci_header)+sizeof(
  10. * unsigned int). check port_char's write() and ccci_fsd for detail.
  11. *
  12. * beaware, these macros are also used by CLDMA
  13. */
  14. #define SKB_4K (CCCI_MTU+128) /* user MTU+CCCI_H+extra(ex. ccci_fsd's OP_ID), for genral packet */
  15. #define SKB_1_5K (CCCI_NET_MTU+16) /* net MTU+CCCI_H, for network packet */
  16. #define SKB_16 16 /* for struct ccci_header */
  17. #define NET_RX_BUF SKB_4K
  18. #ifdef NET_SKBUFF_DATA_USES_OFFSET
  19. #define skb_size(x) ((x)->end)
  20. #define skb_data_size(x) ((x)->head + (x)->end - (x)->data)
  21. #else
  22. #define skb_size(x) ((x)->end - (x)->head)
  23. #define skb_data_size(x) ((x)->end - (x)->data)
  24. #endif
  25. struct ccci_req_queue {
  26. unsigned int magic_header;
  27. struct list_head req_list;
  28. unsigned int count;
  29. unsigned int max_len;
  30. spinlock_t req_lock;
  31. wait_queue_head_t req_wq;
  32. unsigned int magic_footer;
  33. };
  34. struct ccci_skb_queue {
  35. unsigned int magic_header;
  36. struct sk_buff_head skb_list;
  37. unsigned int max_len;
  38. struct work_struct reload_work;
  39. unsigned char pre_filled;
  40. unsigned int max_history;
  41. unsigned int magic_footer;
  42. };
  43. struct sk_buff *ccci_alloc_skb(int size, char from_pool, char blocking);
  44. void ccci_free_skb(struct sk_buff *skb, DATA_POLICY policy);
  45. struct sk_buff *ccci_skb_dequeue(struct ccci_skb_queue *queue);
  46. void ccci_skb_enqueue(struct ccci_skb_queue *queue, struct sk_buff *newsk);
  47. void ccci_skb_queue_init(struct ccci_skb_queue *queue, unsigned int skb_size, unsigned int max_len,
  48. char fill_now);
  49. struct ccci_request *ccci_alloc_req(DIRECTION dir, int size, char blk1, char blk2);
  50. void ccci_free_req(struct ccci_request *req);
  51. void ccci_dump_req(struct ccci_request *req);
  52. void ccci_mem_dump(int md_id, void *start_addr, int len);
  53. void ccci_cmpt_mem_dump(int md_id, void *start_addr, int len);
  54. #endif /* __CCCI_BM_H__ */