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, |
Mohsin Kazmi | ee2e58f | 2018-08-21 16:07:03 +0200 | [diff] [blame] | 8 | disable_mrg_rxbuf=0, disable_indirect_desc=0, |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 9 | custom_dev_instance=0, use_custom_mac=0, mac_address='', |
| 10 | tag=''): |
| 11 | |
| 12 | """ Create VPP Vhost interface """ |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 13 | super(VppVhostInterface, self).__init__(test) |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 14 | self.is_server = is_server |
| 15 | self.sock_filename = sock_filename |
| 16 | self.renumber = renumber |
Mohsin Kazmi | ee2e58f | 2018-08-21 16:07:03 +0200 | [diff] [blame] | 17 | self.disable_mrg_rxbuf = disable_mrg_rxbuf |
| 18 | self.disable_indirect_desc = disable_indirect_desc |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 19 | self.custom_dev_instance = custom_dev_instance |
| 20 | self.use_custom_mac = use_custom_mac |
| 21 | self.mac_address = mac_address |
| 22 | self.tag = tag |
| 23 | |
| 24 | def add_vpp_config(self): |
| 25 | r = self.test.vapi.create_vhost_user_if(self.is_server, |
| 26 | self.sock_filename, |
| 27 | self.renumber, |
Mohsin Kazmi | ee2e58f | 2018-08-21 16:07:03 +0200 | [diff] [blame] | 28 | self.disable_mrg_rxbuf, |
| 29 | self.disable_indirect_desc, |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 30 | self.custom_dev_instance, |
| 31 | self.use_custom_mac, |
| 32 | self.mac_address, |
| 33 | self.tag) |
Klement Sekera | b9ef273 | 2018-06-24 22:49:33 +0200 | [diff] [blame] | 34 | self.set_sw_if_index(r.sw_if_index) |
Steven | e8fa620 | 2017-08-30 14:36:45 -0700 | [diff] [blame] | 35 | |
| 36 | def remove_vpp_config(self): |
| 37 | self.test.vapi.delete_vhost_user_if(self.sw_if_index) |
| 38 | |
| 39 | def is_interface_config_in_dump(self, dump): |
| 40 | for i in dump: |
| 41 | if i.sw_if_index == self.sw_if_index: |
| 42 | return True |
| 43 | else: |
| 44 | return False |