Skip to content

Commit

Permalink
lib/sriov: merge branch 'sriov'
Browse files Browse the repository at this point in the history
  • Loading branch information
thom311 committed Nov 28, 2016
2 parents d9840f6 + 46f04de commit bd42de2
Show file tree
Hide file tree
Showing 11 changed files with 1,765 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/Makefile.am
Expand Up @@ -64,6 +64,7 @@ nobase_libnlinclude_HEADERS = \
netlink/route/link/sit.h \
netlink/route/link/ipvlan.h \
netlink/route/link/vrf.h \
netlink/route/link/sriov.h \
netlink/route/qdisc/cbq.h \
netlink/route/qdisc/dsmark.h \
netlink/route/qdisc/fifo.h \
Expand Down Expand Up @@ -171,4 +172,5 @@ noinst_HEADERS = \
netlink-private/cache-api.h \
netlink-private/object-api.h \
netlink-private/route/link/api.h \
netlink-private/route/link/sriov.h \
netlink-private/route/tc-api.h
1 change: 1 addition & 0 deletions include/linux-private/linux/if_ether.h
Expand Up @@ -78,6 +78,7 @@
*/
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */
#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */
#define ETH_P_TIPC 0x88CA /* TIPC */
#define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */
#define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */
Expand Down
17 changes: 17 additions & 0 deletions include/linux-private/linux/if_link.h
Expand Up @@ -625,6 +625,7 @@ enum {
IFLA_VF_TRUST, /* Trust VF */
IFLA_VF_IB_NODE_GUID, /* VF Infiniband node GUID */
IFLA_VF_IB_PORT_GUID, /* VF Infiniband port GUID */
IFLA_VF_VLAN_LIST, /* nested list of vlans, option for QinQ */
__IFLA_VF_MAX,
};

Expand All @@ -641,6 +642,22 @@ struct ifla_vf_vlan {
__u32 qos;
};

enum {
IFLA_VF_VLAN_INFO_UNSPEC,
IFLA_VF_VLAN_INFO, /* VLAN ID, QoS and VLAN protocol */
__IFLA_VF_VLAN_INFO_MAX,
};

#define IFLA_VF_VLAN_INFO_MAX (__IFLA_VF_VLAN_INFO_MAX - 1)
#define MAX_VLAN_LIST_LEN 1

struct ifla_vf_vlan_info {
__u32 vf;
__u32 vlan; /* 0 - 4095, 0 disables VLAN filter */
__u32 qos;
__be16 vlan_proto; /* VLAN protocol either 802.1Q or 802.1ad */
};

struct ifla_vf_tx_rate {
__u32 vf;
__u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */
Expand Down
34 changes: 34 additions & 0 deletions include/netlink-private/route/link/sriov.h
@@ -0,0 +1,34 @@
/*
* include/netlink-private/route/link/sriov.h SRIOV VF Info
*
* 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 version 2.1
* of the License.
*
* Copyright (c) 2016 Intel Corp. All rights reserved.
* Copyright (c) 2016 Jef Oliver <jef.oliver@intel.com>
*/

#ifndef NETLINK_PRIV_LINK_SRIOV_H_
#define NETLINK_PRIV_LINK_SRIOV_H_

#include <netlink/netlink.h>
#include <netlink/route/link/sriov.h>

#ifdef __cplusplus
extern "C" {
#endif

extern int rtnl_link_sriov_clone(struct rtnl_link *, struct rtnl_link *);
extern void rtnl_link_sriov_dump_details(struct rtnl_link *, struct nl_dump_params *);
extern void rtnl_link_sriov_dump_stats(struct rtnl_link *, struct nl_dump_params *);
extern int rtnl_link_sriov_fill_vflist(struct nl_msg *, struct rtnl_link *);
extern void rtnl_link_sriov_free_data(struct rtnl_link *);
extern int rtnl_link_sriov_parse_vflist(struct rtnl_link *, struct nlattr **);

#ifdef __cplusplus
}
#endif

#endif
23 changes: 23 additions & 0 deletions include/netlink-private/types.h
Expand Up @@ -22,6 +22,7 @@
#include <netlink/netfilter/ct.h>
#include <netlink-private/object-api.h>
#include <netlink-private/route/tc-api.h>
#include <netlink-private/route/link/sriov.h>
#include <linux/tc_act/tc_mirred.h>
#include <linux/tc_act/tc_skbedit.h>

Expand All @@ -36,6 +37,7 @@ struct nl_cache_ops;
struct nl_sock;
struct nl_object;
struct nl_hash_table;
struct nl_vf_vlans;

struct nl_cb
{
Expand Down Expand Up @@ -154,6 +156,26 @@ struct rtnl_link_map
uint8_t lm_port;
};

struct rtnl_link_vf
{
struct nl_list_head vf_list;
int ce_refcnt;
uint32_t ce_mask;
uint32_t vf_index;
uint64_t vf_guid_node;
uint64_t vf_guid_port;
uint32_t vf_linkstate;
struct nl_addr * vf_lladdr;
uint32_t vf_max_tx_rate;
uint32_t vf_min_tx_rate;
uint32_t vf_rate;
uint32_t vf_rss_query_en;
uint32_t vf_spoofchk;
uint64_t vf_stats[RTNL_LINK_VF_STATS_MAX+1];
uint32_t vf_trust;
struct nl_vf_vlans * vf_vlans;
};

#define IFQDISCSIZ 32

struct rtnl_link
Expand Down Expand Up @@ -197,6 +219,7 @@ struct rtnl_link
struct nl_data * l_phys_port_id;
int l_ns_fd;
pid_t l_ns_pid;
struct rtnl_link_vf * l_vf_list;
};

