2 * QEMU rocker switch emulation
4 * Copyright (c) 2014 Scott Feldman <sfeldma@gmail.com>
5 * Copyright (c) 2014 Jiri Pirko <jiri@resnulli.us>
6 * Copyright (c) 2014 Neil Horman <nhorman@tuxdriver.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
22 #include "qemu/sockets.h"
23 #include "qom/object.h"
25 #if defined(DEBUG_ROCKER)
26 # define DPRINTF(fmt, ...) \
28 g_autoptr(GDateTime) now = g_date_time_new_now_local(); \
29 g_autofree char *nowstr = g_date_time_format(now, "%T.%f");\
30 fprintf(stderr, "%s ROCKER: " fmt, nowstr, ## __VA_ARGS__);\
33 static inline G_GNUC_PRINTF(1, 2) int DPRINTF(const char *fmt
, ...)
39 #define __le16 uint16_t
40 #define __le32 uint32_t
41 #define __le64 uint64_t
43 #define __be16 uint16_t
44 #define __be32 uint32_t
45 #define __be64 uint64_t
47 static inline bool ipv4_addr_is_multicast(__be32 addr
)
49 return (addr
& htonl(0xf0000000)) == htonl(0xe0000000);
52 typedef struct ipv6_addr
{
60 static inline bool ipv6_addr_is_multicast(const Ipv6Addr
*addr
)
62 return (addr
->addr32
[0] & htonl(0xFF000000)) == htonl(0xFF000000);
65 typedef struct world World
;
66 typedef struct desc_info DescInfo
;
67 typedef struct desc_ring DescRing
;
69 #define TYPE_ROCKER "rocker"
70 typedef struct rocker Rocker
;
71 DECLARE_INSTANCE_CHECKER(Rocker
, ROCKER
,
74 Rocker
*rocker_find(const char *name
);
75 int rocker_event_link_changed(Rocker
*r
, uint32_t pport
, bool link_up
);
76 int rocker_event_mac_vlan_seen(Rocker
*r
, uint32_t pport
, uint8_t *addr
,
78 int rx_produce(World
*world
, uint32_t pport
,
79 const struct iovec
*iov
, int iovcnt
, uint8_t copy_to_cpu
);
80 int rocker_port_eg(Rocker
*r
, uint32_t pport
,
81 const struct iovec
*iov
, int iovcnt
);