All of lore.kernel.org
 help / color / mirror / Atom feed
* [iproute2 PATCH v2 1/4] if_link: Sync if_link header with kernel to get new VF configuration defines
@ 2010-02-10 11:46 Jeff Kirsher
  2010-02-10 11:46 ` [iproute2 PATCH v2 2/4] libnetlink: Modify the parser to track first duplicated attributes Jeff Kirsher
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jeff Kirsher @ 2010-02-10 11:46 UTC (permalink / raw)
  To: davem, shemminger; +Cc: netdev, gospo, Mitch Williams, Jeff Kirsher

From: Williams, Mitch A <mitch.a.williams@intel.com>

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 include/linux/if_link.h |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index cbefb3b..014ca50 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -78,6 +78,11 @@ enum {
 #define IFLA_LINKINFO IFLA_LINKINFO
 	IFLA_NET_NS_PID,
 	IFLA_IFALIAS,
+	IFLA_NUM_VF,		/* Number of VFs if device is SR-IOV PF */
+	IFLA_VF_MAC,		/* Hardware queue specific attributes */
+	IFLA_VF_VLAN,
+	IFLA_VF_TX_RATE,	/* TX Bandwidth Allocation */
+	IFLA_VFINFO,
 	__IFLA_MAX
 };
 
@@ -194,4 +199,33 @@ enum macvlan_mode {
 	MACVLAN_MODE_BRIDGE  = 4, /* talk to bridge ports directly */
 };
 
+/* subqueue managment section */
+
+struct ifla_vf_mac
+{
+	__u32 vf;
+	__u8 mac[32]; /* MAX_ADDR_LEN */
+};
+
+struct ifla_vf_vlan
+{
+	__u32 vf;
+	__u32 vlan; /* 0 - 4095, 0 disables VLAN filter */
+	__u32 qos;
+};
+
+struct ifla_vf_tx_rate
+{
+	__u32 vf;
+	__u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */
+};
+
+struct ifla_vf_info
+{
+	__u32 vf;
+	__u8 mac[32];
+	__u32 vlan;
+	__u32 qos;
+	__u32 tx_rate;
+};
 #endif /* _LINUX_IF_LINK_H */


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [iproute2 PATCH v2 2/4] libnetlink: Modify the parser to track first duplicated attributes
  2010-02-10 11:46 [iproute2 PATCH v2 1/4] if_link: Sync if_link header with kernel to get new VF configuration defines Jeff Kirsher
@ 2010-02-10 11:46 ` Jeff Kirsher
  2010-02-10 11:47 ` [iproute2 PATCH v2 3/4] ip: Add support for setting and showing SR-IOV virtual funtion link params Jeff Kirsher
  2010-02-10 11:47 ` [iproute2 PATCH v2 4/4] Update man page to indicate current options Jeff Kirsher
  2 siblings, 0 replies; 5+ messages in thread
From: Jeff Kirsher @ 2010-02-10 11:46 UTC (permalink / raw)
  To: davem, shemminger; +Cc: netdev, gospo, Mitch Williams, Jeff Kirsher

From: Williams, Mitch A <mitch.a.williams@intel.com>

Modify the parser to keep track of the first of any duplicated attributes,
instead of the last. This is required for VF configuration reporting, where
multiple attributes of the same type are added sequentially.

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 lib/libnetlink.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 4ba6019..cfeb894 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -644,7 +644,7 @@ int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len)
 {
 	memset(tb, 0, sizeof(struct rtattr *) * (max + 1));
 	while (RTA_OK(rta, len)) {
-		if (rta->rta_type <= max)
+		if ((rta->rta_type <= max) && (!tb[rta->rta_type]))
 			tb[rta->rta_type] = rta;
 		rta = RTA_NEXT(rta,len);
 	}


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [iproute2 PATCH v2 3/4] ip: Add support for setting and showing SR-IOV virtual funtion link params
  2010-02-10 11:46 [iproute2 PATCH v2 1/4] if_link: Sync if_link header with kernel to get new VF configuration defines Jeff Kirsher
  2010-02-10 11:46 ` [iproute2 PATCH v2 2/4] libnetlink: Modify the parser to track first duplicated attributes Jeff Kirsher
@ 2010-02-10 11:47 ` Jeff Kirsher
  2010-03-04  0:34   ` Stephen Hemminger
  2010-02-10 11:47 ` [iproute2 PATCH v2 4/4] Update man page to indicate current options Jeff Kirsher
  2 siblings, 1 reply; 5+ messages in thread
From: Jeff Kirsher @ 2010-02-10 11:47 UTC (permalink / raw)
  To: davem, shemminger; +Cc: netdev, gospo, Mitch Williams, Jeff Kirsher

From: Williams, Mitch A <mitch.a.williams@intel.com>

Add support to 'ip' for setting and showing SR-IOV virtual function
link parameters.

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 ip/ipaddress.c |   25 +++++++++++++++++++++++++
 ip/iplink.c    |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index e9256d9..3186f9c 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -331,6 +331,31 @@ int print_linkinfo(const struct sockaddr_nl *who,
 				);
 		}
 	}
