???????????????????????????? ??????????????/????????????????? ............/............... .........................../... ????????????????????????????? >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>> ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ???????????????????????????? ??????????????/????????????????? ............/............... .........................../... ????????????????????????????? >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>> ÿØÿà JFIF    ÿÛ „  ( %!1!%)+//.383,7(-.+  -%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ     ÿÄ J    ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ   ÿÄ *  !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú "SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5 ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍѶ¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e ríV ?> ......................................... ............................................................................. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>/>>>>>>>>>>>>>>>>>> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Z9 gRddlZddlZddlZddlZddlZddlmZmZmZmZddl m Z ddl m Z ddl Z GddeZd ej efd Zd ej ed ej efd Zd e j&ded efdZd e j&d eefdZdZde j2d eeeffdZde j2d eeeffdZde j2d eefdZdZdZddZ ddZ!y)N)DictListOptionalSet)utils)ConfigurationErrorceZdZdZdefdZedefdZedefdZdedefdZ edefd Z ede fd Z ede fd Z ede fd Zedefd ZedefdZdededefdZdefdZdefdZy) PCIDevicez.Helper class for interaction with a PCI devicepci_addrc||_y)znInitialise a new PCI device handler :param pci_addr: PCI address of device :type: str Nr )selfr s +/usr/share/netplan/netplan_cli/cli/sriov.py__init__zPCIDevice.__init__%s ! returncy)zusysfs path (can be overridden for testing) :return: full path to /sys filesystem :rtype: str z/sysrs rsysz PCIDevice.sys,s rcltjj|jd|jS)zq/sys path for PCI device :return: full path to PCI device in /sys filesystem :rtype: str zbus/pci/devices)ospathjoinrr rs rrzPCIDevice.path4s$ ww||DHH&7GGrsubpathcVtjj|j|S)z/sys subpath helper for PCI device :param subpath: subpath to construct path for :type: str :return: self.path + subpath :rtype: str )rrr)rrs rrzPCIDevice.subpath<sww||DIIw//rcd}tjj|jdrAtjj tj |jd}|S)zjKernel driver for PCI device :return: kernel driver in use for device :rtype: str driver)rrexistsrbasenamereadlink)rr!s rr!zPCIDevice.driverEsM  77>>$,,x0 1WW%%bkk$,,x2H&IJF rc^tjj|jdS)zDetermine if device is bound to a kernel driver :return: whether device is bound to a kernel driver :rtype: bool r!rrr"rrs rboundzPCIDevice.boundP ww~~dll8455rc^tjj|jdS)zwDetermine if device is a SR-IOV Physical Function :return: whether device is a PF :rtype: bool sriov_numvfsr&rs ris_pfzPCIDevice.is_pfXs ww~~dll>:;;rc^tjj|jdS)zvDetermine if device is a SR-IOV Virtual Function :return: whether device is a VF :rtype: bool physfnr&rs ris_vfzPCIDevice.is_vf`r(rc g}d} |jtjjtj|j dj ||dz }f#t$rY|SwxYw)zList Virtual Function addresses associated with a Physical Function :return: List of PCI addresses of Virtual Functions :rtype: list[str] rzvirtfn{}r)appendrrr#r$rformatFileNotFoundError)rvf_addrsis rr3zPCIDevice.vf_addrshs}   GG$$ DLL1B1B11E$FG FA%  sAA,, A98A9cR|jDcgc] }t|c}Scc}w)zList Virtual Function associated with a Physical Function :return: List of PCI devices of Virtual Functions :rtype: list[PCIDevice] )r3r )raddrs rvfsz PCIDevice.vfs|s -1MM:D $:::s$obj_namepropvaluec ntjdd|ddj|j||gy)zSet devlink options for the PCI device :param obj_name: devlink object to set options on :type: str :param prop: property to set :type: str :param value: value to set for property :type: str /sbin/devlinkdevsetzpci/{}N) subprocess check_callr1r )rr8r9r:s r devlink_setzPCIDevice.devlink_sets9  .  rc8d|j} tjddddd|gtj}t j |}|jdij|ijd dS#tj$rYywxYw) zQuery eswitch mode via devlink for the PCI device :return: the eswitch mode or '__undetermined' if it can't be retrieved :rtype: str zpci/r<z-jr=eswitchshow)stderr__undeterminedmode)r r? check_outputDEVNULLCalledProcessErrorjsonloadsget)rpcioutput json_outputs rdevlink_eswitch_modezPCIDevice.devlink_eswitch_modes T]]O$ $,,# ")) Fjj( ub)--c26::6CSTT,, $# $s+BBBc|jS)zbString represenation of object :return: PCI address of string :rtype: str rrs r__str__zPCIDevice.__str__s }}rN)__name__ __module__ __qualname____doc__strrpropertyrrrr!boolr'r+r.listr3r7rArQrSrrrr r "s38!!SHcHH0s0s06t66rrlenr idaddr[)ri interfacesrvmatchesrjs r_get_interface_name_for_netdefr|s "002J  J.O #G( ' )&)<w BB BBBB C(CCnp_stateci}|jjD]}|jjdx}r+t ||j x}s;|||j <K|j rt |x}r|||j < |j}|dkDst |x}s|||j <|S#tj$r}tt|d}~wwxYw)z Go through the list of netplan ethernet devices and identify which are PFs matching them with actual network interfaces. sriovNr) ethernetsvalueslinksrMr|rx_embedded_switch_mode _vf_countnetplanNetplanExceptionr rX)rpfsrilinkifacecountrs r_get_physical_functionsrs C$$++-+<<##G, ,4 ,6x7HIIuI$DGG ++:6BB5B%*C N 1((qy:6BB5B%*C N'+* J ++ 1(Q00 1s CC0C++C0ci}|jjD](} |j}|dkDst|x}s$|||<*|S#tj$r}t t |d}~wwxYw)z Go through the list of netplan ethernet devices and identify which ones have VFs. netdef._vf_count ultimately calls _netplan_state_get_vf_count_for_def from libnetplan which return MAX(sriov_explicit_vf_count, number of VF netdefs). Nr)rrrrrr rXr|)r vf_countsrirrrs r_get_vf_number_per_pfr.s I$$++-) -$$E 196v>>u>#( % )  '' -$SV, , -s A  A6A11A6ct}|jjD]T}|jj dx}s!t ||j s:|j|j V|S)zk Go through the list of netplan ethernet devices and identify which ones are virtual functions r)r>rrrrMr|rxry)rr7rirs r_get_virtual_functionsrAsk %C$$++-#<<##G, ,4 ,-htww.?@ " # Jrc |dkDrtd|d|dtjjd|d}tjj|d}tjj|d} t |5}t |j j}d d d |kDrtd|d |d|d t |d5}|jt|d d d y#1swYTxYw#t$r}td |d t|d }~wt$rtd |zwxYw#1swYyxYw#t$r}d}|jdk(rtjd|z t |d5}|jdd d d n #1swYnxYwt |d5}|jt|d d d n #1swYnxYwd}n#t$r } | }Yd } ~ nd } ~ wwxYw|rtd|d|d t|Yd }~yd }~wwxYw)zB Allocate the required number of VFs for the selected PF. z cannot allocate more VFs for PF z than the SR-IOV maximum: z > 256r~devicer*sriov_totalvfsNz"failed parsing sriov_totalvfs for rz#invalid sriov_totalvfs value for %sz than supported: z > z (sriov_totalvfs)wTzLdevice or resource busy while setting sriov_numvfs for %s, trying workaround0Fzfailed setting sriov_numvfs to z for )r rrrr_intreadrrrrX ValueErrorr`errnologgingwarning) pfvf_countdevdir numvfs_path totalvfs_pathrcvf_maxrbaile_inners rset_numvfs_for_pfrOs%#~ VXZb ce eWW\\*B 9F'',,v~6KGGLL)9:MG -  +A)*F +& ]_aikq rt th +s # #q GGCM " #( A + + VSQRVTUU G@2EFFG #( % h 77b= OOjmoo p +s+!qGGCL!!!+s++qGGCM*+++    QY[]_bcd_efg g  %hs: D (D-D  EE 7ED D E D//E  EEE H?")H: G>F3* G>3F< 8G> G/& G>/G8 4G>;H:> HH H:H"H::H?c Ntjjd|d} ttjj|d5}|j j dd}dddttjj|d5}|j j dd}ddddjg}d }||vryy#1swYwxYw#1swY0xYw#t $r}td|dt|d}~wwxYw) z Perform any hardware-specific quirks for the given SR-IOV device to make sure all the VF-count changes are applied. r~rvendorr Nz,could not determine vendor and device ID of r:r) rrrr_rrrrrX)rrrc device_id vendor_idr combined_id quirk_devicess r perform_hardware_specific_quirksr~s WW\\*B 9F` "'',,vx0 1 -Q(,I - "'',,vx0 1 -Q(,I - ((Iy12KMm# $ - - - - `SUWZ[\W]^__`sG)C< "C$.1C<"C0C<$C-)C<0C95C<< D$DD$c d}tjj|d|d}tjjtj|}tjj|d|d}tj |D]e} d| vstjj|| } tjjtj| } | |k(s`| dd}n|st d|d| tjdd d d |d |d t|g tjtjy#tj$rt d|zwxYw)z@ Apply the hardware VLAN filtering for the selected VF. Nz sys/class/netrvirtfnz%could not determine the VF index for z while configuring vlan iprr>r=rbvlan)stdoutrEzJfailed setting SR-IOV VLAN filter for vlan %s (ip link set command failed)) rrrr#r$listdirrr?r@rXrIrJ) rrb vlan_namevlan_idprefixvf_index vf_devdir vf_dev_id pf_devdirrcdev_pathdev_ids rapply_vlan_filter_for_vfrsPH V_b(CI  Y!78I V_b(CI ZZ " q=ww||Iq1HWW%%bkk(&;vlans_has_sriov_vlan_filterrrM_vlan_idrxrry)config_managerrootdirrzrrvfs_setrvf_count_changedrrr7rbrirj netdef_idr eswitch_moder pcidevcurrent_eswitch_mode_systemrfiltered_vlans_setrrrs rapply_sriov_configrsz %%'J&&H &h/I%X.G !( +C %OO- (LB$R2  # #B '  ( # 1B ,R 0 1 ))+  C"    ( ( **i*@SySW01fik1kll'CG  ( ZB" IIK@ 5)$33 2 2)%0Hx(F*0*E*E*G '::<<MM"7">">vv"WXzzb&vzz6==AMM$?@[?\\`am`nntu~t#AB&&y&,Gzz%EE$VZZ?+@. ,,.' f  ( (<<##F+DooG!Beikokrkrsu 0334B''(dfhlhohoquvxx %RT7 ;  " "2 &9' )b#OO.CI;iX[\]X^W_,`aabs1 M N#$N  N)/)"rKrrr?typingrrrrr r configmanagerr robjectr Iterablerdrh NetDefinitionrXrZrrr|rStaterrrrrrrrrrrrs#&   ,,. YYx&//),FOOI.6??9;U=w44===!7+@+@!Xc]!HY"gmmS#X<GMMd38n& W]] s3x ,^ :$fNs'r