netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net, shemminger@vyatta.com
Cc: netdev@vger.kernel.org, gospo@redhat.com,
	Mitch Williams <mitch.a.williams@intel.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [RFC PATCH iproute2] ip: Add support for setting MAC and VLAN on hardware queues
Date: Tue, 17 Nov 2009 13:55:07 -0800	[thread overview]
Message-ID: <20091117215432.15195.94504.stgit@localhost.localdomain> (raw)

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

This patch adds support to the "ip" tool for setting the MAC address and
VLAN filter for hardware device queues. This is most immediately useful for
SR-IOV; for VF devices to be usable in the real world, the hypervisor or VM
manager must be able to set these parameters before the VF device is
assigned to any VM.

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 |   16 ++++++++++++++++
 ip/iplink.c             |   29 +++++++++++++++++++++++++++--
 2 files changed, 43 insertions(+), 2 deletions(-)

diff --git a/include/linux/if_link.h b/include/linux/if_link.h
index b0b9e8a..a458d63 100644
--- a/include/linux/if_link.h
+++ b/include/linux/if_link.h
@@ -81,6 +81,8 @@ enum
 #define IFLA_LINKINFO IFLA_LINKINFO
 	IFLA_NET_NS_PID,
 	IFLA_IFALIAS,
+	IFLA_QUEUE_MAC,		/* Hardware queue specific attributes */
+	IFLA_QUEUE_VLAN,
 	__IFLA_MAX
 };
 
@@ -188,4 +190,18 @@ struct ifla_vlan_qos_mapping
 	__u32 to;
 };
 
+/* subqueue managment section */
+
+struct ifla_queue_mac
+{
+	__u32 queue;
+	__u8 mac[32]; /* MAX_ADDR_LEN */
+};
+
+struct ifla_queue_vlan
+{
+	__u32 queue;
+	__u32 vlan;
+};
+
 #endif /* _LINUX_IF_LINK_H */
diff --git a/ip/iplink.c b/ip/iplink.c
index 32cce24..9542d62 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -68,7 +68,9 @@ void iplink_usage(void)
 	fprintf(stderr, "	                  [ mtu MTU ]\n");
 	fprintf(stderr, "	                  [ netns PID ]\n");
 	fprintf(stderr, "			  [ alias NAME ]\n");
-	fprintf(stderr, "       ip link show [ DEVICE ]\n");
+	fprintf(stderr, "	                  [ queue NUM [ mac LLADDR ]\n");
+	fprintf(stderr, "				      [ vlan VLANID ] ] \n");
+	fprintf(stderr, "       ip link show [ DEVICE [ queue NUM] ]\n");
 
 	if (iplink_have_newlink()) {
 		fprintf(stderr, "\n");
@@ -176,7 +178,7 @@ struct iplink_req {
 int iplink_parse(int argc, char **argv, struct iplink_req *req,
 		char **name, char **type, char **link, char **dev)
 {
-	int ret, len;
+	int ret, len, qnum;
 	char abuf[32];
 	int qlen = -1;
 	int mtu = -1;
@@ -278,6 +280,29 @@ 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, "queue") == 0) {
+			NEXT_ARG();
+			if (get_integer(&qnum,  *argv, 0)) {
+				invarg("Invalid \"queue\" value\n", *argv);
+			}
+			NEXT_ARG();
+			if (matches(*argv, "mac") == 0) {
+				struct ifla_queue_mac iqm;
+				NEXT_ARG();
+				iqm.queue = qnum;
+				len = ll_addr_a2n((char *)iqm.mac, 32, *argv);
+				if (len < 0)
+					return -1;
+				addattr_l(&req->n, sizeof(*req), IFLA_QUEUE_MAC, &iqm, sizeof(iqm));
+			} else if (matches(*argv, "vlan") == 0) {
+				struct ifla_queue_vlan iqv;
+				NEXT_ARG();
+				if (get_unsigned(&iqv.vlan, *argv, 0)) {
+					invarg("Invalid \"vlan\" value\n", *argv);
+				}
+				iqv.queue = qnum;
+				addattr_l(&req->n, sizeof(*req), IFLA_QUEUE_VLAN, &iqv, sizeof(iqv));
+			}
 #ifdef IFF_DYNAMIC
 		} else if (matches(*argv, "dynamic") == 0) {
 			NEXT_ARG();


             reply	other threads:[~2009-11-17 21:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-17 21:55 Jeff Kirsher [this message]
2009-11-17 22:06 ` [RFC PATCH iproute2] ip: Add support for setting MAC and VLAN on hardware queues Stephen Hemminger
2009-11-18 18:07   ` David Miller
2009-11-18 19:15     ` Stephen Hemminger
2009-11-18 22:07       ` Williams, Mitch A

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091117215432.15195.94504.stgit@localhost.localdomain \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=davem@davemloft.net \
    --cc=gospo@redhat.com \
    --cc=mitch.a.williams@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).