+	if (do_link && tb[IFLA_VFINFO] && tb[IFLA_NUM_VF]) {
+		SPRINT_BUF(b1);
+		struct rtattr *rta = tb[IFLA_VFINFO];
+		struct ifla_vf_info *ivi;
+		int i;
+		for (i = 0; i < *(int *)RTA_DATA(tb[IFLA_NUM_VF]); i++) {
+			if (rta->rta_type != IFLA_VFINFO) {
+				fprintf(stderr, "BUG: rta type is %d\n", rta->rta_type);
+				break;
+			}
+			ivi = RTA_DATA(rta);
+			fprintf(fp, "\n    vf %d: MAC %s",
+				ivi->vf,
+				ll_addr_n2a((unsigned char *)&ivi->mac,
+					    ETH_ALEN, 0, b1, sizeof(b1)));
+				if (ivi->vlan)
+					fprintf(fp, ", vlan %d", ivi->vlan);
+				if (ivi->qos)
+					fprintf(fp, ", qos %d", ivi->qos);
+				if (ivi->tx_rate)
+					fprintf(fp, ", tx rate %d (Mbps_",
+						ivi->tx_rate);
+			rta = (struct rtattr *)((char *)rta + RTA_ALIGN(rta->rta_len));
+		}
+	}
 	fprintf(fp, "\n");
 	fflush(fp);
 	return 0;
diff --git a/ip/iplink.c b/ip/iplink.c
index 32cce24..97fca8b 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -68,6 +68,9 @@ void iplink_usage(void)
 	fprintf(stderr, "	                  [ mtu MTU ]\n");
 	fprintf(stderr, "	                  [ netns PID ]\n");
 	fprintf(stderr, "			  [ alias NAME ]\n");
+	fprintf(stderr, "	                  [ vf NUM [ mac LLADDR ]\n");
+	fprintf(stderr, "				   [ vlan VLANID [ qos VLAN-QOS ] ]\n");
+	fprintf(stderr, "				   [ rate TXRATE ] ] \n");
 	fprintf(stderr, "       ip link show [ DEVICE ]\n");
 
 	if (iplink_have_newlink()) {
@@ -181,6 +184,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 	int qlen = -1;
 	int mtu = -1;
 	int netns = -1;
+	int vf = -1;
 
 	ret = argc;
 
@@ -278,6 +282,54 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req,
 				req->i.ifi_flags |= IFF_NOARP;
 			} else
 				return on_off("noarp");
