virnetdevvportprofile.h 4.4 KB
Newer Older
1
/*
2
 * Copyright (C) 2009-2013 Red Hat, Inc.
3 4 5 6 7 8 9 10 11 12 13 14
 *
 * 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
15
 * License along with this library.  If not, see
O
Osier Yang 已提交
16
 * <http://www.gnu.org/licenses/>.
17 18 19 20 21 22 23 24 25 26
 *
 * Authors:
 *     Stefan Berger <stefanb@us.ibm.com>
 *     Daniel P. Berrange <berrange@redhat.com>
 */

#ifndef __VIR_NETDEV_VPORT_PROFILE_H__
# define __VIR_NETDEV_VPORT_PROFILE_H__

# include "internal.h"
27
# include "viruuid.h"
28
# include "virutil.h"
29
# include "virmacaddr.h"
30 31 32 33 34 35 36

# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40

enum virNetDevVPortProfile {
    VIR_NETDEV_VPORT_PROFILE_NONE,
    VIR_NETDEV_VPORT_PROFILE_8021QBG,
    VIR_NETDEV_VPORT_PROFILE_8021QBH,
A
Ansis Atteka 已提交
37
    VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH,
38
    VIR_NETDEV_VPORT_PROFILE_MIDONET,
39 40 41 42 43

    VIR_NETDEV_VPORT_PROFILE_LAST,
};
VIR_ENUM_DECL(virNetDevVPort)

44
typedef enum {
45 46 47 48 49 50 51 52 53 54
    VIR_NETDEV_VPORT_PROFILE_OP_CREATE,
    VIR_NETDEV_VPORT_PROFILE_OP_SAVE,
    VIR_NETDEV_VPORT_PROFILE_OP_RESTORE,
    VIR_NETDEV_VPORT_PROFILE_OP_DESTROY,
    VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_OUT,
    VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START,
    VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_FINISH,
    VIR_NETDEV_VPORT_PROFILE_OP_NO_OP,

    VIR_NETDEV_VPORT_PROFILE_OP_LAST
55
} virNetDevVPortProfileOp;
56 57
VIR_ENUM_DECL(virNetDevVPortProfileOp)

A
Ansis Atteka 已提交
58
/* profile data for macvtap (VEPA) and openvswitch */
59 60 61
typedef struct _virNetDevVPortProfile virNetDevVPortProfile;
typedef virNetDevVPortProfile *virNetDevVPortProfilePtr;
struct _virNetDevVPortProfile {
62
    int           virtPortType; /* enum virNetDevVPortProfile */
63 64
    /* these members are used when virtPortType == 802.1Qbg */
    uint8_t       managerID;
65
    bool          managerID_specified;
66
    uint32_t      typeID; /* 24 bit valid */
67
    bool          typeID_specified;
68
    uint8_t       typeIDVersion;
69
    bool          typeIDVersion_specified;
70
    unsigned char instanceID[VIR_UUID_BUFLEN];
71
    bool          instanceID_specified;
72 73

    /* this member is used when virtPortType == 802.1Qbh|openvswitch */
74
    /* this is a null-terminated character string */
75 76
    char          profileID[LIBVIRT_IFLA_VF_PORT_PROFILE_MAX];

77
    /* this member is used when virtPortType == openvswitch|midonet */
78
    unsigned char interfaceID[VIR_UUID_BUFLEN];
79
    bool          interfaceID_specified;
80
    /* NB - if virtPortType == NONE, any/all of the items could be used */
81 82 83 84 85 86
};


bool virNetDevVPortProfileEqual(virNetDevVPortProfilePtr a,
                                virNetDevVPortProfilePtr b);

87 88 89 90 91 92 93 94 95
int virNetDevVPortProfileCheckComplete(virNetDevVPortProfilePtr virtport,
                                       bool generateMissing);
int virNetDevVPortProfileCheckNoExtras(virNetDevVPortProfilePtr virtport);

int virNetDevVPortProfileMerge3(virNetDevVPortProfilePtr *result,
                                virNetDevVPortProfilePtr fromInterface,
                                virNetDevVPortProfilePtr fromNetwork,
                                virNetDevVPortProfilePtr fromPortgroup);

96
int virNetDevVPortProfileAssociate(const char *ifname,
97
                                   const virNetDevVPortProfile *virtPort,
98
                                   const virMacAddr *macvtap_macaddr,
99
                                   const char *linkdev,
100
                                   int vf,
101
                                   const unsigned char *vmuuid,
102
                                   virNetDevVPortProfileOp vmOp,
103
                                   bool setlink_only)
104
    ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
105 106

int virNetDevVPortProfileDisassociate(const char *ifname,
107
                                      const virNetDevVPortProfile *virtPort,
108
                                      const virMacAddr *macvtap_macaddr,
109
                                      const char *linkdev,
110
                                      int vf,
111
                                      virNetDevVPortProfileOp vmOp)
112
    ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
113 114


115
#endif /* __VIR_NETDEV_VPORT_PROFILE_H__ */