ofctl_v1_3 lacks of get_desc_stats & get_port_stats methods which is available
in ofctl_v1_0. I copied the code from ofctl_v1_0 and it works fine. The only
change to get_port_stats in ofctl_v1_3 is using OFPP_ANY as argument to call
OFPPortStatsRequest.

Signed-off-by: Wei-Li Tang <[email protected]>
---
 ryu/lib/ofctl_v1_3.py |   43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index e2a2717..dbe7aaf 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -202,6 +202,22 @@ def send_stats_request(dp, stats, waiters, msgs):
         del waiters_per_dp[stats.xid]
 
 
+def get_desc_stats(dp, waiters):
+    stats = dp.ofproto_parser.OFPDescStatsRequest(dp, 0)
+    msgs = []
+    send_stats_request(dp, stats, waiters, msgs)
+
+    for msg in msgs:
+        stats = msg.body
+        s = {'mfr_desc': stats.mfr_desc,
+             'hw_desc': stats.hw_desc,
+             'sw_desc': stats.sw_desc,
+             'serial_num': stats.serial_num,
+             'dp_desc': stats.dp_desc}
+    desc = {str(dp.id): s}
+    return desc
+
+
 def get_flow_stats(dp, waiters):
     table_id = 0
     flags = 0
@@ -243,6 +259,33 @@ def get_flow_stats(dp, waiters):
     return flows
 
 
+def get_port_stats(dp, waiters):
+    stats = dp.ofproto_parser.OFPPortStatsRequest(
+        dp, 0, dp.ofproto.OFPP_ANY)
+    msgs = []
+    send_stats_request(dp, stats, waiters, msgs)
+
+    ports = []
+    for msg in msgs:
+        for stats in msg.body:
+            s = {'port_no': stats.port_no,
+                 'rx_packets': stats.rx_packets,
+                 'tx_packets': stats.tx_packets,
+                 'rx_bytes': stats.rx_bytes,
+                 'tx_bytes': stats.tx_bytes,
+                 'rx_dropped': stats.rx_dropped,
+                 'tx_dropped': stats.tx_dropped,
+                 'rx_errors': stats.rx_errors,
+                 'tx_errors': stats.tx_errors,
+                 'rx_frame_err': stats.rx_frame_err,
+                 'rx_over_err': stats.rx_over_err,
+                 'rx_crc_err': stats.rx_crc_err,
+                 'collisions': stats.collisions}
+            ports.append(s)
+    ports = {str(dp.id): ports}
+    return ports
+
+
 def mod_flow_entry(dp, flow, cmd):
     cookie = int(flow.get('cookie', 0))
     cookie_mask = int(flow.get('cookie_mask', 0))
-- 
1.7.9.5


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to