1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef ROCKER_H
20#define ROCKER_H
21
22#include "qemu/sockets.h"
23#include "qom/object.h"
24
25#if defined(DEBUG_ROCKER)
26# define DPRINTF(fmt, ...) \
27 do { \
28 struct timeval tv; \
29 char timestr[64]; \
30 time_t now; \
31 gettimeofday(&tv, NULL); \
32 now = tv.tv_sec; \
33 strftime(timestr, sizeof(timestr), "%T", localtime(&now)); \
34 fprintf(stderr, "%s.%06ld ", timestr, tv.tv_usec); \
35 fprintf(stderr, "ROCKER: " fmt, ## __VA_ARGS__); \
36 } while (0)
37#else
38static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...)
39{
40 return 0;
41}
42#endif
43
44#define __le16 uint16_t
45#define __le32 uint32_t
46#define __le64 uint64_t
47
48#define __be16 uint16_t
49#define __be32 uint32_t
50#define __be64 uint64_t
51
52static inline bool ipv4_addr_is_multicast(__be32 addr)
53{
54 return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
55}
56
57typedef struct ipv6_addr {
58 union {
59 uint8_t addr8[16];
60 __be16 addr16[8];
61 __be32 addr32[4];
62 };
63} Ipv6Addr;
64
65static inline bool ipv6_addr_is_multicast(const Ipv6Addr *addr)
66{
67 return (addr->addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000);
68}
69
70typedef struct world World;
71typedef struct desc_info DescInfo;
72typedef struct desc_ring DescRing;
73
74#define TYPE_ROCKER "rocker"
75typedef struct rocker Rocker;
76DECLARE_INSTANCE_CHECKER(Rocker, ROCKER,
77 TYPE_ROCKER)
78
79Rocker *rocker_find(const char *name);
80uint32_t rocker_fp_ports(Rocker *r);
81int rocker_event_link_changed(Rocker *r, uint32_t pport, bool link_up);
82int rocker_event_mac_vlan_seen(Rocker *r, uint32_t pport, uint8_t *addr,
83 uint16_t vlan_id);
84int rx_produce(World *world, uint32_t pport,
85 const struct iovec *iov, int iovcnt, uint8_t copy_to_cpu);
86int rocker_port_eg(Rocker *r, uint32_t pport,
87 const struct iovec *iov, int iovcnt);
88
89#endif
90