struct rtnl_ncacheinfo
Expand Down
4 changes: 4 additions & 0 deletions include/netlink/route/link.h
Expand Up @@ -244,6 +244,10 @@ extern int rtnl_link_release(struct nl_sock *, struct rtnl_link *);
extern int rtnl_link_fill_info(struct nl_msg *, struct rtnl_link *);
extern int rtnl_link_info_parse(struct rtnl_link *, struct nlattr **);

extern int rtnl_link_has_vf_list(struct rtnl_link *);
extern void rtnl_link_set_vf_list(struct rtnl_link *);
extern void rtnl_link_unset_vf_list(struct rtnl_link *);


/* deprecated */
extern int rtnl_link_set_info_type(struct rtnl_link *, const char *) __attribute__((deprecated));
Expand Down
144 changes: 144 additions & 0 deletions include/netlink/route/link/sriov.h
@@ -0,0 +1,144 @@
/*
* include/netlink/route/link/sriov.h SRIOV VF Info
*
* 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 version 2.1
* of the License.
*
* Copyright (c) 2016 Intel Corp. All rights reserved.
* Copyright (c) 2016 Jef Oliver <jef.oliver@intel.com>
*/

#ifndef NETLINK_LINK_SRIOV_H_
#define NETLINK_LINK_SRIOV_H_

#include <netlink/netlink.h>
#include <netlink/route/link.h>

