selftests.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _NET_SELFTESTS
  3. #define _NET_SELFTESTS
  4. #include <linux/ethtool.h>
  5. #include <linux/netdevice.h>
  6. struct net_packet_attrs {
  7. const unsigned char *src;
  8. const unsigned char *dst;
  9. u32 ip_src;
  10. u32 ip_dst;
  11. bool tcp;
  12. u16 sport;
  13. u16 dport;
  14. int timeout;
  15. int size;
  16. int max_size;
  17. u8 id;
  18. u16 queue_mapping;
  19. bool bad_csum;
  20. };
  21. struct net_test_priv {
  22. struct net_packet_attrs *packet;
  23. struct packet_type pt;
  24. struct completion comp;
  25. int double_vlan;
  26. int vlan_id;
  27. int ok;
  28. };
  29. struct netsfhdr {
  30. __be32 version;
  31. __be64 magic;
  32. u8 id;
  33. } __packed;
  34. #define NET_TEST_PKT_SIZE (sizeof(struct ethhdr) + sizeof(struct iphdr) + \
  35. sizeof(struct netsfhdr))
  36. #define NET_TEST_PKT_MAGIC 0xdeadcafecafedeadULL
  37. #define NET_LB_TIMEOUT msecs_to_jiffies(200)
  38. #if IS_ENABLED(CONFIG_NET_SELFTESTS)
  39. struct sk_buff *net_test_get_skb(struct net_device *ndev, u8 id,
  40. struct net_packet_attrs *attr);
  41. void net_selftest(struct net_device *ndev, struct ethtool_test *etest,
  42. u64 *buf);
  43. int net_selftest_get_count(void);
  44. void net_selftest_get_strings(u8 *data);
  45. #else
  46. static inline struct sk_buff *net_test_get_skb(struct net_device *ndev, u8 id,
  47. struct net_packet_attrs *attr)
  48. {
  49. return NULL;
  50. }
  51. static inline void net_selftest(struct net_device *ndev, struct ethtool_test *etest,
  52. u64 *buf)
  53. {
  54. }
  55. static inline int net_selftest_get_count(void)
  56. {
  57. return 0;
  58. }
  59. static inline void net_selftest_get_strings(u8 *data)
  60. {
  61. }
  62. #endif
  63. #endif /* _NET_SELFTESTS */