blob: a20504ba1cefe145e7b5323db66affc8d5a8a2e4 [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 ):
Stevene8fa6202017-08-30 14:36:45 -070023
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020024 """Create VPP Vhost interface"""
Klement Sekerab9ef2732018-06-24 22:49:33 +020025 super(VppVhostInterface, self).__init__(test)
Stevene8fa6202017-08-30 14:36:45 -070026 self.is_server = is_server
27 self.sock_filename = sock_filename
28 self.renumber = renumber
Mohsin Kazmiee2e58f2018-08-21 16:07:03 +020029 self.disable_mrg_rxbuf = disable_mrg_rxbuf
30 self.disable_indirect_desc = disable_indirect_desc
Steven Luong27ba5002020-11-17 13:30:44 -080031 self.enable_gso = enable_gso
32 self.enable_packed_ring = enable_packed_ring
33 self.enable_event_idx = enable_event_idx
Stevene8fa6202017-08-30 14:36:45 -070034 self.custom_dev_instance = custom_dev_instance
35 self.use_custom_mac = use_custom_mac
36 self.mac_address = mac_address
37 self.tag = tag
38
39 def add_vpp_config(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020040 r = self.test.vapi.create_vhost_user_if_v2(
41 self.is_server,
42 self.sock_filename,
43 self.renumber,
44 self.disable_mrg_rxbuf,
45 self.disable_indirect_desc,
46 self.enable_gso,
47 self.enable_packed_ring,
48 self.enable_event_idx,
49 self.custom_dev_instance,
50 self.use_custom_mac,
51 self.mac_address,
52 self.tag,
53 )
Klement Sekerab9ef2732018-06-24 22:49:33 +020054 self.set_sw_if_index(r.sw_if_index)
Stevene8fa6202017-08-30 14:36:45 -070055
56 def remove_vpp_config(self):
57 self.test.vapi.delete_vhost_user_if(self.sw_if_index)
58
59 def is_interface_config_in_dump(self, dump):
60 for i in dump:
61 if i.sw_if_index == self.sw_if_index:
62 return True
63 else:
64 return False