#ifdef __cplusplus
extern "C" {
#endif

#define RTNL_VF_GUID_STR_LEN 23

/**
* @ingroup sriov
*/
typedef enum {
RTNL_LINK_VF_RATE_API_UNSPEC, /*!< Unspecified API type */
RTNL_LINK_VF_RATE_API_OLD, /*!< Old Rate setting API */
RTNL_LINK_VF_RATE_API_NEW, /*!< New Rate setting API */
__RTNL_LINK_VF_RATE_API_MAX,
} rtnl_link_rate_api_t;

#define RTNL_LINK_VF_RATE_API_MAX (__RTNL_LINK_VF_RATE_API_MAX - 1)

/**
* @ingroup sriov
*/
typedef enum {
RTNL_LINK_VF_STATS_RX_PACKETS, /*!< Packets Received */
RTNL_LINK_VF_STATS_TX_PACKETS, /*!< Packets Sent */
RTNL_LINK_VF_STATS_RX_BYTES, /*!< Bytes Recieved */
RTNL_LINK_VF_STATS_TX_BYTES, /*!< Bytes Sent */
RTNL_LINK_VF_STATS_BROADCAST, /*!< Broadcast packets received */
RTNL_LINK_VF_STATS_MULTICAST, /*!< Multicast packets received */
__RTNL_LINK_VF_STATS_MAX,
} rtnl_link_vf_stats_t;

#define RTNL_LINK_VF_STATS_MAX (__RTNL_LINK_VF_STATS_MAX - 1)

/**
* @struct rtnl_link_vf sriov.h "netlink/route/link/sriov.h"
* @brief SRIOV VF object
* @ingroup sriov
*
* @copydoc private_struct
*/
struct rtnl_link_vf;

/**
* @brief SRIOV VF VFLAN settings
* @ingroup sriov
*/
typedef struct nl_vf_vlan_info {
uint32_t vf_vlan; /*!< VLAN number */
uint32_t vf_vlan_qos; /*!< VLAN QOS value */
uint16_t vf_vlan_proto; /*!< VLAN protocol */
} nl_vf_vlan_info_t;

/**
* @brief SRIOV VF VLANs information
* @ingroup sriov
*/
typedef struct nl_vf_vlans {
int ce_refcnt; /*!< Reference counter. Don't change this value */
int size; /*!< Number of VLANs on the SRIOV VF */
nl_vf_vlan_info_t * vlans; /*!< nl_vf_vlan_info_t array of SRIOV VF VLANs */
} nl_vf_vlans_t;

/**
* @brief VF Rate information structure
* @ingroup sriov
*/
struct nl_vf_rate {
int api; /*!< rtnl_link_rate_api_t API Version to use */
uint32_t rate; /*!< Old API Max Rate in Mbps */
uint32_t max_tx_rate; /*!< New API Max Rate in Mbps */
uint32_t min_tx_rate; /*!< New API Mix Rate in Mbps */
};

extern int rtnl_link_vf_add(struct rtnl_link *, struct rtnl_link_vf *);
extern struct rtnl_link_vf *rtnl_link_vf_alloc(void);
extern void rtnl_link_vf_free(struct rtnl_link_vf *);
extern struct rtnl_link_vf *rtnl_link_vf_get(struct rtnl_link *, uint32_t);
extern void rtnl_link_vf_put(struct rtnl_link_vf *);

extern int rtnl_link_vf_get_addr(struct rtnl_link_vf *, struct nl_addr **);
extern void rtnl_link_vf_set_addr(struct rtnl_link_vf *, struct nl_addr *);

extern void rtnl_link_vf_set_ib_node_guid(struct rtnl_link_vf *, uint64_t);
extern void rtnl_link_vf_set_ib_port_guid(struct rtnl_link_vf *, uint64_t);

extern int rtnl_link_vf_get_index(struct rtnl_link_vf *, uint32_t *);
extern void rtnl_link_vf_set_index(struct rtnl_link_vf *, uint32_t);

extern int rtnl_link_vf_get_linkstate(struct rtnl_link_vf *, uint32_t *);
extern void rtnl_link_vf_set_linkstate(struct rtnl_link_vf *, uint32_t);

extern int rtnl_link_vf_get_rate(struct rtnl_link_vf *, struct nl_vf_rate *);
extern void rtnl_link_vf_set_rate(struct rtnl_link_vf *, struct nl_vf_rate *);

extern int rtnl_link_vf_get_rss_query_en(struct rtnl_link_vf *, uint32_t *);
extern void rtnl_link_vf_set_rss_query_en(struct rtnl_link_vf *, uint32_t);

extern int rtnl_link_vf_get_spoofchk(struct rtnl_link_vf *, uint32_t *);
extern void rtnl_link_vf_set_spoofchk(struct rtnl_link_vf *, uint32_t);

extern int rtnl_link_vf_get_stat(struct rtnl_link_vf *, rtnl_link_vf_stats_t,
uint64_t *);

extern int rtnl_link_vf_get_trust(struct rtnl_link_vf *, uint32_t *);
extern void rtnl_link_vf_set_trust(struct rtnl_link_vf *, uint32_t);

extern int rtnl_link_vf_get_vlans(struct rtnl_link_vf *, nl_vf_vlans_t **);
extern void rtnl_link_vf_set_vlans(struct rtnl_link_vf *, nl_vf_vlans_t *);

extern int rtnl_link_vf_vlan_alloc(nl_vf_vlans_t **, int);
extern void rtnl_link_vf_vlan_put(nl_vf_vlans_t *);

/* Utility functions */
extern char *rtnl_link_vf_linkstate2str(uint32_t, char *, size_t);
extern int rtnl_link_vf_str2linkstate(const char *);

extern char *rtnl_link_vf_vlanproto2str(uint16_t, char *, size_t);
extern int rtnl_link_vf_str2vlanproto(const char *);

extern int rtnl_link_vf_str2guid(uint64_t *, const char *);

#ifdef __cplusplus
}
#endif

#endif
2 changes: 1 addition & 1 deletion lib/Makefile.am
Expand Up @@ -92,7 +92,7 @@ libnl_route_3_la_SOURCES = \
route/addr.c route/class.c route/cls.c route/act.c route/link.c \
route/neigh.c route/neightbl.c route/nexthop.c route/qdisc.c \
route/route.c route/route_obj.c route/route_utils.c route/rtnl.c \
route/rule.c route/tc.c route/classid.c \
route/rule.c route/tc.c route/classid.c route/link/sriov.c \
\
route/cls/fw.c route/cls/police.c route/cls/u32.c route/cls/basic.c \
route/cls/cgroup.c \
Expand Down

0 comments on commit bd42de2

Please sign in to comment.