blob: dfa9ab612f9ad8b118160a19b6a298cbfee6311b [file] [log] [blame]
Stevene8fa6202017-08-30 14:36:45 -07001from vpp_interface import VppInterface
2
3
4class VppVhostInterface(VppInterface):
5 """VPP vhost interface."""
6
Klement Sekerad9b0c6f2022-04-26 19:02:15 +02007 def __init__(
8 self,
9 test,
10 sock_filename,
11 is_server=0,
12 renumber=0,
13 disable_mrg_rxbuf=0,
14 disable_indirect_desc=0,
15 enable_gso=0,
16 enable_packed_ring=0,
17 enable_event_idx=0,
18 custom_dev_instance=0xFFFFFFFF,
19 use_custom_mac=0,
20 mac_address="",
21 tag="",
22 ):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020023 """Create VPP Vhost interface"""
Klement Sekerab9ef2732018-06-24 22:49:33 +020024 super(VppVhostInterface, self).__init__(test)
Stevene8fa6202017-08-30 14:36:45 -070025 self.is_server = is_server
26 self.sock_filename = sock_filename
27 self.renumber = renumber
Mohsin Kazmiee2e58f2018-08-21 16:07:03 +020028 self.disable_mrg_rxbuf = disable_mrg_rxbuf
29 self.disable_indirect_desc = disable_indirect_desc
Steven Luong27ba5002020-11-17 13:30:44 -080030 self.enable_gso = enable_gso
31 self.enable_packed_ring = enable_packed_ring
32 self.enable_event_idx = enable_event_idx
Stevene8fa6202017-08-30 14:36:45 -070033 self.custom_dev_instance = custom_dev_instance
34 self.use_custom_mac = use_custom_mac
35 self.mac_address = mac_address
36 self.tag = tag
37
38 def add_vpp_config(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020039 r = self.test.vapi.create_vhost_user_if_v2(
40 self.is_server,
41 self.sock_filename,
42 self.renumber,
43 self.disable_mrg_rxbuf,
44 self.disable_indirect_desc,
45 self.enable_gso,
46 self.enable_packed_ring,
47 self.enable_event_idx,
48 self.custom_dev_instance,
49 self.use_custom_mac,
50 self.mac_address,
51 self.tag,
52 )
Klement Sekerab9ef2732018-06-24 22:49:33 +020053 self.set_sw_if_index(r.sw_if_index)
Stevene8fa6202017-08-30 14:36:45 -070054
55 def remove_vpp_config(self):
56 self.test.vapi.delete_vhost_user_if(self.sw_if_index)
57
58 def is_interface_config_in_dump(self, dump):
59 for i in dump:
60 if i.sw_if_index == self.sw_if_index:
61 return True
62 else:
63 return False