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