+		} else if (strcmp(*argv, "vf") == 0) {
+			NEXT_ARG();
+			if (get_integer(&vf,  *argv, 0)) {
+				invarg("Invalid \"vf\" value\n", *argv);
+			}
+		} else if (matches(*argv, "mac") == 0) {
+			struct ifla_vf_mac ivm;
+			NEXT_ARG();
+			if (vf < 0) {
+				missarg("vf");
+			}
+			ivm.vf = vf;
+			len = ll_addr_a2n((char *)ivm.mac, 32, *argv);
+			if (len < 0)
+				return -1;
+			addattr_l(&req->n, sizeof(*req), IFLA_VF_MAC, &ivm, sizeof(ivm));
+		} else if (matches(*argv, "vlan") == 0) {
+			struct ifla_vf_vlan ivv;
+			NEXT_ARG();
+			if (vf < 0) {
+				missarg("vf");
+			}
+			if (get_unsigned(&ivv.vlan, *argv, 0)) {
+				invarg("Invalid \"vlan\" value\n", *argv);
+			}
+			ivv.vf = vf;
+			ivv.qos = 0;
+			if (NEXT_ARG_OK()) {
+				NEXT_ARG();
+				if (matches(*argv, "qos") == 0) {
+					NEXT_ARG();
+					if (get_unsigned(&ivv.qos, *argv, 0)) {
+						invarg("Invalid \"qos\" value\n", *argv);
+					}
+				}
+			}
+			addattr_l(&req->n, sizeof(*req), IFLA_VF_VLAN, &ivv, sizeof(ivv));
+		} else if (matches(*argv, "rate") == 0) {
+			struct ifla_vf_tx_rate ivt;
+			NEXT_ARG();
+			if (vf < 0) {
+				missarg("vf");
+			}
+			if (get_unsigned(&ivt.rate, *argv, 0)) {
+				invarg("Invalid \"rate\" value\n", *argv);
+			}
+			ivt.vf = vf;
+			addattr_l(&req->n, sizeof(*req), IFLA_VF_TX_RATE, &ivt, sizeof(ivt));
 #ifdef IFF_DYNAMIC
 		} else if (matches(*argv, "dynamic") == 0) {
 			NEXT_ARG();


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [iproute2 PATCH v2 4/4] Update man page to indicate current options
  2010-02-10 11:46 [iproute2 PATCH v2 1/4] if_link: Sync if_link header with kernel to get new VF configuration defines Jeff Kirsher
  2010-02-10 11:46 ` [iproute2 PATCH v2 2/4] libnetlink: Modify the parser to track first duplicated attributes Jeff Kirsher
  2010-02-10 11:47 ` [iproute2 PATCH v2 3/4] ip: Add support for setting and showing SR-IOV virtual funtion link params Jeff Kirsher
@ 2010-02-10 11:47 ` Jeff Kirsher
  2 siblings, 0 replies; 5+ messages in thread
From: Jeff Kirsher @ 2010-02-10 11:47 UTC (permalink / raw)
  To: davem, shemminger; +Cc: netdev, gospo, Mitch Williams, Jeff Kirsher

From: Williams, Mitch A <mitch.a.williams@intel.com>

Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 man/man8/ip.8 |   73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 70 insertions(+), 3 deletions(-)

diff --git a/man/man8/ip.8 b/man/man8/ip.8
index ccc800f..3efa045 100644
--- a/man/man8/ip.8
+++ b/man/man8/ip.8
@@ -53,7 +53,23 @@ ip \- show / manipulate routing, devices, policy routing and tunnels
 .IR MTU " |"
 .br
 .B  netns
-.IR PID " }"
+.IR PID " |"
+.br
+.B alias
+.IR NAME  " |"
+.br
+.B vf
+.IR NUM " ["
+.B  mac
+.IR LLADDR " ] ["
+.B vlan
+.IR VLANID " [ "
+.B qos
+.IR VLAN-QOS " ] ] ["
+.B rate
+.IR TXRATE " ]"
+.BR " }"
+
 
 .ti -8
 .B ip link show
@@ -822,7 +838,9 @@ display and change the state of devices.
 .TP
 .BI dev " NAME " (default)
 .I NAME
-specifies network device to operate on.
+specifies network device to operate on. When configuring SR-IOV Virtual Fuction
+(VF) devices, this keyword should specify the associated Physical Function (PF)
+device.
 
 .TP
 .BR up " and " down
@@ -884,7 +902,56 @@ the interface is
 .TP
 .BI netns " PID"
 move the device to the network namespace associated with the process
-.IR "PID" .
+.IR "PID".
+
+.TP
+.BI alias " NAME"
+give the device a symbolic name for easy reference.
+
+.TP
+.BI vf " NUM"
+specify a Virtual Function device to be configured. The associated PF device
+must be specified using the
+.B dev
+parameter.
+
+.in +8
+.BI mac " LLADDRESS"
+- change the station address for the specified VF. The
+.B vf
+parameter must be specified.
+
+.sp
+.BI vlan " VLANID"
+- change the assigned VLAN for the specified VF. When specified, all traffic
+sent from the VF will be tagged with the specified VLAN ID. Incoming traffic
+will be filtered for the specified VLAN ID, and will have all VLAN tags
+stripped before being passed to the VF. Setting this parameter to 0 disables
+VLAN tagging and filtering. The
+.B vf
+parameter must be specified.
+
+.sp
+.BI qos " VLAN-QOS"
+- assign VLAN QOS (priority) bits for the VLAN tag. When specified, all VLAN
+tags transmitted by the VF will include the specified priority bits in the
+VLAN tag. If not specified, the value is assumed to be 0. Both the
+.B vf
+and
+.B vlan
+parameters must be specified. Setting both
+.B vlan
+and
+.B qos
+as 0 disables VLAN tagging and filtering for the VF.
+
+.sp
+.BI rate " TXRATE"
+- change the allowed transmit bandwidth, in Mbps, for the specified VF.
+Setting this parameter to 0 disables rate limiting. The
+.B vf
+parameter must be specified.
+.in -8
 
 .PP
 .B Warning:


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [iproute2 PATCH v2 3/4] ip: Add support for setting and showing SR-IOV virtual funtion link params
  2010-02-10 11:47 ` [iproute2 PATCH v2 3/4] ip: Add support for setting and showing SR-IOV virtual funtion link params Jeff Kirsher
@ 2010-03-04  0:34   ` Stephen Hemminger
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2010-03-04  0:34 UTC (permalink / raw)
  To: Jeff Kirsher; +Cc: davem, netdev, gospo, Mitch Williams

On Wed, 10 Feb 2010 03:47:08 -0800
Jeff Kirsher <jeffrey.t.kirsher@intel.com> wrote:

> From: Williams, Mitch A <mitch.a.williams@intel.com>
> 
> Add support to 'ip' for setting and showing SR-IOV virtual function
> link parameters.
> 
> Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-03-04  0:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-10 11:46 [iproute2 PATCH v2 1/4] if_link: Sync if_link header with kernel to get new VF configuration defines Jeff Kirsher
2010-02-10 11:46 ` [iproute2 PATCH v2 2/4] libnetlink: Modify the parser to track first duplicated attributes Jeff Kirsher
2010-02-10 11:47 ` [iproute2 PATCH v2 3/4] ip: Add support for setting and showing SR-IOV virtual funtion link params Jeff Kirsher
2010-03-04  0:34   ` Stephen Hemminger
2010-02-10 11:47 ` [iproute2 PATCH v2 4/4] Update man page to indicate current options Jeff Kirsher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.