From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id E1C7711A2 for ; Tue, 14 Jul 2015 07:03:35 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 13 Jul 2015 22:03:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,469,1432623600"; d="scan'208";a="763931145" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 13 Jul 2015 22:03:34 -0700 Received: from shecgisg003.sh.intel.com (shecgisg003.sh.intel.com [10.239.29.90]) by shvmail01.sh.intel.com with ESMTP id t6E53Wtl017382; Tue, 14 Jul 2015 13:03:32 +0800 Received: from shecgisg003.sh.intel.com (localhost [127.0.0.1]) by shecgisg003.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id t6E53Ue1012812; Tue, 14 Jul 2015 13:03:32 +0800 Received: (from yliu84x@localhost) by shecgisg003.sh.intel.com (8.13.6/8.13.6/Submit) id t6E53U6J012808; Tue, 14 Jul 2015 13:03:30 +0800 From: Yong Liu To: dts@dpdk.org Date: Tue, 14 Jul 2015 13:03:28 +0800 Message-Id: <1436850208-12776-1-git-send-email-yong.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dts] [PATCH] Optimize interface enable ipv6 and disable ipv6 function X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jul 2015 05:03:36 -0000 From: Marvin Liu Move ipv6 operation to net_device module. Now function only support linux OS. Signed-off-by: Marvin Liu diff --git a/framework/dut.py b/framework/dut.py index bbc6274..d587834 100644 --- a/framework/dut.py +++ b/framework/dut.py @@ -834,13 +834,13 @@ class Dut(Crb): def disable_tester_ipv6(self): for tester_port in self.ports_map: - intf = self.tester.get_interface(tester_port) - self.tester.disable_ipv6(intf) + port = self.tester.ports_info[tester_port]['port'] + port.disable_ipv6() def enable_tester_ipv6(self): for tester_port in self.ports_map: - intf = self.tester.get_interface(tester_port) - self.tester.enable_ipv6(intf) + port = self.tester.ports_info[tester_port]['port'] + port.enable_ipv6() def check_port_occupied(self, port): out = self.alt_session.send_expect('lsof -i:%d' % port, '# ') diff --git a/framework/net_device.py b/framework/net_device.py index bb0464a..a2ccc30 100644 --- a/framework/net_device.py +++ b/framework/net_device.py @@ -56,7 +56,7 @@ class NetDevice(object): self.pci = bus_id + ':' + devfun_id self.pci_id = self.get_pci_id(bus_id, devfun_id) self.default_driver = settings.get_nic_driver(self.pci_id) - + if self.nic_is_pf(): self.default_vf_driver = '' self.get_interface_name() @@ -118,7 +118,6 @@ class NetDevice(object): socket = -1 return socket - def get_nic_socket_freebsd(self, bus_id, devfun_id): NotImplemented @@ -178,11 +177,11 @@ class NetDevice(object): """ try: get_interface_name_freebsd = getattr(self, - 'get_interface_name_freebsd_%s' % driver) + 'get_interface_name_freebsd_%s' % driver) except Exception as e: generic_driver = 'generic' get_interface_name_freebsd = getattr(self, - 'get_interface_name_freebsd_%s' % generic_driver) + 'get_interface_name_freebsd_%s' % generic_driver) return get_interface_name_freebsd(bus_id, devfun_id) @@ -253,7 +252,7 @@ class NetDevice(object): Get MAC by the default way on linux. """ virtio_cmd = ('ls /sys/bus/pci/devices/0000\:%s\:%s/ | grep --color=never virtio' % - (bus_id, devfun_id)) + (bus_id, devfun_id)) virtio = self.__send_expect(virtio_cmd, '# ') command = ('cat /sys/bus/pci/devices/0000\:%s\:%s/%s/net/%s/address' % @@ -351,6 +350,58 @@ class NetDevice(object): return match[0] @nic_has_driver + def enable_ipv6(self): + """ + Enable ipv6 address of specified pci device. + """ + if self.current_driver != self.default_driver: + return + + enable_ipv6 = getattr( + self, 'enable_ipv6_%s' % self.__get_os_type()) + return enable_ipv6(self.intf_name) + + def enable_ipv6_linux(self, intf): + """ + Enable ipv6 address of specified pci device on linux. + """ + self.__send_expect("sysctl net.ipv6.conf.%s.disable_ipv6=0" % + intf, "# ") + + def enable_ipv6_freebsd(self, intf): + pass + + @nic_has_driver + def disable_ipv6(self): + """ + Enable ipv6 address of specified pci device. + """ + if self.current_driver != self.default_driver: + return + disable_ipv6 = getattr( + self, 'disable_ipv6_%s' % self.__get_os_type()) + return disable_ipv6(self.intf_name) + + def disable_ipv6_linux(self, intf): + """ + Enable ipv6 address of specified pci device on linux. + """ + self.__send_expect("sysctl net.ipv6.conf.%s.disable_ipv6=1" % + intf, "# ") + + def disable_ipv6_freebsd(self, intf): + pass + + @nic_has_driver + def get_ipv6_addr(self): + """ + Get ipv6 address of specified pci device. + """ + get_ipv6_addr = getattr( + self, 'get_ipv6_addr_%s' % self.__get_os_type()) + return get_ipv6_addr(self.intf_name, self.current_driver) + + @nic_has_driver def get_ipv6_addr(self): """ Get ipv6 address of specified pci device. @@ -560,7 +611,7 @@ class NetDevice(object): vf_reg_path = self.__send_expect(regx_reg_path, "# ") else: vf_reg_path = os.path.join("/sys/bus/pci/devices/0000:%s:%s" % - (bus_id, devfun_id), vf_reg_file) + (bus_id, devfun_id), vf_reg_file) self.__send_expect("echo %d > %s" % (int(vf_num), vf_reg_path), "# ") -- 1.9.3