iproute: Sync if_link header with kernel to get new VF configuration defines
Subsystems (3)
RFC PATCH 1/3 iproute: Sync if_link header with kernel to get new VF configuration defines
From: Williams, Mitch A <[email protected]>
Signed-off-by Mitch Williams <[email protected]>
Signed-off-by Jeff Kirsher <[email protected]>
---
include/linux/if_link.h | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-)
include/linux/if_link.h +32 -0
@@ -81,6 +81,11 @@ enum#define IFLA_LINKINFO IFLA_LINKINFOIFLA_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 };
@@ -188,4 +193,31 @@ struct ifla_vlan_qos_mapping __u32 to; }; +/* subqueue managment section */ + +struct ifla_vf_mac +{ +__u32 vf; +__u8 mac[32 ];/* MAX_ADDR_LEN */ +}; + +struct ifla_vf_vlan +{ +__u32 vf; +__s32 vlan;/* 0 - 4095, -1 disables VLAN filter */ +}; + +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 ]; +__s32 vlan; +__u32 tx_rate; +};#endif /* _LINUX_IF_LINK_H */
RFC PATCH 2/3 iproute: Modify the parser's handling duplicated attributes
From: Williams, Mitch A <[email protected]>
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 <[email protected]>
Signed-off-by Jeff Kirsher <[email protected]>
---
lib/libnetlink.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
lib/libnetlink.c +1 -1
@@ -628,7 +628,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); }
RFC PATCH 3/3 iproute: Add support to 'ip' for SR-IOV virtual function link paramters
In reply to Jeff KirsherFrom: Williams, Mitch A <[email protected]>
Adds support for setting and showing SR-IOV virtual function link parameters.
Signed-off-by Mitch Williams <[email protected]>
Signed-off-by Jeff Kirsher <[email protected]>
---
ip/ipaddress.c | 23 +++++++++++++++++++++++ ip/iplink.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 0 deletions(-)
ip/ipaddress.c +23 -0
@@ -330,6 +330,29 @@ 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->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 ;
ip/iplink.c +39 -0
@@ -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 ] ] \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,41 @@ 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_integer (&ivv.vlan, *argv,0 )) { +invarg ("Invalid \"vlan\" value\n" , *argv); + } + ivv.vf = vf; +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 ();