test suite reviews and discussions
 help / color / mirror / Atom feed
From: Yong Liu <yong.liu@intel.com>
To: dts@dpdk.org
Subject: [dts] [PATCH] Optimize interface enable ipv6 and disable ipv6 function
Date: Tue, 14 Jul 2015 13:03:28 +0800	[thread overview]
Message-ID: <1436850208-12776-1-git-send-email-yong.liu@intel.com> (raw)

From: Marvin Liu <yong.liu@intel.com>

Move ipv6 operation to net_device module. Now function only support linux OS.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

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

                 reply	other threads:[~2015-07-14  5:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1436850208-12776-1-git-send-email-yong.liu@intel.com \
    --to=yong.liu@intel.com \
    --cc=dts@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).