Browse Source

RPC: pgarestart command to match {cpu,gpu}restart

Luke Dashjr 12 years ago
parent
commit
289817c24a
2 changed files with 26 additions and 0 deletions
  1. 7 0
      README.RPC
  2. 19 0
      api.c

+ 7 - 0
README.RPC

@@ -310,6 +310,10 @@ The list of requests - a (*) means it requires privileged access - and replies:
                               stating the results of the disable request
                               stating the results of the disable request
                               This is only available if PGA mining is enabled
                               This is only available if PGA mining is enabled
 
 
+ pgarestart|N (*)
+               none           There is no reply section just the STATUS section
+                              stating the results of the restart request
+
  pgaidentify|N (*)
  pgaidentify|N (*)
                none           This is equivalent to PROCIDENTIFY on the first
                none           This is equivalent to PROCIDENTIFY on the first
                               processor of any given device
                               processor of any given device
@@ -483,6 +487,9 @@ Multiple report request command with '+' e.g. summary+devs
 
 
 CPU and OpenCL devices are now included as "PGAs", to enable migration to a simpler interface.
 CPU and OpenCL devices are now included as "PGAs", to enable migration to a simpler interface.
 
 
+Added API commands:
+ 'pgarestart'
+
 Deprecated API commands:
 Deprecated API commands:
  'gpuintensity'
  'gpuintensity'
  'gpumem'
  'gpumem'

+ 19 - 0
api.c

@@ -264,6 +264,7 @@ static const char *JSON_PARAMETER = "parameter";
 #define MSG_PGALRDIS 62
 #define MSG_PGALRDIS 62
 #define MSG_PGAENA 63
 #define MSG_PGAENA 63
 #define MSG_PGADIS 64
 #define MSG_PGADIS 64
+#define MSG_PGAREI 0x101
 #define MSG_PGAUNW 65
 #define MSG_PGAUNW 65
 #endif
 #endif
 
 
@@ -1827,6 +1828,23 @@ static void pgadisable(struct io_data *io_data, __maybe_unused SOCKETTYPE c, cha
 	message(io_data, MSG_PGADIS, id, NULL, isjson);
 	message(io_data, MSG_PGADIS, id, NULL, isjson);
 }
 }
 
 
+static void pgarestart(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
+{
+	struct cgpu_info *cgpu;
+	int id, dev;
+	
+	cgpu = get_pga_cgpu(io_data, c, param, isjson, group, &id, &dev);
+	if (!cgpu)
+		return;
+	
+	applog(LOG_DEBUG, "API: request to pgarestart dev id %d device %d %s",
+			id, dev, cgpu->dev_repr);
+	
+	reinit_device(cgpu);
+	
+	message(io_data, MSG_PGAREI, id, NULL, isjson);
+}
+
 static void pgaidentify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
 static void pgaidentify(struct io_data *io_data, __maybe_unused SOCKETTYPE c, char *param, bool isjson, __maybe_unused char group)
 {
 {
 	struct cgpu_info *cgpu;
 	struct cgpu_info *cgpu;
@@ -3384,6 +3402,7 @@ struct CMDS {
 	{ "pga",		pgadev,		false,	false },
 	{ "pga",		pgadev,		false,	false },
 	{ "pgaenable",		pgaenable,	true,	false },
 	{ "pgaenable",		pgaenable,	true,	false },
 	{ "pgadisable",		pgadisable,	true,	false },
 	{ "pgadisable",		pgadisable,	true,	false },
+	{ "pgarestart",		pgarestart,	true,	false },
 	{ "pgaidentify",	pgaidentify,	true,	false },
 	{ "pgaidentify",	pgaidentify,	true,	false },
 	{ "proc",		pgadev,		false,	false },
 	{ "proc",		pgadev,		false,	false },
 	{ "procenable",		pgaenable,	true,	false },
 	{ "procenable",		pgaenable,	true,	false },