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