virnetdevmacvlan.h 4.8 KB
Newer Older
1
/*
2
 * Copyright (C) 2011, 2013, 2016 Red Hat, Inc.
3 4 5 6 7 8 9 10 11 12 13 14 15
 * Copyright (C) 2010 IBM Corporation
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library.  If not, see
O
Osier Yang 已提交
17
 * <http://www.gnu.org/licenses/>.
18 19 20 21 22 23
 *
 * Authors:
 *     Stefan Berger <stefanb@us.ibm.com>
 */

#ifndef __UTIL_MACVTAP_H__
24
# define __UTIL_MACVTAP_H__
25

26
# include "internal.h"
27
# include "virmacaddr.h"
28 29 30
# include "virsocketaddr.h"
# include "virnetdevbandwidth.h"
# include "virnetdevvportprofile.h"
31
# include "virnetdevvlan.h"
32

33
/* the mode type for macvtap devices */
34
typedef enum {
35 36 37 38
    VIR_NETDEV_MACVLAN_MODE_VEPA,
    VIR_NETDEV_MACVLAN_MODE_PRIVATE,
    VIR_NETDEV_MACVLAN_MODE_BRIDGE,
    VIR_NETDEV_MACVLAN_MODE_PASSTHRU,
39

40
    VIR_NETDEV_MACVLAN_MODE_LAST,
41
} virNetDevMacVLanMode;
42
VIR_ENUM_DECL(virNetDevMacVLanMode)
43

44 45 46 47
typedef enum {
   VIR_NETDEV_MACVLAN_CREATE_NONE     = 0,
   /* Create with a tap device */
   VIR_NETDEV_MACVLAN_CREATE_WITH_TAP = 1 << 0,
48 49
   /* Bring the interface up */
   VIR_NETDEV_MACVLAN_CREATE_IFUP     = 1 << 1,
50 51
   /* Enable VNET_HDR */
   VIR_NETDEV_MACVLAN_VNET_HDR          = 1 << 2,
52 53
} virNetDevMacVLanCreateFlags;

54 55 56
int virNetDevMacVLanReserveName(const char *name, bool quietfail);
int virNetDevMacVLanReleaseName(const char *name);

57 58
int virNetDevMacVLanCreate(const char *ifname,
                           const char *type,
59
                           const virMacAddr *macaddress,
60 61 62 63 64 65 66 67 68
                           const char *srcdev,
                           uint32_t macvlan_mode,
                           int *retry)
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4)
    ATTRIBUTE_RETURN_CHECK;

int virNetDevMacVLanDelete(const char *ifname)
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;

69
int virNetDevMacVLanCreateWithVPortProfile(const char *ifname,
70
                                           const virMacAddr *macaddress,
71
                                           const char *linkdev,
72
                                           virNetDevMacVLanMode mode,
73
                                           virNetDevVlanPtr vlan,
74 75 76
                                           const unsigned char *vmuuid,
                                           virNetDevVPortProfilePtr virtPortProfile,
                                           char **res_ifname,
77
                                           virNetDevVPortProfileOp vmop,
78
                                           char *stateDir,
79 80
                                           int *tapfd,
                                           size_t tapfdSize,
81
                                           unsigned int flags)
82 83
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(6)
    ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(10) ATTRIBUTE_RETURN_CHECK;
84

85
int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
86
                                           const virMacAddr *macaddress,
87 88 89 90
                                           const char *linkdev,
                                           int mode,
                                           virNetDevVPortProfilePtr virtPortProfile,
                                           char *stateDir)
91
    ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
92
    ATTRIBUTE_NONNULL(6) ATTRIBUTE_RETURN_CHECK;
93

94
int virNetDevMacVLanRestartWithVPortProfile(const char *cr_ifname,
95 96 97 98 99
                                            const virMacAddr *macaddress,
                                            const char *linkdev,
                                            const unsigned char *vmuuid,
                                            virNetDevVPortProfilePtr virtPortProfile,
                                            virNetDevVPortProfileOp vmOp)
100
    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
101
    ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
102

103
int virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
104 105 106 107 108
                                                 const virMacAddr *macaddress,
                                                 const char *linkdev,
                                                 const unsigned char *vmuuid,
                                                 virNetDevVPortProfilePtr virtPortProfile,
                                                 virNetDevVPortProfileOp vmOp)
109
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
110
ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
111
#endif /* __UTIL_MACVTAP_H__ */