[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1572551722-9520-3-git-send-email-lariel@mellanox.com>
Date: Thu, 31 Oct 2019 19:55:33 +0000
From: Ariel Levkovich <lariel@...lanox.com>
To: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC: Jiri Pirko <jiri@...lanox.com>,
"stephen@...workplumber.org" <stephen@...workplumber.org>,
Ariel Levkovich <lariel@...lanox.com>
Subject: [PATCH iproute2-next v2 2/3] ip: Present the VF VLAN tagging mode
The change prints the VLAN tagging mode per VF on
link query.
The possible modes are:
1) VGT - Virtual Guest tagging mode.
2) VST - Virtual Switch tagging mode.
3) Trunk - Guest tagging mode with specific allowed VLAN access list.
For the full VLAN ids list in Trunk mode, it is required to
query the specific VF.
Signed-off-by: Ariel Levkovich <lariel@...lanox.com>
---
include/uapi/linux/if_link.h | 14 ++++++++++++++
ip/ipaddress.c | 18 +++++++++++++++++-
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index d39017b..6304add 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -697,6 +697,7 @@ enum {
IFLA_VF_IB_PORT_GUID, /* VF Infiniband port GUID */
IFLA_VF_VLAN_LIST, /* nested list of vlans, option for QinQ */
IFLA_VF_BROADCAST, /* VF broadcast */
+ IFLA_VF_VLAN_MODE, /* vlan tagging mode */
__IFLA_VF_MAX,
};
@@ -711,6 +712,19 @@ struct ifla_vf_broadcast {
__u8 broadcast[32];
};
+enum {
+ IFLA_VF_VLAN_MODE_UNSPEC,
+ IFLA_VF_VLAN_MODE_VGT,
+ IFLA_VF_VLAN_MODE_VST,
+ IFLA_VF_VLAN_MODE_TRUNK,
+ __IFLA_VF_VLAN_MODE_MAX,
+};
+
+struct ifla_vf_vlan_mode {
+ __u32 vf;
+ __u32 mode; /* The VLAN tagging mode */
+};
+
struct ifla_vf_vlan {
__u32 vf;
__u32 vlan; /* 0 - 4095, 0 disables VLAN filter */
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 0521fdc..9c04cee 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -351,13 +351,19 @@ static void print_af_spec(FILE *fp, struct rtattr *af_spec_attr)
static void print_vf_stats64(FILE *fp, struct rtattr *vfstats);
+static const char *vlan_modes[] = {
+ [IFLA_VF_VLAN_MODE_UNSPEC] = "n/a",
+ [IFLA_VF_VLAN_MODE_VGT] = "vgt",
+ [IFLA_VF_VLAN_MODE_VST] = "vst",
+ [IFLA_VF_VLAN_MODE_TRUNK] = "trunk",
+};
+
static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
{
struct ifla_vf_mac *vf_mac;
struct ifla_vf_broadcast *vf_broadcast;
struct ifla_vf_tx_rate *vf_tx_rate;
struct rtattr *vf[IFLA_VF_MAX + 1] = {};
-
SPRINT_BUF(b1);
if (vfinfo->rta_type != IFLA_VF_INFO) {
@@ -404,6 +410,16 @@ static void print_vfinfo(FILE *fp, struct ifinfomsg *ifi, struct rtattr *vfinfo)
b1, sizeof(b1)));
}
+ if (vf[IFLA_VF_VLAN_MODE]) {
+ struct ifla_vf_vlan_mode *vlan_mode = RTA_DATA(vf[IFLA_VF_VLAN_MODE]);
+
+ if (vlan_mode->mode >= ARRAY_SIZE(vlan_modes))
+ print_int(PRINT_ANY, "vlan_mode", ", vlan_mode %d ", vlan_mode->mode);
+ else
+ print_string(PRINT_ANY, "vlan_mode", ", vlan_mode %s",
+ vlan_modes[vlan_mode->mode]);
+ }
+
if (vf[IFLA_VF_VLAN_LIST]) {
struct rtattr *i, *vfvlanlist = vf[IFLA_VF_VLAN_LIST];
int rem = RTA_PAYLOAD(vfvlanlist);
--
1.8.3.1
Powered by blists - more mailing lists