RM-autogen.py: Print resources per host with --perhost
authorNikhil Devshatwar <nikhil.nd@ti.com>
Thu, 7 May 2020 12:27:18 +0000 (17:57 +0530)
committerNikhil Devshatwar <nikhil.nd@ti.com>
Thu, 7 May 2020 12:27:24 +0000 (17:57 +0530)
Create a new argument --perhost which would print the resource
assignments list per host.
This will be useful to sync PDK udma_rmcfg structs

Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
respart/RM-autogen.py

index feca3bb390a953632be7c8e41e4e70ec0d7a83f7..d81a2f5e416ed954e6e35efe549866f6e11dd88f 100755 (executable)
@@ -22,6 +22,7 @@ ROW_RES_START = 1
 
 comments = {}
 resasg = {}
+host_list = []
 
 def gen_rmcfg_data(sharing):
        global comments
@@ -55,6 +56,9 @@ def gen_rmcfg_data(sharing):
                                continue
                        num = int(num)
 
+                       if (host_id not in host_list):
+                               host_list.append(host_id)
+
                        key = (restype, subtype, host_id)
                        value = (start, num)
                        if (key in resasg):
@@ -120,6 +124,15 @@ def print_rmcfg(rmcfg, prefix=""):
                output += rmconfig_templ % (start, num, restype, subtype, host)
        return output
 
+def print_per_host_id(rmcfg, prefix=""):
+       print host_list
+       for h_id in  host_list:
+               print (">>>>>> For host %s" % h_id)
+               for entry in rmcfg:
+                       (start, num, restype, subtype, host) = entry
+                       if (host == h_id):
+                               print ("%s: %s start = %d, count = %d " % (restype, subtype, start, num))
+
 ################################################################################
 ##                          Main program starts here                          ##
 ################################################################################
@@ -143,6 +156,10 @@ parser.add_argument('--share', dest='share', default=[],
        action='append', nargs=2, metavar=('HOST_ID_A', 'HOST_ID_B'),
        help='Share resource with HOST_ID_A for HOST_ID_B')
 
+parser.add_argument('--perhost', dest='perhost',
+       action='store_true',
+       help='Print the resource assignment per host')
+
 parser.add_argument('--allow_all', dest='allow_all',
        action='store_true',
        help='Create the minimal boardconfig to allow all hosts to access all resources')
@@ -169,6 +186,8 @@ else:
        print ("ERROR: format %s not supported" % args.format)
        exit(1)
 
+if (args.perhost):
+       print_per_host_id(boardconfig, prefix="TISCI_")
 
 ofile = open(args.output, "w")
 ofile.write(data)