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