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 | |
Klement Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 7 | 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 Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 23 | """Create VPP Vhost interface""" |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 24 | super(VppVhostInterface, self).__init__(test) |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 25 | self.is_server = is_server |
| 26 | self.sock_filename = sock_filename |
| 27 | self.renumber = renumber |
Mohsin Kazmi | ee2e58f | 2018-08-21 16:07:03 +0200 | [diff] [blame] | 28 | self.disable_mrg_rxbuf = disable_mrg_rxbuf |
| 29 | self.disable_indirect_desc = disable_indirect_desc |
Steven Luong | 27ba500 | 2020-11-17 13:30:44 -0800 | [diff] [blame] | 30 | self.enable_gso = enable_gso |
| 31 | self.enable_packed_ring = enable_packed_ring |
| 32 | self.enable_event_idx = enable_event_idx |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 33 | 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 Sekera | d9b0c6f | 2022-04-26 19:02:15 +0200 | [diff] [blame] | 39 | 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 Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 53 | self.set_sw_if_index(r.sw_if_index) |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 54 | |
| 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 |