Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171093723
D58778.id183846.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
12 KB
Referenced Files
None
Subscribers
None
D58778.id183846.diff
View Options
Index: sbin/ifconfig/Makefile
===================================================================
--- sbin/ifconfig/Makefile
+++ sbin/ifconfig/Makefile
@@ -66,6 +66,7 @@
.if ${MK_NETLINK_SUPPORT} != "no"
SRCS+= ifconfig_netlink.c
+SRCS+= ifvfstatus.c # VF status information
SRCS+= ifgeneve.c # GENEVE support
.else
CFLAGS+=-DWITHOUT_NETLINK
Index: sbin/ifconfig/ifconfig.h
===================================================================
--- sbin/ifconfig/ifconfig.h
+++ sbin/ifconfig/ifconfig.h
@@ -281,6 +281,10 @@
void clone_setdefcallback_filter(clone_match_func *, clone_callback_func *);
void sfp_status(if_ctx *ctx);
+#ifndef WITHOUT_NETLINK
+struct snl_parsed_vf_status;
+void vf_status(if_ctx *, const struct snl_parsed_vf_status *, uint32_t);
+#endif
struct sockaddr_dl;
bool match_ether(const struct sockaddr_dl *sdl);
Index: sbin/ifconfig/ifconfig.8
===================================================================
--- sbin/ifconfig/ifconfig.8
+++ sbin/ifconfig/ifconfig.8
@@ -325,6 +325,65 @@
Display only the interfaces that are up.
.It Fl v
Get more verbose status for an interface.
+When supported, this includes the status of configured SR-IOV virtual
+functions.
+Fields that the PF driver cannot observe are omitted; an omitted field does
+not mean false or zero.
+The status begins with the PF link state and speed normally advertised to
+VFs, followed by the number of VFs and one record for each VF.
+PF link status does not demonstrate that a VF driver is operational.
+.Pp
+Per-VF fields are arranged in the following groups:
+.Bl -tag -width "driver.*"
+.It Cm identity
+The primary MAC address known to the PF.
+.It Cm state
+.Cm configured=yes
+means that the PF accepted the VF configuration.
+.Cm initialized=yes
+means that the VF completed its driver or mailbox handshake since its last
+reset.
+When available, this group also reports whether traffic is enabled, whether
+malicious-driver detection blocked the VF, and whether it is quarantined.
+.It Cm resources
+The number of symmetric RX/TX queue pairs allocated to the VF.
+This is not necessarily the number of queue pairs currently used by its
+driver.
+.It Cm vlan
+An access VLAN is imposed by the PF; trunk mode means that no access VLAN is
+imposed and does not promise unlimited filter capacity.
+The filter count includes explicit filters recorded by the PF and excludes
+implicit untagged and priority-tag membership.
+.It Cm policy
+Administrative permissions for VF requests, MAC anti-spoofing state, and an
+optional per-VF link-state policy.
+Permissions describe what the VF may request, not its current requests.
+.It Cm protocol
+The negotiated PF/VF mailbox API version, when known.
+.It Cm driver.*
+Driver-specific extension namespaces.
+The namespace version and scalar boolean, numeric, string, and binary fields
+are displayed using their stable schema names.
+See the PF driver's manual page for their meanings.
+.El
+.Pp
+For example:
+.Bd -literal -offset indent
+VF-visible PF link: state=up speed=10000Mbps
+virtual functions: 1
+ vf 0:
+ identity: mac=02:00:00:00:00:01
+ state: configured=yes initialized=yes traffic=enabled
+ resources: queue-pairs=4
+ vlan: mode=trunk filters=0
+ policy: set-mac=denied set-vlan=allowed anti-spoof=on
+.Ed
+.Pp
+See
+.Xr iovctl.conf 5
+for VF configuration and
+.Xr iovctl 8
+for PCI attachment and passthrough status.
.It Ar address
For the inet family,
the address is either a host name present in the host name data
Index: sbin/ifconfig/ifconfig_netlink.c
===================================================================
--- sbin/ifconfig/ifconfig_netlink.c
+++ sbin/ifconfig/ifconfig_netlink.c
@@ -141,7 +141,7 @@
* Memory is allocated using snl temporary buffers
*/
static struct ifmap *
-prepare_ifmap(struct snl_state *ss, const char *ifname)
+prepare_ifmap(struct snl_state *ss, const char *ifname, bool vf_status)
{
struct snl_writer nw = {};
@@ -149,8 +149,10 @@
struct nlmsghdr *hdr = snl_create_msg_request(&nw, RTM_GETLINK);
hdr->nlmsg_flags |= NLM_F_DUMP;
snl_reserve_msg_object(&nw, struct ifinfomsg);
- if (ifname != NULL)
- snl_add_msg_attr_string(&nw, IFLA_IFNAME, ifname);
+ if (ifname != NULL)
+ snl_add_msg_attr_string(&nw, IFLA_IFNAME, ifname);
+ if (vf_status)
+ snl_add_msg_attr_u32(&nw, IFLA_EXT_MASK, RTEXT_FILTER_VF);
if (! (hdr = snl_finalize_msg(&nw)) || !snl_send_message(ss, hdr))
return (NULL);
@@ -414,6 +416,8 @@
args->afp->af_other_status(ctx);
print_ifstatus(ctx);
+ if (args->verbose > 0)
+ vf_status(ctx, &link->iflaf_vf_status, link->ifla_num_vf);
if (args->drivername || args->verbose) {
if (ifconfig_get_orig_name(lifh, link->ifla_ifname,
&drivername) != 0) {
@@ -457,7 +461,8 @@
nl_init_socket(&ss);
- struct ifmap *ifmap = prepare_ifmap(&ss, args->ifname);
+ struct ifmap *ifmap = prepare_ifmap(&ss, args->ifname,
+ args->verbose > 0);
struct iface **sorted_ifaces = snl_allocz(&ss, ifmap->count * sizeof(void *));
for (uint32_t i = 0, num = 0; i < ifmap->size; i++) {
if (ifmap->ifaces[i] != NULL) {
Index: sbin/ifconfig/ifvfstatus.c
===================================================================
--- /dev/null
+++ sbin/ifconfig/ifvfstatus.c
@@ -0,0 +1,252 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019 Intel Corporation
+ * All rights reserved.
+ */
+
+#include <sys/types.h>
+
+#include <net/ethernet.h>
+#include <net/if.h>
+
+#include <netlink/netlink.h>
+#include <netlink/netlink_snl.h>
+#include <netlink/netlink_snl_route_parsers.h>
+#include <netlink/route/interface.h>
+
+#include <err.h>
+#include <inttypes.h>
+#include <stdio.h>
+
+#include "ifconfig.h"
+
+static void
+vf_group_begin(bool *printed, const char *name)
+{
+
+ if (!*printed) {
+ printf("\t\t\t%s:", name);
+ *printed = true;
+ }
+}
+
+static void
+vf_group_end(bool printed)
+{
+
+ if (printed)
+ putchar('\n');
+}
+
+static const char *
+vf_link_state_name(uint8_t state)
+{
+
+ switch (state) {
+ case IFLAF_VF_LINK_DOWN:
+ return ("down");
+ case IFLAF_VF_LINK_UP:
+ return ("up");
+ case IFLAF_VF_LINK_AUTO:
+ return ("auto");
+ default:
+ return ("unknown");
+ }
+}
+
+static const char *
+vf_vlan_mode_name(uint8_t mode)
+{
+
+ switch (mode) {
+ case IFLAF_VF_VLAN_ACCESS:
+ return ("access");
+ case IFLAF_VF_VLAN_TRUNK:
+ return ("trunk");
+ default:
+ return ("unknown");
+ }
+}
+
+static void
+vf_driver_field(const struct snl_parsed_vf_driver_field *field)
+{
+ const uint8_t *data;
+ uint32_t i, length;
+
+ printf(" %s=", field->name);
+ switch (field->type) {
+ case SNL_VFDF_BOOL:
+ printf("%s", field->boolean ? "yes" : "no");
+ break;
+ case SNL_VFDF_NUMBER:
+ printf("%" PRIu64, field->number);
+ break;
+ case SNL_VFDF_STRING:
+ printf("%s", field->string);
+ break;
+ case SNL_VFDF_BINARY:
+ data = NLA_DATA(field->binary);
+ length = (uint32_t)NLA_DATA_LEN(field->binary);
+ printf("0x");
+ for (i = 0; i < length; i++)
+ printf("%02x", data[i]);
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+vf_driver_status(const struct snl_parsed_vf *vf)
+{
+ const struct snl_parsed_vf_driver *driver;
+ const struct snl_parsed_vf_driver_field *field;
+ uint32_t i, j;
+
+ for (i = 0; i < vf->drivers.count; i++) {
+ driver = vf->drivers.items[i];
+ printf("\t\t\t%s: version=%u", driver->name,
+ driver->version);
+ for (j = 0; j < driver->fields.count; j++) {
+ field = driver->fields.items[j];
+ vf_driver_field(field);
+ }
+ putchar('\n');
+ }
+}
+
+void
+vf_status(if_ctx *ctx __unused, const struct snl_parsed_vf_status *status,
+ uint32_t expected_vfs)
+{
+ const struct snl_parsed_vf *vf;
+ const struct ether_addr *mac;
+ const char *mode;
+ uint64_t speed;
+ bool printed;
+ uint32_t i;
+
+ if (!status->present)
+ return;
+ if (status->error != 0) {
+ warnc(status->error, "VF status");
+ return;
+ }
+
+ printf("\tVF-visible PF link: state=%s",
+ vf_link_state_name(status->pf_link_state));
+ speed = status->pf_link_speed;
+ if (speed != 0) {
+ if (speed % IF_Mbps(1) == 0)
+ printf(" speed=%" PRIu64 "Mbps", speed / IF_Mbps(1));
+ else
+ printf(" speed=%" PRIu64 "bps", speed);
+ }
+ putchar('\n');
+
+ if (expected_vfs != status->vfs.count)
+ warnx("kernel reported %u VFs but returned %u VF records",
+ expected_vfs, status->vfs.count);
+ printf("\tvirtual functions: %u\n", status->vfs.count);
+ for (i = 0; i < status->vfs.count; i++) {
+ vf = status->vfs.items[i];
+ printf("\t\tvf %3u:\n", vf->index);
+
+ printed = false;
+ if ((vf->attrs & SNL_VF_F_MAC) != 0 &&
+ NLA_DATA_LEN(vf->mac) == ETHER_ADDR_LEN) {
+ mac = (const struct ether_addr *)NLA_DATA(vf->mac);
+ vf_group_begin(&printed, "identity");
+ printf(" mac=%s", ether_ntoa(mac));
+ }
+ vf_group_end(printed);
+
+ printed = false;
+ if ((vf->attrs & SNL_VF_F_CONFIGURED) != 0) {
+ vf_group_begin(&printed, "state");
+ printf(" configured=%s", vf->configured ? "yes" : "no");
+ }
+ if ((vf->attrs & SNL_VF_F_INITIALIZED) != 0) {
+ vf_group_begin(&printed, "state");
+ printf(" initialized=%s", vf->initialized ? "yes" : "no");
+ }
+ if ((vf->attrs & SNL_VF_F_TRAFFIC_ENABLED) != 0) {
+ vf_group_begin(&printed, "state");
+ printf(" traffic=%s", vf->traffic_enabled ?
+ "enabled" : "disabled");
+ }
+ if ((vf->attrs & SNL_VF_F_MDD_BLOCKED) != 0) {
+ vf_group_begin(&printed, "state");
+ printf(" mdd-blocked=%s", vf->mdd_blocked ? "yes" : "no");
+ }
+ if ((vf->attrs & SNL_VF_F_QUARANTINED) != 0) {
+ vf_group_begin(&printed, "state");
+ printf(" quarantined=%s", vf->quarantined ? "yes" : "no");
+ }
+ vf_group_end(printed);
+
+ printed = false;
+ if ((vf->attrs & SNL_VF_F_NUM_QUEUES) != 0) {
+ vf_group_begin(&printed, "resources");
+ printf(" queue-pairs=%u", vf->num_queues);
+ }
+ vf_group_end(printed);
+
+ printed = false;
+ if ((vf->attrs & SNL_VF_F_VLAN_MODE) != 0) {
+ mode = vf_vlan_mode_name(vf->vlan_mode);
+ vf_group_begin(&printed, "vlan");
+ printf(" mode=%s", mode);
+ if (vf->vlan_mode == IFLAF_VF_VLAN_ACCESS &&
+ (vf->attrs & SNL_VF_F_VLAN) != 0)
+ printf(" vid=%u", vf->vlan);
+ }
+ if ((vf->attrs & SNL_VF_F_VLAN_COUNT) != 0) {
+ vf_group_begin(&printed, "vlan");
+ printf(" filters=%u", vf->vlan_count);
+ }
+ if ((vf->attrs & SNL_VF_F_VLAN_LIMIT) != 0) {
+ vf_group_begin(&printed, "vlan");
+ printf(" limit=%u", vf->vlan_limit);
+ }
+ vf_group_end(printed);
+
+ printed = false;
+ if ((vf->attrs & SNL_VF_F_ALLOW_SET_MAC) != 0) {
+ vf_group_begin(&printed, "policy");
+ printf(" set-mac=%s", vf->allow_set_mac ?
+ "allowed" : "denied");
+ }
+ if ((vf->attrs & SNL_VF_F_ALLOW_SET_VLAN) != 0) {
+ vf_group_begin(&printed, "policy");
+ printf(" set-vlan=%s", vf->allow_set_vlan ?
+ "allowed" : "denied");
+ }
+ if ((vf->attrs & SNL_VF_F_MAC_ANTI_SPOOF) != 0) {
+ vf_group_begin(&printed, "policy");
+ printf(" anti-spoof=%s", vf->mac_anti_spoof ? "on" : "off");
+ }
+ if ((vf->attrs & SNL_VF_F_ALLOW_PROMISC) != 0) {
+ vf_group_begin(&printed, "policy");
+ printf(" promisc=%s", vf->allow_promisc ?
+ "allowed" : "denied");
+ }
+ if ((vf->attrs & SNL_VF_F_LINK_STATE_POLICY) != 0) {
+ vf_group_begin(&printed, "policy");
+ printf(" link-state=%s",
+ vf_link_state_name(vf->link_state_policy));
+ }
+ vf_group_end(printed);
+
+ printed = false;
+ if ((vf->attrs & SNL_VF_F_API_VERSION) != 0) {
+ vf_group_begin(&printed, "protocol");
+ printf(" api=%s", vf->api_version);
+ }
+ vf_group_end(printed);
+
+ vf_driver_status(vf);
+ }
+}
Index: usr.sbin/iovctl/iovctl.8
===================================================================
--- usr.sbin/iovctl/iovctl.8
+++ usr.sbin/iovctl/iovctl.8
@@ -131,10 +131,18 @@
This action may be used to discover the configuration parameters supported on
a given PF device.
.El
+.Pp
+For network devices, use
+.Xr ifconfig 8
+with the
+.Fl v
+option on the PF interface to display NIC-specific VF initialization,
+resource, and policy state.
.Sh SEE ALSO
.Xr vmm 4 ,
.Xr iovctl.conf 5 ,
-.Xr rc.conf 5
+.Xr rc.conf 5 ,
+.Xr ifconfig 8
.Sh AUTHORS
This manual page was written by
.An Ryan Stone Aq Mt rstone@FreeBSD.org .
Index: usr.sbin/iovctl/iovctl.conf.5
===================================================================
--- usr.sbin/iovctl/iovctl.conf.5
+++ usr.sbin/iovctl/iovctl.conf.5
@@ -145,7 +145,14 @@
.Bd -literal -offset indent
iovctl -L -d ix0
.Ed
+For network devices, display NIC-specific initialization, resources, and
+policy state with:
+.Bd -literal -offset indent
+ifconfig -v ix0
+.Ed
See
+.Xr ifconfig 8
+and
.Xr iovctl 8
for the meaning of the reported fields.
.Sh EXAMPLES
@@ -174,6 +181,7 @@
.Ed
.Sh SEE ALSO
.Xr rc.conf 5 ,
+.Xr ifconfig 8 ,
.Xr iovctl 8
.Sh AUTHORS
This manual page was written by
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Sep 9, 4:12 PM (4 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38597671
Default Alt Text
D58778.id183846.diff (12 KB)
Attached To
Mode
D58778: ifconfig: Add SR-IOV VF status output
Attached
Detach File
Event Timeline
Log In to Comment