• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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,
33 } rtnl_link_rate_api_t;
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,
48 } rtnl_link_vf_stats_t;
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 */
69 } nl_vf_vlan_info_t;
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 */
79 } nl_vf_vlans_t;
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
146