Skip to contentSkip to conversation

ip: add support for queue attributes

RFC PATCH In review John Fastabend 2 participants 2 messages Jul 10, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ip: add support for queue attributes

Test patch to demonstrat and test queue attributes. The 'show' formatting could likely be improved.

# ./ip/ip link set dev p3p2 queue 1 rate 1000
# ./ip/ip link set dev p3p2 queue 5 rate 1000
# ./ip/ip link show dev p3p2
4: p3p2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
    link/ether 00:1b:21:69:9f:09 brd ff:ff:ff:ff:ff:ff queues:  (1: rate 1000Mbps) (5: rate 1000Mbps)
---
 include/linux/if_link.h |   24 +++++++++++++++++++++
 ip/ipaddress.c          |   26 +++++++++++++++++++++++
 ip/iplink.c             |   54 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)
include/linux/if_link.h +24 -0
index 965dc9f..dcb2cea 100644
@@ -143,6 +143,7 @@ enum {
 	IFLA_NUM_TX_QUEUES,
 	IFLA_NUM_RX_QUEUES,
 	IFLA_CARRIER,
+	IFLA_QUEUE_ATTRIBS,
 	__IFLA_MAX
 };
 
@@ -432,6 +433,29 @@ struct ifla_port_vsi {
 	__u8 pad[3];
 };
 
+/* Queue Attributes management
+ *	Netsted layout of queue attributes is:
+ *	[IFLA_QUEUE_ATTRIBS]
+ *		[IFLA_QUEUE_ATTRIB]
+ *			[IFLA_QUEUE_INDEX]	<required>
+ *			[IFLA_QUEUE_RATE]	<optional>
+ *		[IFLA_QUEUE_ATTRIB]
+ *			[...]
+ */
+enum {
+	IFLA_QUEUE_ATTRIB_UNSPEC,
+	IFLA_QUEUE_ATTRIB,			/* nest */
+	__IFLA_QUEUE_ATTRIB_MAX,
+};
+#define IFLA_QUEUE_ATTRIB_MAX (__IFLA_QUEUE_ATTRIB_MAX - 1)
+
+enum {
+	IFLA_QUEUE_UNSPEC,
+	IFLA_QUEUE_INDEX,		/* __u32 */
+	IFLA_QUEUE_RATE,		/* __u32 */
+	__IFLA_QUEUE_MAX,
+};
+#define IFLA_QUEUE_MAX (__IFLA_QUEUE_MAX - 1)
 
 /* IPoIB section */
 
ip/ipaddress.c +26 -0
index 5b9a438..5e55798 100644
@@ -272,6 +272,23 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
 	}
 }
 
+static void print_queue_attribs(FILE *fp, struct rtattr *queue)
+{
+	struct rtattr *q[IFLA_QUEUE_MAX+1];
+
+	parse_rtattr_nested(q, IFLA_QUEUE_MAX, queue);
+
+	if (q[IFLA_QUEUE_INDEX]) {
+		int index = *(int *) RTA_DATA(q[IFLA_QUEUE_INDEX]);
+		int rate = 0;
+
+		if (q[IFLA_QUEUE_RATE])
+			rate = *(int *) RTA_DATA(q[IFLA_QUEUE_RATE]);
+
+		fprintf(fp, " (%u: rate %uMbps)", index, rate);
+	}
+}
+
 static void print_link_stats64(FILE *fp, const struct rtnl_link_stats64 *s) {
 	fprintf(fp, "%s", _SL_);
 	fprintf(fp, "    RX: bytes  packets  errors  dropped overrun mcast   %s%s",
@@ -487,6 +504,15 @@ int print_linkinfo(const struct sockaddr_nl *who,
 			print_vfinfo(fp, i);
 	}
 
+	if (do_link && tb[IFLA_QUEUE_ATTRIBS]) {
+		struct rtattr *i, *queue_attribs = tb[IFLA_QUEUE_ATTRIBS];
+		int rem = RTA_PAYLOAD(queue_attribs);
+
+		fprintf(fp, " queues: ");
+		for (i = RTA_DATA(queue_attribs); RTA_OK(i, rem); i = RTA_NEXT(i, rem))
+			print_queue_attribs(fp, i);
+	}
+
 	fprintf(fp, "\n");
 	fflush(fp);
 	return 0;
ip/iplink.c +54 -0

72 lines not on this page · raw message

#1 lore raw
Quoted 12 lines · John Fastabend

Test patch to demonstrat and test queue attributes. The 'show' formatting could likely be improved.

# ./ip/ip link set dev p3p2 queue 1 rate 1000
# ./ip/ip link set dev p3p2 queue 5 rate 1000
# ./ip/ip link show dev p3p2
4: p3p2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT qlen 1000
     link/ether 00:1b:21:69:9f:09 brd ff:ff:ff:ff:ff:ff queues:  (1: rate 1000Mbps) (5: rate 1000Mbps)

---

Oops sorry, demonstrat should be demonstrate and the title should be 'iproute2' to avoid confusion. Hopefully the context is at least clear from the patch description.

.John