ip: add support for queue attributes
Subsystems (2)
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)Signed-off-by John Fastabend <[email protected]>
--- 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
@@ -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
@@ -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
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)Signed-off-by John Fastabend <[email protected]>---
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