Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 1 | from vpp_interface import VppInterface |
| 2 | |
| 3 | |
| 4 | class VppVhostInterface(VppInterface): |
| 5 | """VPP vhost interface.""" |
| 6 | |
| 7 | def __init__(self, test, sock_filename, is_server=0, renumber=0, |
Steven Luong | 27ba500 | 2020-11-17 13:30:44 -0800 | [diff] [blame] | 8 | disable_mrg_rxbuf=0, disable_indirect_desc=0, enable_gso=0, |
| 9 | enable_packed_ring=0, enable_event_idx=0, |
| 10 | custom_dev_instance=0xFFFFFFFF, use_custom_mac=0, |
Steven Luong | bc0d9ff | 2020-03-23 09:34:59 -0700 | [diff] [blame] | 11 | mac_address='', tag=''): |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 12 | |
| 13 | """ Create VPP Vhost interface """ |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 14 | super(VppVhostInterface, self).__init__(test) |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 15 | self.is_server = is_server |
| 16 | self.sock_filename = sock_filename |
| 17 | self.renumber = renumber |
Mohsin Kazmi | ee2e58f | 2018-08-21 16:07:03 +0200 | [diff] [blame] | 18 | self.disable_mrg_rxbuf = disable_mrg_rxbuf |
| 19 | self.disable_indirect_desc = disable_indirect_desc |
Steven Luong | 27ba500 | 2020-11-17 13:30:44 -0800 | [diff] [blame] | 20 | self.enable_gso = enable_gso |
| 21 | self.enable_packed_ring = enable_packed_ring |
| 22 | self.enable_event_idx = enable_event_idx |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 23 | self.custom_dev_instance = custom_dev_instance |
| 24 | self.use_custom_mac = use_custom_mac |
| 25 | self.mac_address = mac_address |
| 26 | self.tag = tag |
| 27 | |
| 28 | def add_vpp_config(self): |
Steven Luong | 27ba500 | 2020-11-17 13:30:44 -0800 | [diff] [blame] | 29 | r = self.test.vapi.create_vhost_user_if_v2(self.is_server, |
| 30 | self.sock_filename, |
| 31 | self.renumber, |
| 32 | self.disable_mrg_rxbuf, |
| 33 | self.disable_indirect_desc, |
| 34 | self.enable_gso, |
| 35 | self.enable_packed_ring, |
| 36 | self.enable_event_idx, |
| 37 | self.custom_dev_instance, |
| 38 | self.use_custom_mac, |
| 39 | self.mac_address, |
| 40 | self.tag) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 41 | self.set_sw_if_index(r.sw_if_index) |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 42 | |
| 43 | def remove_vpp_config(self): |
| 44 | self.test.vapi.delete_vhost_user_if(self.sw_if_index) |
| 45 | |
| 46 | def is_interface_config_in_dump(self, dump): |
| 47 | for i in dump: |
| 48 | if i.sw_if_index == self.sw_if_index: |
| 49 | return True |
| 50 | else: |
| 51 | return False |