xref: /openbmc/qemu/hw/net/spapr_llan.c (revision 228aa992)
1 /*
2  * QEMU PowerPC pSeries Logical Partition (aka sPAPR) hardware System Emulator
3  *
4  * PAPR Inter-VM Logical Lan, aka ibmveth
5  *
6  * Copyright (c) 2010,2011 David Gibson, IBM Corporation.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  *
26  */
27 #include "hw/hw.h"
28 #include "net/net.h"
29 #include "hw/qdev.h"
30 #include "hw/ppc/spapr.h"
31 #include "hw/ppc/spapr_vio.h"
32 #include "sysemu/sysemu.h"
33 
34 #include <libfdt.h>
35 
36 #define ETH_ALEN        6
37 #define MAX_PACKET_SIZE 65536
38 
39 /*#define DEBUG*/
40 
41 #ifdef DEBUG
42 #define DPRINTF(fmt...) do { fprintf(stderr, fmt); } while (0)
43 #else
44 #define DPRINTF(fmt...)
45 #endif
46 
47 /*
48  * Virtual LAN device
49  */
50 
51 typedef uint64_t vlan_bd_t;
52 
53 #define VLAN_BD_VALID        0x8000000000000000ULL
54 #define VLAN_BD_TOGGLE       0x4000000000000000ULL
55 #define VLAN_BD_NO_CSUM      0x0200000000000000ULL
56 #define VLAN_BD_CSUM_GOOD    0x0100000000000000ULL
57 #define VLAN_BD_LEN_MASK     0x00ffffff00000000ULL
58 #define VLAN_BD_LEN(bd)      (((bd) & VLAN_BD_LEN_MASK) >> 32)
59 #define VLAN_BD_ADDR_MASK    0x00000000ffffffffULL
60 #define VLAN_BD_ADDR(bd)     ((bd) & VLAN_BD_ADDR_MASK)
61 
62 #define VLAN_VALID_BD(addr, len) (VLAN_BD_VALID | \
63                                   (((len) << 32) & VLAN_BD_LEN_MASK) |  \
64                                   (addr & VLAN_BD_ADDR_MASK))
65 
66 #define VLAN_RXQC_TOGGLE     0x80
67 #define VLAN_RXQC_VALID      0x40
68 #define VLAN_RXQC_NO_CSUM    0x02
69 #define VLAN_RXQC_CSUM_GOOD  0x01
70 
71 #define VLAN_RQ_ALIGNMENT    16
72 #define VLAN_RXQ_BD_OFF      0
73 #define VLAN_FILTER_BD_OFF   8
74 #define VLAN_RX_BDS_OFF      16
75 /*
76  * The final 8 bytes of the buffer list is a counter of frames dropped
77  * because there was not a buffer in the buffer list capable of holding
78  * the frame. We must avoid it, or the operating system will report garbage
79  * for this statistic.
80  */
81 #define VLAN_RX_BDS_LEN      (SPAPR_TCE_PAGE_SIZE - VLAN_RX_BDS_OFF - 8)
82 #define VLAN_MAX_BUFS        (VLAN_RX_BDS_LEN / 8)
83 
84 #define TYPE_VIO_SPAPR_VLAN_DEVICE "spapr-vlan"
85 #define VIO_SPAPR_VLAN_DEVICE(obj) \
86      OBJECT_CHECK(VIOsPAPRVLANDevice, (obj), TYPE_VIO_SPAPR_VLAN_DEVICE)
87 
88 typedef struct VIOsPAPRVLANDevice {
89     VIOsPAPRDevice sdev;
90     NICConf nicconf;
91     NICState *nic;
92     bool isopen;
93     target_ulong buf_list;
94     uint32_t add_buf_ptr, use_buf_ptr, rx_bufs;
95     target_ulong rxq_ptr;
96 } VIOsPAPRVLANDevice;
97 
98 static int spapr_vlan_can_receive(NetClientState *nc)
99 {
100     VIOsPAPRVLANDevice *dev = qemu_get_nic_opaque(nc);
101 
102     return (dev->isopen && dev->rx_bufs > 0);
103 }
104 
105 static ssize_t spapr_vlan_receive(NetClientState *nc, const uint8_t *buf,
106                                   size_t size)
107 {
108     VIOsPAPRVLANDevice *dev = qemu_get_nic_opaque(nc);
109     VIOsPAPRDevice *sdev = VIO_SPAPR_DEVICE(dev);
110     vlan_bd_t rxq_bd = vio_ldq(sdev, dev->buf_list + VLAN_RXQ_BD_OFF);
111     vlan_bd_t bd;
112     int buf_ptr = dev->use_buf_ptr;
113     uint64_t handle;
114     uint8_t control;
115 
116     DPRINTF("spapr_vlan_receive() [%s] rx_bufs=%d\n", sdev->qdev.id,
117             dev->rx_bufs);
118 
119     if (!dev->isopen) {
120         return -1;
121     }
122 
123     if (!dev->rx_bufs) {
124         return -1;
125     }
126 
127     do {
128         buf_ptr += 8;
129         if (buf_ptr >= (VLAN_RX_BDS_LEN + VLAN_RX_BDS_OFF)) {
130             buf_ptr = VLAN_RX_BDS_OFF;
131         }
132 
133         bd = vio_ldq(sdev, dev->buf_list + buf_ptr);
134         DPRINTF("use_buf_ptr=%d bd=0x%016llx\n",
135                 buf_ptr, (unsigned long long)bd);
136     } while ((!(bd & VLAN_BD_VALID) || (VLAN_BD_LEN(bd) < (size + 8)))
137              && (buf_ptr != dev->use_buf_ptr));
138 
139     if (!(bd & VLAN_BD_VALID) || (VLAN_BD_LEN(bd) < (size + 8))) {
140         /* Failed to find a suitable buffer */
141         return -1;
142     }
143 
144     /* Remove the buffer from the pool */
145     dev->rx_bufs--;
146     dev->use_buf_ptr = buf_ptr;
147     vio_stq(sdev, dev->buf_list + dev->use_buf_ptr, 0);
148 
149     DPRINTF("Found buffer: ptr=%d num=%d\n", dev->use_buf_ptr, dev->rx_bufs);
150 
151     /* Transfer the packet data */
152     if (spapr_vio_dma_write(sdev, VLAN_BD_ADDR(bd) + 8, buf, size) < 0) {
153         return -1;
154     }
155 
156     DPRINTF("spapr_vlan_receive: DMA write completed\n");
157 
158     /* Update the receive queue */
159     control = VLAN_RXQC_TOGGLE | VLAN_RXQC_VALID;
160     if (rxq_bd & VLAN_BD_TOGGLE) {
161         control ^= VLAN_RXQC_TOGGLE;
162     }
163 
164     handle = vio_ldq(sdev, VLAN_BD_ADDR(bd));
165     vio_stq(sdev, VLAN_BD_ADDR(rxq_bd) + dev->rxq_ptr + 8, handle);
166     vio_stl(sdev, VLAN_BD_ADDR(rxq_bd) + dev->rxq_ptr + 4, size);
167     vio_sth(sdev, VLAN_BD_ADDR(rxq_bd) + dev->rxq_ptr + 2, 8);
168     vio_stb(sdev, VLAN_BD_ADDR(rxq_bd) + dev->rxq_ptr, control);
169 
170     DPRINTF("wrote rxq entry (ptr=0x%llx): 0x%016llx 0x%016llx\n",
171             (unsigned long long)dev->rxq_ptr,
172             (unsigned long long)vio_ldq(sdev, VLAN_BD_ADDR(rxq_bd) +
173                                         dev->rxq_ptr),
174             (unsigned long long)vio_ldq(sdev, VLAN_BD_ADDR(rxq_bd) +
175                                         dev->rxq_ptr + 8));
176 
177     dev->rxq_ptr += 16;
178     if (dev->rxq_ptr >= VLAN_BD_LEN(rxq_bd)) {
179         dev->rxq_ptr = 0;
180         vio_stq(sdev, dev->buf_list + VLAN_RXQ_BD_OFF, rxq_bd ^ VLAN_BD_TOGGLE);
181     }
182 
183     if (sdev->signal_state & 1) {
184         qemu_irq_pulse(spapr_vio_qirq(sdev));
185     }
186 
187     return size;
188 }
189 
190 static void spapr_vlan_cleanup(NetClientState *nc)
191 {
192     VIOsPAPRVLANDevice *dev = qemu_get_nic_opaque(nc);
193 
194     dev->nic = NULL;
195 }
196 
197 static NetClientInfo net_spapr_vlan_info = {
198     .type = NET_CLIENT_OPTIONS_KIND_NIC,
199     .size = sizeof(NICState),
200     .can_receive = spapr_vlan_can_receive,
201     .receive = spapr_vlan_receive,
202     .cleanup = spapr_vlan_cleanup,
203 };
204 
205 static void spapr_vlan_reset(VIOsPAPRDevice *sdev)
206 {
207     VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
208 
209     dev->buf_list = 0;
210     dev->rx_bufs = 0;
211     dev->isopen = 0;
212 }
213 
214 static int spapr_vlan_init(VIOsPAPRDevice *sdev)
215 {
216     VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
217 
218     qemu_macaddr_default_if_unset(&dev->nicconf.macaddr);
219 
220     dev->nic = qemu_new_nic(&net_spapr_vlan_info, &dev->nicconf,
221                             object_get_typename(OBJECT(sdev)), sdev->qdev.id, dev);
222     qemu_format_nic_info_str(qemu_get_queue(dev->nic), dev->nicconf.macaddr.a);
223 
224     return 0;
225 }
226 
227 static void spapr_vlan_instance_init(Object *obj)
228 {
229     VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(obj);
230 
231     device_add_bootindex_property(obj, &dev->nicconf.bootindex,
232                                   "bootindex", "",
233                                   DEVICE(dev), NULL);
234 }
235 
236 void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd)
237 {
238     DeviceState *dev;
239 
240     dev = qdev_create(&bus->bus, "spapr-vlan");
241 
242     qdev_set_nic_properties(dev, nd);
243 
244     qdev_init_nofail(dev);
245 }
246 
247 static int spapr_vlan_devnode(VIOsPAPRDevice *dev, void *fdt, int node_off)
248 {
249     VIOsPAPRVLANDevice *vdev = VIO_SPAPR_VLAN_DEVICE(dev);
250     uint8_t padded_mac[8] = {0, 0};
251     int ret;
252 
253     /* Some old phyp versions give the mac address in an 8-byte
254      * property.  The kernel driver has an insane workaround for this;
255      * rather than doing the obvious thing and checking the property
256      * length, it checks whether the first byte has 0b10 in the low
257      * bits.  If a correct 6-byte property has a different first byte
258      * the kernel will get the wrong mac address, overrunning its
259      * buffer in the process (read only, thank goodness).
260      *
261      * Here we workaround the kernel workaround by always supplying an
262      * 8-byte property, with the mac address in the last six bytes */
263     memcpy(&padded_mac[2], &vdev->nicconf.macaddr, ETH_ALEN);
264     ret = fdt_setprop(fdt, node_off, "local-mac-address",
265                       padded_mac, sizeof(padded_mac));
266     if (ret < 0) {
267         return ret;
268     }
269 
270     ret = fdt_setprop_cell(fdt, node_off, "ibm,mac-address-filters", 0);
271     if (ret < 0) {
272         return ret;
273     }
274 
275     return 0;
276 }
277 
278 static int check_bd(VIOsPAPRVLANDevice *dev, vlan_bd_t bd,
279                     target_ulong alignment)
280 {
281     if ((VLAN_BD_ADDR(bd) % alignment)
282         || (VLAN_BD_LEN(bd) % alignment)) {
283         return -1;
284     }
285 
286     if (!spapr_vio_dma_valid(&dev->sdev, VLAN_BD_ADDR(bd),
287                              VLAN_BD_LEN(bd), DMA_DIRECTION_FROM_DEVICE)
288         || !spapr_vio_dma_valid(&dev->sdev, VLAN_BD_ADDR(bd),
289                                 VLAN_BD_LEN(bd), DMA_DIRECTION_TO_DEVICE)) {
290         return -1;
291     }
292 
293     return 0;
294 }
295 
296 static target_ulong h_register_logical_lan(PowerPCCPU *cpu,
297                                            sPAPREnvironment *spapr,
298                                            target_ulong opcode,
299                                            target_ulong *args)
300 {
301     target_ulong reg = args[0];
302     target_ulong buf_list = args[1];
303     target_ulong rec_queue = args[2];
304     target_ulong filter_list = args[3];
305     VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
306     VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
307     vlan_bd_t filter_list_bd;
308 
309     if (!dev) {
310         return H_PARAMETER;
311     }
312 
313     if (dev->isopen) {
314         hcall_dprintf("H_REGISTER_LOGICAL_LAN called twice without "
315                       "H_FREE_LOGICAL_LAN\n");
316         return H_RESOURCE;
317     }
318 
319     if (check_bd(dev, VLAN_VALID_BD(buf_list, SPAPR_TCE_PAGE_SIZE),
320                  SPAPR_TCE_PAGE_SIZE) < 0) {
321         hcall_dprintf("Bad buf_list 0x" TARGET_FMT_lx "\n", buf_list);
322         return H_PARAMETER;
323     }
324 
325     filter_list_bd = VLAN_VALID_BD(filter_list, SPAPR_TCE_PAGE_SIZE);
326     if (check_bd(dev, filter_list_bd, SPAPR_TCE_PAGE_SIZE) < 0) {
327         hcall_dprintf("Bad filter_list 0x" TARGET_FMT_lx "\n", filter_list);
328         return H_PARAMETER;
329     }
330 
331     if (!(rec_queue & VLAN_BD_VALID)
332         || (check_bd(dev, rec_queue, VLAN_RQ_ALIGNMENT) < 0)) {
333         hcall_dprintf("Bad receive queue\n");
334         return H_PARAMETER;
335     }
336 
337     dev->buf_list = buf_list;
338     sdev->signal_state = 0;
339 
340     rec_queue &= ~VLAN_BD_TOGGLE;
341 
342     /* Initialize the buffer list */
343     vio_stq(sdev, buf_list, rec_queue);
344     vio_stq(sdev, buf_list + 8, filter_list_bd);
345     spapr_vio_dma_set(sdev, buf_list + VLAN_RX_BDS_OFF, 0,
346                       SPAPR_TCE_PAGE_SIZE - VLAN_RX_BDS_OFF);
347     dev->add_buf_ptr = VLAN_RX_BDS_OFF - 8;
348     dev->use_buf_ptr = VLAN_RX_BDS_OFF - 8;
349     dev->rx_bufs = 0;
350     dev->rxq_ptr = 0;
351 
352     /* Initialize the receive queue */
353     spapr_vio_dma_set(sdev, VLAN_BD_ADDR(rec_queue), 0, VLAN_BD_LEN(rec_queue));
354 
355     dev->isopen = 1;
356     qemu_flush_queued_packets(qemu_get_queue(dev->nic));
357 
358     return H_SUCCESS;
359 }
360 
361 
362 static target_ulong h_free_logical_lan(PowerPCCPU *cpu, sPAPREnvironment *spapr,
363                                        target_ulong opcode, target_ulong *args)
364 {
365     target_ulong reg = args[0];
366     VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
367     VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
368 
369     if (!dev) {
370         return H_PARAMETER;
371     }
372 
373     if (!dev->isopen) {
374         hcall_dprintf("H_FREE_LOGICAL_LAN called without "
375                       "H_REGISTER_LOGICAL_LAN\n");
376         return H_RESOURCE;
377     }
378 
379     spapr_vlan_reset(sdev);
380     return H_SUCCESS;
381 }
382 
383 static target_ulong h_add_logical_lan_buffer(PowerPCCPU *cpu,
384                                              sPAPREnvironment *spapr,
385                                              target_ulong opcode,
386                                              target_ulong *args)
387 {
388     target_ulong reg = args[0];
389     target_ulong buf = args[1];
390     VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
391     VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
392     vlan_bd_t bd;
393 
394     DPRINTF("H_ADD_LOGICAL_LAN_BUFFER(0x" TARGET_FMT_lx
395             ", 0x" TARGET_FMT_lx ")\n", reg, buf);
396 
397     if (!sdev) {
398         hcall_dprintf("Bad device\n");
399         return H_PARAMETER;
400     }
401 
402     if ((check_bd(dev, buf, 4) < 0)
403         || (VLAN_BD_LEN(buf) < 16)) {
404         hcall_dprintf("Bad buffer enqueued\n");
405         return H_PARAMETER;
406     }
407 
408     if (!dev->isopen || dev->rx_bufs >= VLAN_MAX_BUFS) {
409         return H_RESOURCE;
410     }
411 
412     do {
413         dev->add_buf_ptr += 8;
414         if (dev->add_buf_ptr >= (VLAN_RX_BDS_LEN + VLAN_RX_BDS_OFF)) {
415             dev->add_buf_ptr = VLAN_RX_BDS_OFF;
416         }
417 
418         bd = vio_ldq(sdev, dev->buf_list + dev->add_buf_ptr);
419     } while (bd & VLAN_BD_VALID);
420 
421     vio_stq(sdev, dev->buf_list + dev->add_buf_ptr, buf);
422 
423     dev->rx_bufs++;
424 
425     qemu_flush_queued_packets(qemu_get_queue(dev->nic));
426 
427     DPRINTF("h_add_logical_lan_buffer():  Added buf  ptr=%d  rx_bufs=%d"
428             " bd=0x%016llx\n", dev->add_buf_ptr, dev->rx_bufs,
429             (unsigned long long)buf);
430 
431     return H_SUCCESS;
432 }
433 
434 static target_ulong h_send_logical_lan(PowerPCCPU *cpu, sPAPREnvironment *spapr,
435                                        target_ulong opcode, target_ulong *args)
436 {
437     target_ulong reg = args[0];
438     target_ulong *bufs = args + 1;
439     target_ulong continue_token = args[7];
440     VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
441     VIOsPAPRVLANDevice *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
442     unsigned total_len;
443     uint8_t *lbuf, *p;
444     int i, nbufs;
445     int ret;
446 
447     DPRINTF("H_SEND_LOGICAL_LAN(0x" TARGET_FMT_lx ", <bufs>, 0x"
448             TARGET_FMT_lx ")\n", reg, continue_token);
449 
450     if (!sdev) {
451         return H_PARAMETER;
452     }
453 
454     DPRINTF("rxbufs = %d\n", dev->rx_bufs);
455 
456     if (!dev->isopen) {
457         return H_DROPPED;
458     }
459 
460     if (continue_token) {
461         return H_HARDWARE; /* FIXME actually handle this */
462     }
463 
464     total_len = 0;
465     for (i = 0; i < 6; i++) {
466         DPRINTF("   buf desc: 0x" TARGET_FMT_lx "\n", bufs[i]);
467         if (!(bufs[i] & VLAN_BD_VALID)) {
468             break;
469         }
470         total_len += VLAN_BD_LEN(bufs[i]);
471     }
472 
473     nbufs = i;
474     DPRINTF("h_send_logical_lan() %d buffers, total length 0x%x\n",
475             nbufs, total_len);
476 
477     if (total_len == 0) {
478         return H_SUCCESS;
479     }
480 
481     if (total_len > MAX_PACKET_SIZE) {
482         /* Don't let the guest force too large an allocation */
483         return H_RESOURCE;
484     }
485 
486     lbuf = alloca(total_len);
487     p = lbuf;
488     for (i = 0; i < nbufs; i++) {
489         ret = spapr_vio_dma_read(sdev, VLAN_BD_ADDR(bufs[i]),
490                                  p, VLAN_BD_LEN(bufs[i]));
491         if (ret < 0) {
492             return ret;
493         }
494 
495         p += VLAN_BD_LEN(bufs[i]);
496     }
497 
498     qemu_send_packet(qemu_get_queue(dev->nic), lbuf, total_len);
499 
500     return H_SUCCESS;
501 }
502 
503 static target_ulong h_multicast_ctrl(PowerPCCPU *cpu, sPAPREnvironment *spapr,
504                                      target_ulong opcode, target_ulong *args)
505 {
506     target_ulong reg = args[0];
507     VIOsPAPRDevice *dev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
508 
509     if (!dev) {
510         return H_PARAMETER;
511     }
512 
513     return H_SUCCESS;
514 }
515 
516 static Property spapr_vlan_properties[] = {
517     DEFINE_SPAPR_PROPERTIES(VIOsPAPRVLANDevice, sdev),
518     DEFINE_NIC_PROPERTIES(VIOsPAPRVLANDevice, nicconf),
519     DEFINE_PROP_END_OF_LIST(),
520 };
521 
522 static const VMStateDescription vmstate_spapr_llan = {
523     .name = "spapr_llan",
524     .version_id = 1,
525     .minimum_version_id = 1,
526     .fields = (VMStateField[]) {
527         VMSTATE_SPAPR_VIO(sdev, VIOsPAPRVLANDevice),
528         /* LLAN state */
529         VMSTATE_BOOL(isopen, VIOsPAPRVLANDevice),
530         VMSTATE_UINTTL(buf_list, VIOsPAPRVLANDevice),
531         VMSTATE_UINT32(add_buf_ptr, VIOsPAPRVLANDevice),
532         VMSTATE_UINT32(use_buf_ptr, VIOsPAPRVLANDevice),
533         VMSTATE_UINT32(rx_bufs, VIOsPAPRVLANDevice),
534         VMSTATE_UINTTL(rxq_ptr, VIOsPAPRVLANDevice),
535 
536         VMSTATE_END_OF_LIST()
537     },
538 };
539 
540 static void spapr_vlan_class_init(ObjectClass *klass, void *data)
541 {
542     DeviceClass *dc = DEVICE_CLASS(klass);
543     VIOsPAPRDeviceClass *k = VIO_SPAPR_DEVICE_CLASS(klass);
544 
545     k->init = spapr_vlan_init;
546     k->reset = spapr_vlan_reset;
547     k->devnode = spapr_vlan_devnode;
548     k->dt_name = "l-lan";
549     k->dt_type = "network";
550     k->dt_compatible = "IBM,l-lan";
551     k->signal_mask = 0x1;
552     set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
553     dc->props = spapr_vlan_properties;
554     k->rtce_window_size = 0x10000000;
555     dc->vmsd = &vmstate_spapr_llan;
556 }
557 
558 static const TypeInfo spapr_vlan_info = {
559     .name          = TYPE_VIO_SPAPR_VLAN_DEVICE,
560     .parent        = TYPE_VIO_SPAPR_DEVICE,
561     .instance_size = sizeof(VIOsPAPRVLANDevice),
562     .class_init    = spapr_vlan_class_init,
563     .instance_init = spapr_vlan_instance_init,
564 };
565 
566 static void spapr_vlan_register_types(void)
567 {
568     spapr_register_hypercall(H_REGISTER_LOGICAL_LAN, h_register_logical_lan);
569     spapr_register_hypercall(H_FREE_LOGICAL_LAN, h_free_logical_lan);
570     spapr_register_hypercall(H_SEND_LOGICAL_LAN, h_send_logical_lan);
571     spapr_register_hypercall(H_ADD_LOGICAL_LAN_BUFFER,
572                              h_add_logical_lan_buffer);
573     spapr_register_hypercall(H_MULTICAST_CTRL, h_multicast_ctrl);
574     type_register_static(&spapr_vlan_info);
575 }
576 
577 type_init(spapr_vlan_register_types)
578