libnl  3.3.0
sriov.h
1 /*
2  * include/netlink/route/link/sriov.h SRIOV VF Info
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation version 2.1
7  * of the License.
8  *
9  * Copyright (c) 2016 Intel Corp. All rights reserved.
10  * Copyright (c) 2016 Jef Oliver <jef.oliver@intel.com>
11  */
12 
13 #ifndef NETLINK_LINK_SRIOV_H_
14 #define NETLINK_LINK_SRIOV_H_
15 
16 #include <netlink/netlink.h>
17 #include <netlink/route/link.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #define RTNL_VF_GUID_STR_LEN 23
24 
25 /**
26  * @ingroup sriov
27  */
28 typedef enum {
29  RTNL_LINK_VF_RATE_API_UNSPEC, /*!< Unspecified API type */
30  RTNL_LINK_VF_RATE_API_OLD, /*!< Old Rate setting API */
31  RTNL_LINK_VF_RATE_API_NEW, /*!< New Rate setting API */
32  __RTNL_LINK_VF_RATE_API_MAX,
34 
35 #define RTNL_LINK_VF_RATE_API_MAX (__RTNL_LINK_VF_RATE_API_MAX - 1)
36 
37 /**
38  * @ingroup sriov
39  */
40 typedef enum {
41  RTNL_LINK_VF_STATS_RX_PACKETS, /*!< Packets Received */
42  RTNL_LINK_VF_STATS_TX_PACKETS, /*!< Packets Sent */
43  RTNL_LINK_VF_STATS_RX_BYTES, /*!< Bytes Recieved */
44  RTNL_LINK_VF_STATS_TX_BYTES, /*!< Bytes Sent */
45  RTNL_LINK_VF_STATS_BROADCAST, /*!< Broadcast packets received */
46  RTNL_LINK_VF_STATS_MULTICAST, /*!< Multicast packets received */
47  __RTNL_LINK_VF_STATS_MAX,
49 
50 #define RTNL_LINK_VF_STATS_MAX (__RTNL_LINK_VF_STATS_MAX - 1)
51 
52 /**
53  * @struct rtnl_link_vf sriov.h "netlink/route/link/sriov.h"
54  * @brief SRIOV VF object
55  * @ingroup sriov
56  *
57  * @copydoc private_struct
58  */
59 struct rtnl_link_vf;
60 
61 /**
62  * @brief SRIOV VF VFLAN settings
63  * @ingroup sriov
64  */
65 typedef struct nl_vf_vlan_info {
66  uint32_t vf_vlan; /*!< VLAN number */
67  uint32_t vf_vlan_qos; /*!< VLAN QOS value */
68  uint16_t vf_vlan_proto; /*!< VLAN protocol */
70 
71 /**
72  * @brief SRIOV VF VLANs information
73  * @ingroup sriov
74  */
75 typedef struct nl_vf_vlans {
76  int ce_refcnt; /*!< Reference counter. Don't change this value */
77  int size; /*!< Number of VLANs on the SRIOV VF */
78  nl_vf_vlan_info_t * vlans; /*!< nl_vf_vlan_info_t array of SRIOV VF VLANs */
80 
81 /**
82  * @brief VF Rate information structure
83  * @ingroup sriov
84  */
85 struct nl_vf_rate {
86  int api; /*!< rtnl_link_rate_api_t API Version to use */
87  uint32_t rate; /*!< Old API Max Rate in Mbps */
88  uint32_t max_tx_rate; /*!< New API Max Rate in Mbps */
89  uint32_t min_tx_rate; /*!< New API Mix Rate in Mbps */
90 };
91 
92 extern int rtnl_link_vf_add(struct rtnl_link *, struct rtnl_link_vf *);
93 extern struct rtnl_link_vf *rtnl_link_vf_alloc(void);
94 extern void rtnl_link_vf_free(struct rtnl_link_vf *);
95 extern struct rtnl_link_vf *rtnl_link_vf_get(struct rtnl_link *, uint32_t);
96 extern void rtnl_link_vf_put(struct rtnl_link_vf *);
97 
98 extern int rtnl_link_vf_get_addr(struct rtnl_link_vf *, struct nl_addr **);
99 extern void rtnl_link_vf_set_addr(struct rtnl_link_vf *, struct nl_addr *);
100 
101 extern void rtnl_link_vf_set_ib_node_guid(struct rtnl_link_vf *, uint64_t);
102 extern void rtnl_link_vf_set_ib_port_guid(struct rtnl_link_vf *, uint64_t);
103 
104 extern int rtnl_link_vf_get_index(struct rtnl_link_vf *, uint32_t *);
105 extern void rtnl_link_vf_set_index(struct rtnl_link_vf *, uint32_t);
106 
107 extern int rtnl_link_vf_get_linkstate(struct rtnl_link_vf *, uint32_t *);
108 extern void rtnl_link_vf_set_linkstate(struct rtnl_link_vf *, uint32_t);
109 
110 extern int rtnl_link_vf_get_rate(struct rtnl_link_vf *, struct nl_vf_rate *);
111 extern void rtnl_link_vf_set_rate(struct rtnl_link_vf *, struct nl_vf_rate *);
112 
113 extern int rtnl_link_vf_get_rss_query_en(struct rtnl_link_vf *, uint32_t *);
114 extern void rtnl_link_vf_set_rss_query_en(struct rtnl_link_vf *, uint32_t);
115 
116 extern int rtnl_link_vf_get_spoofchk(struct rtnl_link_vf *, uint32_t *);
117 extern void rtnl_link_vf_set_spoofchk(struct rtnl_link_vf *, uint32_t);
118 
119 extern int rtnl_link_vf_get_stat(struct rtnl_link_vf *, rtnl_link_vf_stats_t,
120  uint64_t *);
121 
122 extern int rtnl_link_vf_get_trust(struct rtnl_link_vf *, uint32_t *);
123 extern void rtnl_link_vf_set_trust(struct rtnl_link_vf *, uint32_t);
124 
125 extern int rtnl_link_vf_get_vlans(struct rtnl_link_vf *, nl_vf_vlans_t **);
126 extern void rtnl_link_vf_set_vlans(struct rtnl_link_vf *, nl_vf_vlans_t *);
127 
128 extern int rtnl_link_vf_vlan_alloc(nl_vf_vlans_t **, int);
129 extern void rtnl_link_vf_vlan_free(nl_vf_vlans_t *vf_vlans);
130 extern void rtnl_link_vf_vlan_put(nl_vf_vlans_t *);
131 
132 /* Utility functions */
133 extern char *rtnl_link_vf_linkstate2str(uint32_t, char *, size_t);
134 extern int rtnl_link_vf_str2linkstate(const char *);
135 
136 extern char *rtnl_link_vf_vlanproto2str(uint16_t, char *, size_t);
137 extern int rtnl_link_vf_str2vlanproto(const char *);
138 
139 extern int rtnl_link_vf_str2guid(uint64_t *, const char *);
140 
141 #ifdef __cplusplus
142 }
143 #endif
144 
145 #endif
int rtnl_link_vf_get_trust(struct rtnl_link_vf *, uint32_t *)
Get trust setting of SRIOV Virtual Function.
Definition: sriov.c:1215
SRIOV VF VLANs information.
Definition: sriov.h:75
int size
Definition: sriov.h:77
int rtnl_link_vf_get_stat(struct rtnl_link_vf *, rtnl_link_vf_stats_t, uint64_t *)
Get value of stat counter for SRIOV Virtual Function.
Definition: sriov.c:1189
uint32_t vf_vlan
Definition: sriov.h:66
int api
Definition: sriov.h:86
uint32_t rate
Definition: sriov.h:87
struct rtnl_link_vf * rtnl_link_vf_alloc(void)
Allocate a new SRIOV VF object.
Definition: sriov.c:742
void rtnl_link_vf_put(struct rtnl_link_vf *)
Return SRIOV VF object to the owning link object.
Definition: sriov.c:816
SRIOV VF VFLAN settings.
Definition: sriov.h:65
void rtnl_link_vf_set_index(struct rtnl_link_vf *, uint32_t)
Set index of SRIOV Virtual Function object.
Definition: sriov.c:937
void rtnl_link_vf_set_spoofchk(struct rtnl_link_vf *, uint32_t)
Set spoof checking value of SRIOV Virtual Function Object.
Definition: sriov.c:1169
void rtnl_link_vf_set_linkstate(struct rtnl_link_vf *, uint32_t)
Set link state of SRIOV Virtual Function object.
Definition: sriov.c:981
int rtnl_link_vf_get_vlans(struct rtnl_link_vf *, nl_vf_vlans_t **)
Get an array of VLANS on SRIOV Virtual Function.
Definition: sriov.c:1257
struct nl_vf_vlan_info nl_vf_vlan_info_t
SRIOV VF VFLAN settings.
void rtnl_link_vf_vlan_put(nl_vf_vlans_t *)
Return SRIOV VF VLANs object to the owning SRIOV VF object.
Definition: sriov.c:1359
rtnl_link_rate_api_t
Definition: sriov.h:28
nl_vf_vlan_info_t * vlans
Definition: sriov.h:78
int rtnl_link_vf_get_addr(struct rtnl_link_vf *, struct nl_addr **)
Get link layer address of SRIOV Virtual Function.
Definition: sriov.c:846
uint32_t min_tx_rate
Definition: sriov.h:89
int rtnl_link_vf_get_index(struct rtnl_link_vf *, uint32_t *)
Get index of SRIOV Virtual Function.
Definition: sriov.c:917
void rtnl_link_vf_set_rss_query_en(struct rtnl_link_vf *, uint32_t)
Set RSS configuration querying of SRIOV Virtual Function Object.
Definition: sriov.c:1128
struct rtnl_link_vf * rtnl_link_vf_get(struct rtnl_link *, uint32_t)
Lookup SRIOV VF in link object by VF index.
Definition: sriov.c:789
struct nl_vf_vlans nl_vf_vlans_t
SRIOV VF VLANs information.
void rtnl_link_vf_set_addr(struct rtnl_link_vf *, struct nl_addr *)
Set link layer address of SRIOV Virtual Function object.
Definition: sriov.c:869
void rtnl_link_vf_set_ib_port_guid(struct rtnl_link_vf *, uint64_t)
Set the Infiniband port GUID for the SRIOV Virtual Function object.
Definition: sriov.c:898
int rtnl_link_vf_add(struct rtnl_link *, struct rtnl_link_vf *)
Add a SRIOV VF object to a link object.
Definition: sriov.c:707
int rtnl_link_vf_get_rss_query_en(struct rtnl_link_vf *, uint32_t *)
Get RSS Query EN value of SRIOV Virtual Function.
Definition: sriov.c:1107
int rtnl_link_vf_get_rate(struct rtnl_link_vf *, struct nl_vf_rate *)
Get TX Rate Limit of SRIOV Virtual Function.
Definition: sriov.c:1013
void rtnl_link_vf_set_ib_node_guid(struct rtnl_link_vf *, uint64_t)
Set the Infiniband node GUID for the SRIOV Virtual Function object.
Definition: sriov.c:885
uint16_t vf_vlan_proto
Definition: sriov.h:68
int ce_refcnt
Definition: sriov.h:76
int rtnl_link_vf_vlan_alloc(nl_vf_vlans_t **, int)
Allocate a SRIOV VF VLAN object.
Definition: sriov.c:1310
void rtnl_link_vf_set_rate(struct rtnl_link_vf *, struct nl_vf_rate *)
Set TX Rate Limit of SRIOV Virtual Function object.
Definition: sriov.c:1079
uint32_t vf_vlan_qos
Definition: sriov.h:67
int rtnl_link_vf_get_spoofchk(struct rtnl_link_vf *, uint32_t *)
Get spoof checking value of SRIOV Virtual Function.
Definition: sriov.c:1148
void rtnl_link_vf_free(struct rtnl_link_vf *)
Free SRIOV VF object.
Definition: sriov.c:760
VF Rate information structure.
Definition: sriov.h:85
void rtnl_link_vf_set_vlans(struct rtnl_link_vf *, nl_vf_vlans_t *)
Add a SRIOV VF VLANs object to the SRIOV Virtual Function Object.
Definition: sriov.c:1286
uint32_t max_tx_rate
Definition: sriov.h:88
rtnl_link_vf_stats_t
Definition: sriov.h:40
void rtnl_link_vf_set_trust(struct rtnl_link_vf *, uint32_t)
Set user trust setting on SRIOV Virtual Function Object.
Definition: sriov.c:1235
void rtnl_link_vf_vlan_free(nl_vf_vlans_t *vf_vlans)
Free an allocated SRIOV VF VLANs object.
Definition: sriov.c:1341
int rtnl_link_vf_get_linkstate(struct rtnl_link_vf *, uint32_t *)
Get link state of SRIOV Virtual Function.
Definition: sriov.c:957