15
15
virt_vm ,
16
16
)
17
17
18
- from provider import netperf_base , win_driver_utils
18
+ from provider import netperf_base , vdpa_utils , win_driver_utils
19
19
20
20
LOG_JOB = logging .getLogger ("avocado.test" )
21
21
@@ -62,6 +62,7 @@ def mtu_set(mtu):
62
62
server_mtu_cmd = params .get ("server_mtu_cmd" )
63
63
client_mtu_cmd = params .get ("client_mtu_cmd" )
64
64
host_mtu_cmd = params .get ("host_mtu_cmd" )
65
+ client_physical_nic = params .get ("client_physical_nic" )
65
66
error_context .context ("Changing the MTU of guest" , test .log .info )
66
67
if params .get ("os_type" ) == "linux" :
67
68
ethname = utils_net .get_linux_ifname (server_ctl , mac )
@@ -73,9 +74,8 @@ def mtu_set(mtu):
73
74
netperf_base .ssh_cmd (server_ctl , server_mtu_cmd % (connection_id , mtu ))
74
75
75
76
error_context .context ("Changing the MTU of client" , test .log .info )
76
- netperf_base .ssh_cmd (
77
- client , client_mtu_cmd % (params .get ("client_physical_nic" ), mtu )
78
- )
77
+ if client_physical_nic :
78
+ netperf_base .ssh_cmd (client , client_mtu_cmd % (client_physical_nic , mtu ))
79
79
80
80
netdst = params .get ("netdst" , "switch" )
81
81
host_bridges = utils_net .Bridge ()
@@ -84,52 +84,13 @@ def mtu_set(mtu):
84
84
if netdst in br_in_use :
85
85
ifaces_in_use = host_bridges .list_iface ()
86
86
target_ifaces = list (ifaces_in_use + br_in_use )
87
- if (
88
- process .system (
89
- "which ovs-vsctl && systemctl status openvswitch.service" ,
90
- ignore_status = True ,
91
- shell = True ,
92
- )
93
- == 0
94
- ):
95
- ovs_br_all = netperf_base .ssh_cmd (host , "ovs-vsctl list-br" )
96
- ovs_br = []
97
- if ovs_br_all :
98
- for nic in vm .virtnet :
99
- if nic .netdst in ovs_br_all :
100
- ovs_br .append (nic .netdst )
101
- elif nic .nettype == "vdpa" :
102
- vf_pci = netperf_base .ssh_cmd (
103
- host ,
104
- "vdpa dev show |grep %s | grep -o 'pci/[^[:space:]]*' | "
105
- "awk -F/ '{print $2}'" % nic .netdst ,
106
- )
107
- pf_pci = netperf_base .ssh_cmd (
108
- host ,
109
- "grep PCI_SLOT_NAME /sys/bus/pci/devices/%s/physfn/uevent |"
110
- " cut -d'=' -f2" % vf_pci ,
111
- )
112
- port = netperf_base .ssh_cmd (
113
- host , "ls /sys/bus/pci/devices/%s/net/ | head -n 1" % pf_pci
114
- )
115
- ovs_br_vdpa = netperf_base .ssh_cmd (
116
- host , "ovs-vsctl port-to-br %s" % port
117
- )
118
- cmd = (
119
- f"ovs-ofctl add-flow { ovs_br_vdpa } '"
120
- "in_port=1,idle_timeout=0 actions=output:2'"
121
- )
122
- cmd += (
123
- f"&& ovs-ofctl add-flow { ovs_br_vdpa } '"
124
- "in_port=2,idle_timeout=0 actions=output:1'"
125
- )
126
- cmd += "&& ovs-ofctl dump-flows {}" .format (ovs_br_vdpa )
127
- netperf_base .ssh_cmd (host , cmd )
128
- ovs_br .append (ovs_br_vdpa )
129
- for br in ovs_br :
130
- ovs_list = "ovs-vsctl list-ports %s" % br
131
- ovs_port = netperf_base .ssh_cmd (host , ovs_list )
132
- target_ifaces .extend (ovs_port .split () + [br ])
87
+
88
+ add_flows = params .get ("vdpa_ovs_add_flows" , "yes" ) == "yes"
89
+ ovs_handler = vdpa_utils .OVSHandler (vm )
90
+ target_ifaces .extend (
91
+ ovs_handler .get_vdpa_ovs_info (add_flows = add_flows , return_ports = True )
92
+ )
93
+
133
94
if vm .virtnet [0 ].nettype == "macvtap" :
134
95
target_ifaces .extend ([vm .virtnet [0 ].netdst , vm .get_ifname (0 )])
135
96
error_context .context ("Change all Bridge NICs MTU to %s" % mtu , test .log .info )
@@ -339,6 +300,7 @@ def mtu_set(mtu):
339
300
client = params .get ("client" , "localhost" )
340
301
client_ip = client
341
302
clients = []
303
+ client_pub_ip = None
342
304
# client session 1 for control, session 2 for data communication
343
305
for i in range (2 ):
344
306
if client in params .get ("vms" ):
0 commit comments