Lines Matching +full:port +full:-
2 * QEMU rocker switch emulation - front-panel ports
18 #include "qapi/qapi-types-rocker.h"
44 char *fp_port_get_name(FpPort *port) in fp_port_get_name() argument
46 return port->name; in fp_port_get_name()
49 bool fp_port_get_link_up(FpPort *port) in fp_port_get_link_up() argument
51 return !qemu_get_queue(port->nic)->link_down; in fp_port_get_link_up()
54 RockerPort *fp_port_get_info(FpPort *port) in fp_port_get_info() argument
58 value->name = g_strdup(port->name); in fp_port_get_info()
59 value->enabled = port->enabled; in fp_port_get_info()
60 value->link_up = fp_port_get_link_up(port); in fp_port_get_info()
61 value->speed = port->speed; in fp_port_get_info()
62 value->duplex = port->duplex; in fp_port_get_info()
63 value->autoneg = port->autoneg; in fp_port_get_info()
67 void fp_port_get_macaddr(FpPort *port, MACAddr *macaddr) in fp_port_get_macaddr() argument
69 memcpy(macaddr->a, port->conf.macaddr.a, sizeof(macaddr->a)); in fp_port_get_macaddr()
72 void fp_port_set_macaddr(FpPort *port, MACAddr *macaddr) in fp_port_set_macaddr() argument
75 * XXX memcpy(port->conf.macaddr.a, macaddr.a, sizeof(port->conf.macaddr.a)); in fp_port_set_macaddr()
79 uint8_t fp_port_get_learning(FpPort *port) in fp_port_get_learning() argument
81 return port->learning; in fp_port_get_learning()
84 void fp_port_set_learning(FpPort *port, uint8_t learning) in fp_port_set_learning() argument
86 port->learning = learning; in fp_port_set_learning()
89 int fp_port_get_settings(FpPort *port, uint32_t *speed, in fp_port_get_settings() argument
92 *speed = port->speed; in fp_port_get_settings()
93 *duplex = port->duplex; in fp_port_get_settings()
94 *autoneg = port->autoneg; in fp_port_get_settings()
99 int fp_port_set_settings(FpPort *port, uint32_t speed, in fp_port_set_settings() argument
104 port->speed = speed; in fp_port_set_settings()
105 port->duplex = duplex; in fp_port_set_settings()
106 port->autoneg = autoneg; in fp_port_set_settings()
111 bool fp_port_from_pport(uint32_t pport, uint32_t *port) in fp_port_from_pport() argument
116 *port = pport - 1; in fp_port_from_pport()
120 int fp_port_eg(FpPort *port, const struct iovec *iov, int iovcnt) in fp_port_eg() argument
122 NetClientState *nc = qemu_get_queue(port->nic); in fp_port_eg()
124 if (port->enabled) { in fp_port_eg()
134 FpPort *port = qemu_get_nic_opaque(nc); in fp_port_receive_iov() local
136 /* If the port is disabled, we want to drop this pkt in fp_port_receive_iov()
138 * any stale pkts getting into the device when the port in fp_port_receive_iov()
142 if (!port->enabled) { in fp_port_receive_iov()
143 return -1; in fp_port_receive_iov()
146 return world_ingress(port->world, port->pport, iov, iovcnt); in fp_port_receive_iov()
166 FpPort *port = qemu_get_nic_opaque(nc); in fp_port_set_link_status() local
168 rocker_event_link_changed(port->r, port->pport, !nc->link_down); in fp_port_set_link_status()
180 World *fp_port_get_world(FpPort *port) in fp_port_get_world() argument
182 return port->world; in fp_port_get_world()
185 void fp_port_set_world(FpPort *port, World *world) in fp_port_set_world() argument
187 DPRINTF("port %d setting world \"%s\"\n", port->index, world_name(world)); in fp_port_set_world()
188 port->world = world; in fp_port_set_world()
191 bool fp_port_check_world(FpPort *port, World *world) in fp_port_check_world() argument
193 return port->world == world; in fp_port_check_world()
196 bool fp_port_enabled(FpPort *port) in fp_port_enabled() argument
198 return port->enabled; in fp_port_enabled()
201 static void fp_port_set_link(FpPort *port, bool up) in fp_port_set_link() argument
203 NetClientState *nc = qemu_get_queue(port->nic); in fp_port_set_link()
205 if (up == nc->link_down) { in fp_port_set_link()
206 nc->link_down = !up; in fp_port_set_link()
207 nc->info->link_status_changed(nc); in fp_port_set_link()
211 void fp_port_enable(FpPort *port) in fp_port_enable() argument
213 fp_port_set_link(port, true); in fp_port_enable()
214 port->enabled = true; in fp_port_enable()
215 DPRINTF("port %d enabled\n", port->index); in fp_port_enable()
218 void fp_port_disable(FpPort *port) in fp_port_disable() argument
220 port->enabled = false; in fp_port_disable()
221 fp_port_set_link(port, false); in fp_port_disable()
222 DPRINTF("port %d disabled\n", port->index); in fp_port_disable()
229 FpPort *port = g_new0(FpPort, 1); in fp_port_alloc() local
231 port->r = r; in fp_port_alloc()
232 port->index = index; in fp_port_alloc()
233 port->pport = index + 1; in fp_port_alloc()
235 /* front-panel switch port names are 1-based */ in fp_port_alloc()
237 port->name = g_strdup_printf("%sp%d", sw_name, port->pport); in fp_port_alloc()
239 memcpy(port->conf.macaddr.a, start_mac, sizeof(port->conf.macaddr.a)); in fp_port_alloc()
240 port->conf.macaddr.a[5] += index; in fp_port_alloc()
241 port->conf.bootindex = -1; in fp_port_alloc()
242 port->conf.peers = *peers; in fp_port_alloc()
244 port->nic = qemu_new_nic(&fp_port_info, &port->conf, sw_name, NULL, in fp_port_alloc()
245 &DEVICE(r)->mem_reentrancy_guard, port); in fp_port_alloc()
246 qemu_format_nic_info_str(qemu_get_queue(port->nic), in fp_port_alloc()
247 port->conf.macaddr.a); in fp_port_alloc()
249 fp_port_reset(port); in fp_port_alloc()
251 return port; in fp_port_alloc()
254 void fp_port_free(FpPort *port) in fp_port_free() argument
256 qemu_del_nic(port->nic); in fp_port_free()
257 g_free(port->name); in fp_port_free()
258 g_free(port); in fp_port_free()
261 void fp_port_reset(FpPort *port) in fp_port_reset() argument
263 fp_port_disable(port); in fp_port_reset()
264 port->speed = 10000; /* 10Gbps */ in fp_port_reset()
265 port->duplex = DUPLEX_FULL; in fp_port_reset()
266 port->autoneg = 0; in fp_port_reset()