1 /* SPDX-License-Identifier: LGPL-2.1-only */ 2 /* 3 * Copyright (c) 2016 Intel Corp. All rights reserved. 4 * Copyright (c) 2016 Jef Oliver <jef.oliver@intel.com> 5 */ 6 7 #ifndef NETLINK_LINK_SRIOV_H_ 8 #define NETLINK_LINK_SRIOV_H_ 9 10 #include <netlink/netlink.h> 11 #include <netlink/route/link.h> 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 #define RTNL_VF_GUID_STR_LEN 23 18 19 /** 20 * @ingroup sriov 21 */ 22 typedef enum { 23 RTNL_LINK_VF_RATE_API_UNSPEC, /*!< Unspecified API type */ 24 RTNL_LINK_VF_RATE_API_OLD, /*!< Old Rate setting API */ 25 RTNL_LINK_VF_RATE_API_NEW, /*!< New Rate setting API */ 26 __RTNL_LINK_VF_RATE_API_MAX, 27 } rtnl_link_rate_api_t; 28 29 #define RTNL_LINK_VF_RATE_API_MAX (__RTNL_LINK_VF_RATE_API_MAX - 1) 30 31 /** 32 * @ingroup sriov 33 */ 34 typedef enum { 35 RTNL_LINK_VF_STATS_RX_PACKETS, /*!< Packets Received */ 36 RTNL_LINK_VF_STATS_TX_PACKETS, /*!< Packets Sent */ 37 RTNL_LINK_VF_STATS_RX_BYTES, /*!< Bytes Recieved */ 38 RTNL_LINK_VF_STATS_TX_BYTES, /*!< Bytes Sent */ 39 RTNL_LINK_VF_STATS_BROADCAST, /*!< Broadcast packets received */ 40 RTNL_LINK_VF_STATS_MULTICAST, /*!< Multicast packets received */ 41 __RTNL_LINK_VF_STATS_MAX, 42 } rtnl_link_vf_stats_t; 43 44 #define RTNL_LINK_VF_STATS_MAX (__RTNL_LINK_VF_STATS_MAX - 1) 45 46 /** 47 * @struct rtnl_link_vf sriov.h "netlink/route/link/sriov.h" 48 * @brief SRIOV VF object 49 * @ingroup sriov 50 * 51 * @copydoc private_struct 52 */ 53 struct rtnl_link_vf; 54 55 /** 56 * @brief SRIOV VF VFLAN settings 57 * @ingroup sriov 58 */ 59 typedef struct nl_vf_vlan_info { 60 uint32_t vf_vlan; /*!< VLAN number */ 61 uint32_t vf_vlan_qos; /*!< VLAN QOS value */ 62 uint16_t vf_vlan_proto; /*!< VLAN protocol */ 63 } nl_vf_vlan_info_t; 64 65 /** 66 * @brief SRIOV VF VLANs information 67 * @ingroup sriov 68 */ 69 typedef struct nl_vf_vlans { 70 int ce_refcnt; /*!< Reference counter. Don't change this value */ 71 int size; /*!< Number of VLANs on the SRIOV VF */ 72 nl_vf_vlan_info_t * vlans; /*!< nl_vf_vlan_info_t array of SRIOV VF VLANs */ 73 } nl_vf_vlans_t; 74 75 /** 76 * @brief VF Rate information structure 77 * @ingroup sriov 78 */ 79 struct nl_vf_rate { 80 int api; /*!< rtnl_link_rate_api_t API Version to use */ 81 uint32_t rate; /*!< Old API Max Rate in Mbps */ 82 uint32_t max_tx_rate; /*!< New API Max Rate in Mbps */ 83 uint32_t min_tx_rate; /*!< New API Mix Rate in Mbps */ 84 }; 85 86 extern int rtnl_link_vf_add(struct rtnl_link *, struct rtnl_link_vf *); 87 extern struct rtnl_link_vf *rtnl_link_vf_alloc(void); 88 extern void rtnl_link_vf_free(struct rtnl_link_vf *); 89 extern struct rtnl_link_vf *rtnl_link_vf_get(struct rtnl_link *, uint32_t); 90 extern void rtnl_link_vf_put(struct rtnl_link_vf *); 91 92 extern int rtnl_link_vf_get_addr(struct rtnl_link_vf *, struct nl_addr **); 93 extern void rtnl_link_vf_set_addr(struct rtnl_link_vf *, struct nl_addr *); 94 95 extern void rtnl_link_vf_set_ib_node_guid(struct rtnl_link_vf *, uint64_t); 96 extern void rtnl_link_vf_set_ib_port_guid(struct rtnl_link_vf *, uint64_t); 97 98 extern int rtnl_link_vf_get_index(struct rtnl_link_vf *, uint32_t *); 99 extern void rtnl_link_vf_set_index(struct rtnl_link_vf *, uint32_t); 100 101 extern int rtnl_link_vf_get_linkstate(struct rtnl_link_vf *, uint32_t *); 102 extern void rtnl_link_vf_set_linkstate(struct rtnl_link_vf *, uint32_t); 103 104 extern int rtnl_link_vf_get_rate(struct rtnl_link_vf *, struct nl_vf_rate *); 105 extern void rtnl_link_vf_set_rate(struct rtnl_link_vf *, struct nl_vf_rate *); 106 107 extern int rtnl_link_vf_get_rss_query_en(struct rtnl_link_vf *, uint32_t *); 108 extern void rtnl_link_vf_set_rss_query_en(struct rtnl_link_vf *, uint32_t); 109 110 extern int rtnl_link_vf_get_spoofchk(struct rtnl_link_vf *, uint32_t *); 111 extern void rtnl_link_vf_set_spoofchk(struct rtnl_link_vf *, uint32_t); 112 113 extern int rtnl_link_vf_get_stat(struct rtnl_link_vf *, rtnl_link_vf_stats_t, 114 uint64_t *); 115 116 extern int rtnl_link_vf_get_trust(struct rtnl_link_vf *, uint32_t *); 117 extern void rtnl_link_vf_set_trust(struct rtnl_link_vf *, uint32_t); 118 119 extern int rtnl_link_vf_get_vlans(struct rtnl_link_vf *, nl_vf_vlans_t **); 120 extern void rtnl_link_vf_set_vlans(struct rtnl_link_vf *, nl_vf_vlans_t *); 121 122 extern int rtnl_link_vf_vlan_alloc(nl_vf_vlans_t **, int); 123 extern void rtnl_link_vf_vlan_free(nl_vf_vlans_t *vf_vlans); 124 extern void rtnl_link_vf_vlan_put(nl_vf_vlans_t *); 125 126 /* Utility functions */ 127 extern char *rtnl_link_vf_linkstate2str(uint32_t, char *, size_t); 128 extern int rtnl_link_vf_str2linkstate(const char *); 129 130 extern char *rtnl_link_vf_vlanproto2str(uint16_t, char *, size_t); 131 extern int rtnl_link_vf_str2vlanproto(const char *); 132 133 extern int rtnl_link_vf_str2guid(uint64_t *, const char *); 134 135 #ifdef __cplusplus 136 } 137 #endif 138 139 #endif 140