af_can.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of Volkswagen nor the names of its contributors
  14. * may be used to endorse or promote products derived from this software
  15. * without specific prior written permission.
  16. *
  17. * Alternatively, provided that this notice is retained in full, this
  18. * software may be distributed under the terms of the GNU General
  19. * Public License ("GPL") version 2, in which case the provisions of the
  20. * GPL apply INSTEAD OF those given above.
  21. *
  22. * The provided data structures and external interfaces from this code
  23. * are not restricted to be used by modules with a GPL compatible license.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  26. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  27. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  28. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  29. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  30. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  31. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  32. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  34. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  35. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  36. * DAMAGE.
  37. *
  38. */
  39. #ifndef AF_CAN_H
  40. #define AF_CAN_H
  41. #include <linux/skbuff.h>
  42. #include <linux/netdevice.h>
  43. #include <linux/list.h>
  44. #include <linux/rcupdate.h>
  45. #include <linux/can.h>
  46. /* af_can rx dispatcher structures */
  47. struct receiver {
  48. struct hlist_node list;
  49. canid_t can_id;
  50. canid_t mask;
  51. unsigned long matches;
  52. void (*func)(struct sk_buff *, void *);
  53. void *data;
  54. char *ident;
  55. struct sock *sk;
  56. struct rcu_head rcu;
  57. };
  58. #define CAN_SFF_RCV_ARRAY_SZ (1 << CAN_SFF_ID_BITS)
  59. #define CAN_EFF_RCV_HASH_BITS 10
  60. #define CAN_EFF_RCV_ARRAY_SZ (1 << CAN_EFF_RCV_HASH_BITS)
  61. enum { RX_ERR, RX_ALL, RX_FIL, RX_INV, RX_MAX };
  62. /* per device receive filters linked at dev->ml_priv */
  63. struct can_dev_rcv_lists {
  64. struct hlist_head rx[RX_MAX];
  65. struct hlist_head rx_sff[CAN_SFF_RCV_ARRAY_SZ];
  66. struct hlist_head rx_eff[CAN_EFF_RCV_ARRAY_SZ];
  67. int remove_on_zero_entries;
  68. int entries;
  69. };
  70. /* statistic structures */
  71. /* can be reset e.g. by can_init_stats() */
  72. struct s_stats {
  73. unsigned long jiffies_init;
  74. unsigned long rx_frames;
  75. unsigned long tx_frames;
  76. unsigned long matches;
  77. unsigned long total_rx_rate;
  78. unsigned long total_tx_rate;
  79. unsigned long total_rx_match_ratio;
  80. unsigned long current_rx_rate;
  81. unsigned long current_tx_rate;
  82. unsigned long current_rx_match_ratio;
  83. unsigned long max_rx_rate;
  84. unsigned long max_tx_rate;
  85. unsigned long max_rx_match_ratio;
  86. unsigned long rx_frames_delta;
  87. unsigned long tx_frames_delta;
  88. unsigned long matches_delta;
  89. };
  90. /* persistent statistics */
  91. struct s_pstats {
  92. unsigned long stats_reset;
  93. unsigned long user_reset;
  94. unsigned long rcv_entries;
  95. unsigned long rcv_entries_max;
  96. };
  97. /* function prototypes for the CAN networklayer procfs (proc.c) */
  98. void can_init_proc(struct net *net);
  99. void can_remove_proc(struct net *net);
  100. void can_stat_update(struct timer_list *t);
  101. #endif /* AF_CAN_H */