Lines Matching refs:dev
114 SpaprVioVlan *dev = qemu_get_nic_opaque(nc); in spapr_vlan_can_receive() local
116 return dev->isopen && dev->rx_bufs > 0; in spapr_vlan_can_receive()
126 static void spapr_vlan_record_dropped_rx_frame(SpaprVioVlan *dev) in spapr_vlan_record_dropped_rx_frame() argument
130 cnt = vio_ldq(&dev->sdev, dev->buf_list + 4096 - 8); in spapr_vlan_record_dropped_rx_frame()
131 vio_stq(&dev->sdev, dev->buf_list + 4096 - 8, cnt + 1); in spapr_vlan_record_dropped_rx_frame()
137 static vlan_bd_t spapr_vlan_get_rx_bd_from_pool(SpaprVioVlan *dev, in spapr_vlan_get_rx_bd_from_pool() argument
144 if (dev->rx_pool[pool]->count > 0 && in spapr_vlan_get_rx_bd_from_pool()
145 dev->rx_pool[pool]->bufsize >= size + 8) { in spapr_vlan_get_rx_bd_from_pool()
156 dev->rx_pool[pool]->count, in spapr_vlan_get_rx_bd_from_pool()
157 dev->rx_bufs); in spapr_vlan_get_rx_bd_from_pool()
160 dev->rx_pool[pool]->count--; in spapr_vlan_get_rx_bd_from_pool()
161 bd = dev->rx_pool[pool]->bds[dev->rx_pool[pool]->count]; in spapr_vlan_get_rx_bd_from_pool()
162 dev->rx_pool[pool]->bds[dev->rx_pool[pool]->count] = 0; in spapr_vlan_get_rx_bd_from_pool()
171 static vlan_bd_t spapr_vlan_get_rx_bd_from_page(SpaprVioVlan *dev, in spapr_vlan_get_rx_bd_from_page() argument
174 int buf_ptr = dev->use_buf_ptr; in spapr_vlan_get_rx_bd_from_page()
183 bd = vio_ldq(&dev->sdev, dev->buf_list + buf_ptr); in spapr_vlan_get_rx_bd_from_page()
187 && buf_ptr != dev->use_buf_ptr); in spapr_vlan_get_rx_bd_from_page()
195 dev->use_buf_ptr = buf_ptr; in spapr_vlan_get_rx_bd_from_page()
196 vio_stq(&dev->sdev, dev->buf_list + dev->use_buf_ptr, 0); in spapr_vlan_get_rx_bd_from_page()
198 trace_spapr_vlan_get_rx_bd_from_page_found(dev->use_buf_ptr, dev->rx_bufs); in spapr_vlan_get_rx_bd_from_page()
206 SpaprVioVlan *dev = qemu_get_nic_opaque(nc); in spapr_vlan_receive() local
207 SpaprVioDevice *sdev = VIO_SPAPR_DEVICE(dev); in spapr_vlan_receive()
208 vlan_bd_t rxq_bd = vio_ldq(sdev, dev->buf_list + VLAN_RXQ_BD_OFF); in spapr_vlan_receive()
213 trace_spapr_vlan_receive(sdev->qdev.id, dev->rx_bufs); in spapr_vlan_receive()
215 if (!dev->isopen) { in spapr_vlan_receive()
219 if (!dev->rx_bufs) { in spapr_vlan_receive()
220 spapr_vlan_record_dropped_rx_frame(dev); in spapr_vlan_receive()
224 if (dev->compat_flags & SPAPRVLAN_FLAG_RX_BUF_POOLS) { in spapr_vlan_receive()
225 bd = spapr_vlan_get_rx_bd_from_pool(dev, size); in spapr_vlan_receive()
227 bd = spapr_vlan_get_rx_bd_from_page(dev, size); in spapr_vlan_receive()
230 spapr_vlan_record_dropped_rx_frame(dev); in spapr_vlan_receive()
234 dev->rx_bufs--; in spapr_vlan_receive()
250 vio_stq(sdev, VLAN_BD_ADDR(rxq_bd) + dev->rxq_ptr + 8, handle); in spapr_vlan_receive()
251 vio_stl(sdev, VLAN_BD_ADDR(rxq_bd) + dev->rxq_ptr + 4, size); in spapr_vlan_receive()
252 vio_sth(sdev, VLAN_BD_ADDR(rxq_bd) + dev->rxq_ptr + 2, 8); in spapr_vlan_receive()
253 vio_stb(sdev, VLAN_BD_ADDR(rxq_bd) + dev->rxq_ptr, control); in spapr_vlan_receive()
255 trace_spapr_vlan_receive_wrote(dev->rxq_ptr, in spapr_vlan_receive()
257 dev->rxq_ptr), in spapr_vlan_receive()
259 dev->rxq_ptr + 8)); in spapr_vlan_receive()
261 dev->rxq_ptr += 16; in spapr_vlan_receive()
262 if (dev->rxq_ptr >= VLAN_BD_LEN(rxq_bd)) { in spapr_vlan_receive()
263 dev->rxq_ptr = 0; in spapr_vlan_receive()
264 vio_stq(sdev, dev->buf_list + VLAN_RXQ_BD_OFF, rxq_bd ^ VLAN_BD_TOGGLE); in spapr_vlan_receive()
283 SpaprVioVlan *dev = opaque; in spapr_vlan_flush_rx_queue() local
285 qemu_flush_queued_packets(qemu_get_queue(dev->nic)); in spapr_vlan_flush_rx_queue()
301 SpaprVioVlan *dev = VIO_SPAPR_VLAN_DEVICE(sdev); in spapr_vlan_reset() local
304 dev->buf_list = 0; in spapr_vlan_reset()
305 dev->rx_bufs = 0; in spapr_vlan_reset()
306 dev->isopen = 0; in spapr_vlan_reset()
308 if (dev->compat_flags & SPAPRVLAN_FLAG_RX_BUF_POOLS) { in spapr_vlan_reset()
310 spapr_vlan_reset_rx_pool(dev->rx_pool[i]); in spapr_vlan_reset()
314 memcpy(&dev->nicconf.macaddr.a, &dev->perm_mac.a, in spapr_vlan_reset()
315 sizeof(dev->nicconf.macaddr.a)); in spapr_vlan_reset()
316 qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.macaddr.a); in spapr_vlan_reset()
321 SpaprVioVlan *dev = VIO_SPAPR_VLAN_DEVICE(sdev); in spapr_vlan_realize() local
323 qemu_macaddr_default_if_unset(&dev->nicconf.macaddr); in spapr_vlan_realize()
325 memcpy(&dev->perm_mac.a, &dev->nicconf.macaddr.a, sizeof(dev->perm_mac.a)); in spapr_vlan_realize()
327 dev->nic = qemu_new_nic(&net_spapr_vlan_info, &dev->nicconf, in spapr_vlan_realize()
329 &sdev->qdev.mem_reentrancy_guard, dev); in spapr_vlan_realize()
330 qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.macaddr.a); in spapr_vlan_realize()
332 dev->rxp_timer = timer_new_us(QEMU_CLOCK_VIRTUAL, spapr_vlan_flush_rx_queue, in spapr_vlan_realize()
333 dev); in spapr_vlan_realize()
338 SpaprVioVlan *dev = VIO_SPAPR_VLAN_DEVICE(obj); in spapr_vlan_instance_init() local
341 device_add_bootindex_property(obj, &dev->nicconf.bootindex, in spapr_vlan_instance_init()
343 DEVICE(dev)); in spapr_vlan_instance_init()
345 if (dev->compat_flags & SPAPRVLAN_FLAG_RX_BUF_POOLS) { in spapr_vlan_instance_init()
347 dev->rx_pool[i] = g_new(RxBufPool, 1); in spapr_vlan_instance_init()
348 spapr_vlan_reset_rx_pool(dev->rx_pool[i]); in spapr_vlan_instance_init()
355 SpaprVioVlan *dev = VIO_SPAPR_VLAN_DEVICE(obj); in spapr_vlan_instance_finalize() local
358 if (dev->compat_flags & SPAPRVLAN_FLAG_RX_BUF_POOLS) { in spapr_vlan_instance_finalize()
360 g_free(dev->rx_pool[i]); in spapr_vlan_instance_finalize()
361 dev->rx_pool[i] = NULL; in spapr_vlan_instance_finalize()
365 if (dev->rxp_timer) { in spapr_vlan_instance_finalize()
366 timer_free(dev->rxp_timer); in spapr_vlan_instance_finalize()
372 DeviceState *dev; in spapr_vlan_create() local
374 dev = qdev_new("spapr-vlan"); in spapr_vlan_create()
376 qdev_set_nic_properties(dev, nd); in spapr_vlan_create()
378 qdev_realize_and_unref(dev, &bus->bus, &error_fatal); in spapr_vlan_create()
381 static int spapr_vlan_devnode(SpaprVioDevice *dev, void *fdt, int node_off) in spapr_vlan_devnode() argument
383 SpaprVioVlan *vdev = VIO_SPAPR_VLAN_DEVICE(dev); in spapr_vlan_devnode()
418 static int check_bd(SpaprVioVlan *dev, vlan_bd_t bd, in check_bd() argument
426 if (!spapr_vio_dma_valid(&dev->sdev, VLAN_BD_ADDR(bd), in check_bd()
428 || !spapr_vio_dma_valid(&dev->sdev, VLAN_BD_ADDR(bd), in check_bd()
446 SpaprVioVlan *dev = VIO_SPAPR_VLAN_DEVICE(sdev); in h_register_logical_lan() local
449 if (!dev) { in h_register_logical_lan()
453 if (dev->isopen) { in h_register_logical_lan()
459 if (check_bd(dev, VLAN_VALID_BD(buf_list, SPAPR_TCE_PAGE_SIZE), in h_register_logical_lan()
466 if (check_bd(dev, filter_list_bd, SPAPR_TCE_PAGE_SIZE) < 0) { in h_register_logical_lan()
472 || (check_bd(dev, rec_queue, VLAN_RQ_ALIGNMENT) < 0)) { in h_register_logical_lan()
477 dev->buf_list = buf_list; in h_register_logical_lan()
487 dev->add_buf_ptr = VLAN_RX_BDS_OFF - 8; in h_register_logical_lan()
488 dev->use_buf_ptr = VLAN_RX_BDS_OFF - 8; in h_register_logical_lan()
489 dev->rx_bufs = 0; in h_register_logical_lan()
490 dev->rxq_ptr = 0; in h_register_logical_lan()
495 dev->isopen = 1; in h_register_logical_lan()
496 qemu_flush_queued_packets(qemu_get_queue(dev->nic)); in h_register_logical_lan()
508 SpaprVioVlan *dev = VIO_SPAPR_VLAN_DEVICE(sdev); in h_free_logical_lan() local
510 if (!dev) { in h_free_logical_lan()
514 if (!dev->isopen) { in h_free_logical_lan()
542 static int spapr_vlan_get_rx_pool_id(SpaprVioVlan *dev, int size) in spapr_vlan_get_rx_pool_id() argument
547 if (dev->rx_pool[pool]->bufsize == size) { in spapr_vlan_get_rx_pool_id()
558 static target_long spapr_vlan_add_rxbuf_to_pool(SpaprVioVlan *dev, in spapr_vlan_add_rxbuf_to_pool() argument
564 pool = spapr_vlan_get_rx_pool_id(dev, size); in spapr_vlan_add_rxbuf_to_pool()
573 if (dev->rx_pool[pool]->count == 0) { in spapr_vlan_add_rxbuf_to_pool()
574 dev->rx_pool[pool]->bufsize = size; in spapr_vlan_add_rxbuf_to_pool()
579 qsort(dev->rx_pool, RX_MAX_POOLS, sizeof(dev->rx_pool[0]), in spapr_vlan_add_rxbuf_to_pool()
581 pool = spapr_vlan_get_rx_pool_id(dev, size); in spapr_vlan_add_rxbuf_to_pool()
589 if (pool < 0 || dev->rx_pool[pool]->count >= RX_POOL_MAX_BDS) { in spapr_vlan_add_rxbuf_to_pool()
594 dev->rx_pool[pool]->count); in spapr_vlan_add_rxbuf_to_pool()
596 dev->rx_pool[pool]->bds[dev->rx_pool[pool]->count++] = buf; in spapr_vlan_add_rxbuf_to_pool()
605 static target_long spapr_vlan_add_rxbuf_to_page(SpaprVioVlan *dev, in spapr_vlan_add_rxbuf_to_page() argument
610 if (dev->rx_bufs >= VLAN_MAX_BUFS) { in spapr_vlan_add_rxbuf_to_page()
615 dev->add_buf_ptr += 8; in spapr_vlan_add_rxbuf_to_page()
616 if (dev->add_buf_ptr >= VLAN_RX_BDS_LEN + VLAN_RX_BDS_OFF) { in spapr_vlan_add_rxbuf_to_page()
617 dev->add_buf_ptr = VLAN_RX_BDS_OFF; in spapr_vlan_add_rxbuf_to_page()
620 bd = vio_ldq(&dev->sdev, dev->buf_list + dev->add_buf_ptr); in spapr_vlan_add_rxbuf_to_page()
623 vio_stq(&dev->sdev, dev->buf_list + dev->add_buf_ptr, buf); in spapr_vlan_add_rxbuf_to_page()
625 trace_spapr_vlan_add_rxbuf_to_page(dev->add_buf_ptr, dev->rx_bufs, buf); in spapr_vlan_add_rxbuf_to_page()
638 SpaprVioVlan *dev = VIO_SPAPR_VLAN_DEVICE(sdev); in h_add_logical_lan_buffer() local
648 if ((check_bd(dev, buf, 4) < 0) in h_add_logical_lan_buffer()
654 if (!dev->isopen) { in h_add_logical_lan_buffer()
658 if (dev->compat_flags & SPAPRVLAN_FLAG_RX_BUF_POOLS) { in h_add_logical_lan_buffer()
659 ret = spapr_vlan_add_rxbuf_to_pool(dev, buf); in h_add_logical_lan_buffer()
661 ret = spapr_vlan_add_rxbuf_to_page(dev, buf); in h_add_logical_lan_buffer()
667 dev->rx_bufs++; in h_add_logical_lan_buffer()
675 timer_mod(dev->rxp_timer, qemu_clock_get_us(QEMU_CLOCK_VIRTUAL) + 500); in h_add_logical_lan_buffer()
688 SpaprVioVlan *dev = VIO_SPAPR_VLAN_DEVICE(sdev); in h_send_logical_lan() local
701 trace_spapr_vlan_h_send_logical_lan_rxbufs(dev->rx_bufs); in h_send_logical_lan()
703 if (!dev->isopen) { in h_send_logical_lan()
744 qemu_send_packet(qemu_get_queue(dev->nic), lbuf, total_len); in h_send_logical_lan()
753 SpaprVioDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg); in h_multicast_ctrl() local
755 if (!dev) { in h_multicast_ctrl()
770 SpaprVioVlan *dev = VIO_SPAPR_VLAN_DEVICE(sdev); in h_change_logical_lan_mac() local
773 if (!dev) { in h_change_logical_lan_mac()
780 dev->nicconf.macaddr.a[ETH_ALEN - i - 1] = macaddr & 0xff; in h_change_logical_lan_mac()
784 qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.macaddr.a); in h_change_logical_lan_mac()
799 SpaprVioVlan *dev = opaque; in spapr_vlan_rx_buffer_pools_needed() local
801 return (dev->compat_flags & SPAPRVLAN_FLAG_RX_BUF_POOLS) != 0; in spapr_vlan_rx_buffer_pools_needed()