linux-user: netlink: Add IFLA_VFINFO_LIST

# QEMU_LOG=unimp ip a
  Unknown host QEMU_IFLA type: 22

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20211219154514.2165728-2-laurent@vivier.eu>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This commit is contained in:
Laurent Vivier 2021-12-19 16:45:13 +01:00
parent 312aef98ae
commit a99478672c

View File

@ -271,6 +271,37 @@ enum {
QEMU___RTA_MAX
};
enum {
QEMU_IFLA_VF_STATS_RX_PACKETS,
QEMU_IFLA_VF_STATS_TX_PACKETS,
QEMU_IFLA_VF_STATS_RX_BYTES,
QEMU_IFLA_VF_STATS_TX_BYTES,
QEMU_IFLA_VF_STATS_BROADCAST,
QEMU_IFLA_VF_STATS_MULTICAST,
QEMU_IFLA_VF_STATS_PAD,
QEMU_IFLA_VF_STATS_RX_DROPPED,
QEMU_IFLA_VF_STATS_TX_DROPPED,
QEMU__IFLA_VF_STATS_MAX,
};
enum {
QEMU_IFLA_VF_UNSPEC,
QEMU_IFLA_VF_MAC,
QEMU_IFLA_VF_VLAN,
QEMU_IFLA_VF_TX_RATE,
QEMU_IFLA_VF_SPOOFCHK,
QEMU_IFLA_VF_LINK_STATE,
QEMU_IFLA_VF_RATE,
QEMU_IFLA_VF_RSS_QUERY_EN,
QEMU_IFLA_VF_STATS,
QEMU_IFLA_VF_TRUST,
QEMU_IFLA_VF_IB_NODE_GUID,
QEMU_IFLA_VF_IB_PORT_GUID,
QEMU_IFLA_VF_VLAN_LIST,
QEMU_IFLA_VF_BROADCAST,
QEMU__IFLA_VF_MAX,
};
TargetFdTrans **target_fd_trans;
QemuMutex target_fd_trans_lock;
unsigned int target_fd_max;
@ -808,6 +839,145 @@ static abi_long host_to_target_data_xdp_nlattr(struct nlattr *nlattr,
return 0;
}
static abi_long host_to_target_data_vlan_list_nlattr(struct nlattr *nlattr,
void *context)
{
struct ifla_vf_vlan_info *vlan_info;
switch (nlattr->nla_type) {
/* struct ifla_vf_vlan_info */
case IFLA_VF_VLAN_INFO:
vlan_info = NLA_DATA(nlattr);
vlan_info->vf = tswap32(vlan_info->vf);
vlan_info->vlan = tswap32(vlan_info->vlan);
vlan_info->qos = tswap32(vlan_info->qos);
break;
default:
qemu_log_mask(LOG_UNIMP, "Unknown host VLAN LIST type: %d\n",
nlattr->nla_type);
break;
}
return 0;
}
static abi_long host_to_target_data_vf_stats_nlattr(struct nlattr *nlattr,
void *context)
{
uint64_t *u64;
switch (nlattr->nla_type) {
/* uint64_t */
case QEMU_IFLA_VF_STATS_RX_PACKETS:
case QEMU_IFLA_VF_STATS_TX_PACKETS:
case QEMU_IFLA_VF_STATS_RX_BYTES:
case QEMU_IFLA_VF_STATS_TX_BYTES:
case QEMU_IFLA_VF_STATS_BROADCAST:
case QEMU_IFLA_VF_STATS_MULTICAST:
case QEMU_IFLA_VF_STATS_PAD:
case QEMU_IFLA_VF_STATS_RX_DROPPED:
case QEMU_IFLA_VF_STATS_TX_DROPPED:
u64 = NLA_DATA(nlattr);
*u64 = tswap64(*u64);
break;
default:
qemu_log_mask(LOG_UNIMP, "Unknown host VF STATS type: %d\n",
nlattr->nla_type);
break;
}
return 0;
}
static abi_long host_to_target_data_vfinfo_nlattr(struct nlattr *nlattr,
void *context)
{
struct ifla_vf_mac *mac;
struct ifla_vf_vlan *vlan;
struct ifla_vf_vlan_info *vlan_info;
struct ifla_vf_spoofchk *spoofchk;
struct ifla_vf_rate *rate;
struct ifla_vf_link_state *link_state;
struct ifla_vf_rss_query_en *rss_query_en;
struct ifla_vf_trust *trust;
struct ifla_vf_guid *guid;
switch (nlattr->nla_type) {
/* struct ifla_vf_mac */
case QEMU_IFLA_VF_MAC:
mac = NLA_DATA(nlattr);
mac->vf = tswap32(mac->vf);
break;
/* struct ifla_vf_broadcast */
case QEMU_IFLA_VF_BROADCAST:
break;
/* struct struct ifla_vf_vlan */
case QEMU_IFLA_VF_VLAN:
vlan = NLA_DATA(nlattr);
vlan->vf = tswap32(vlan->vf);
vlan->vlan = tswap32(vlan->vlan);
vlan->qos = tswap32(vlan->qos);
break;
/* struct ifla_vf_vlan_info */
case QEMU_IFLA_VF_TX_RATE:
vlan_info = NLA_DATA(nlattr);
vlan_info->vf = tswap32(vlan_info->vf);
vlan_info->vlan = tswap32(vlan_info->vlan);
vlan_info->qos = tswap32(vlan_info->qos);
break;
/* struct ifla_vf_spoofchk */
case QEMU_IFLA_VF_SPOOFCHK:
spoofchk = NLA_DATA(nlattr);
spoofchk->vf = tswap32(spoofchk->vf);
spoofchk->setting = tswap32(spoofchk->setting);
break;
/* struct ifla_vf_rate */
case QEMU_IFLA_VF_RATE:
rate = NLA_DATA(nlattr);
rate->vf = tswap32(rate->vf);
rate->min_tx_rate = tswap32(rate->min_tx_rate);
rate->max_tx_rate = tswap32(rate->max_tx_rate);
break;
/* struct ifla_vf_link_state */
case QEMU_IFLA_VF_LINK_STATE:
link_state = NLA_DATA(nlattr);
link_state->vf = tswap32(link_state->vf);
link_state->link_state = tswap32(link_state->link_state);
break;
/* struct ifla_vf_rss_query_en */
case QEMU_IFLA_VF_RSS_QUERY_EN:
rss_query_en = NLA_DATA(nlattr);
rss_query_en->vf = tswap32(rss_query_en->vf);
rss_query_en->setting = tswap32(rss_query_en->setting);
break;
/* struct ifla_vf_trust */
case QEMU_IFLA_VF_TRUST:
trust = NLA_DATA(nlattr);
trust->vf = tswap32(trust->vf);
trust->setting = tswap32(trust->setting);
break;
/* struct ifla_vf_guid */
case QEMU_IFLA_VF_IB_NODE_GUID:
case QEMU_IFLA_VF_IB_PORT_GUID:
guid = NLA_DATA(nlattr);
guid->vf = tswap32(guid->vf);
guid->guid = tswap32(guid->guid);
break;
/* nested */
case QEMU_IFLA_VF_VLAN_LIST:
return host_to_target_for_each_nlattr(RTA_DATA(nlattr), nlattr->nla_len,
NULL,
host_to_target_data_vlan_list_nlattr);
case QEMU_IFLA_VF_STATS:
return host_to_target_for_each_nlattr(RTA_DATA(nlattr), nlattr->nla_len,
NULL,
host_to_target_data_vf_stats_nlattr);
default:
qemu_log_mask(LOG_UNIMP, "Unknown host VFINFO type: %d\n",
nlattr->nla_type);
break;
}
return 0;
}
static abi_long host_to_target_data_link_rtattr(struct rtattr *rtattr)
{
uint32_t *u32;
@ -945,6 +1115,10 @@ static abi_long host_to_target_data_link_rtattr(struct rtattr *rtattr)
return host_to_target_for_each_nlattr(RTA_DATA(rtattr), rtattr->rta_len,
NULL,
host_to_target_data_xdp_nlattr);
case QEMU_IFLA_VFINFO_LIST:
return host_to_target_for_each_nlattr(RTA_DATA(rtattr), rtattr->rta_len,
NULL,
host_to_target_data_vfinfo_nlattr);
default:
qemu_log_mask(LOG_UNIMP, "Unknown host QEMU_IFLA type: %d\n",
rtattr->rta_type);