Skip to content

Commit

Permalink
Merge pull request #45 from ibm-capi/libcxlupdates
Browse files Browse the repository at this point in the history
libcxlupdates for afu_directed, extend libcxl subroutine support, and code fix for #44.
  • Loading branch information
LanceThompson authored Jun 17, 2016
2 parents 624b092 + 692b3f8 commit c8b6053
Show file tree
Hide file tree
Showing 34 changed files with 923 additions and 103 deletions.
39 changes: 39 additions & 0 deletions common/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ static void _debug_send_32_32(FILE * fp, DBG_HEADER header, uint32_t value0,
}
}



static void _debug_send_id_8_16(FILE * fp, DBG_HEADER header, uint8_t id,
uint8_t value0, uint16_t value1)
{
Expand All @@ -156,6 +158,33 @@ static void _debug_send_id_8_16(FILE * fp, DBG_HEADER header, uint8_t id,
}
}

static void _debug_send_id_32_64(FILE * fp, DBG_HEADER header, uint8_t id,
uint32_t value0, uint64_t value1)
{
char *buffer;
size_t size;
int offset;

offset = 0;
header = adjust_header(header);
size =
sizeof(DBG_HEADER) + sizeof(id) + sizeof(value0) + sizeof(value1);
if ((buffer = (char *)malloc(size)) != NULL) {
memcpy(buffer, (char *)&header, sizeof(DBG_HEADER));
offset += sizeof(header);
buffer[offset] = id;
offset += sizeof(id);
value0 = htonl(value0);
memcpy(buffer + offset, (char *)&value0, sizeof(value0));
offset += sizeof(value0);
value1 = htonll(value1);
memcpy(buffer + offset, (char *)&value1, sizeof(value1));
fwrite(buffer, size, 1, fp);
free(buffer);
}
}


static void _debug_send_id_8_16_16(FILE * fp, DBG_HEADER header, uint8_t id,
uint8_t value0, uint16_t value1,
uint16_t value2)
Expand Down Expand Up @@ -313,6 +342,16 @@ void debug_job_send(FILE * fp, uint8_t id, uint32_t code)
_debug_send_id_32(fp, DBG_HEADER_JOB_SEND, id, code);
}

void debug_pe_add(FILE * fp, uint8_t id, uint32_t code, uint64_t addr)
{
_debug_send_id_32_64(fp, DBG_HEADER_PE_ADD, id, code, addr);
}

void debug_pe_send(FILE * fp, uint8_t id, uint32_t code, uint64_t addr)
{
_debug_send_id_32_64(fp, DBG_HEADER_PE_SEND, id, code, addr);
}

void debug_job_aux2(FILE * fp, uint8_t id, uint8_t aux2)
{
_debug_send_id_8(fp, DBG_HEADER_JOB_AUX2, id, aux2);
Expand Down
8 changes: 8 additions & 0 deletions common/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ typedef uint8_t DBG_HEADER;
#define DBG_HEADER_CMD_BUFFER_WRITE 0x14
#define DBG_HEADER_CMD_BUFFER_READ 0x15
#define DBG_HEADER_CMD_RESPONSE 0x16
#define DBG_HEADER_PE_ADD 0x18
#define DBG_HEADER_PE_SEND 0x19

#define DBG_AUX2_DONE 0x80
#define DBG_AUX2_RUNNING 0x40
Expand All @@ -60,6 +62,10 @@ typedef uint8_t DBG_HEADER;
#define DBG_PARM_PAGED_PERCENT 0x4
#define DBG_PARM_REORDER_PERCENT 0x5
#define DBG_PARM_BUFFER_PERCENT 0x6
#define DBG_CAIA_VERSION 0x7
#define DBG_PSL_REV_LVL 0x8
#define DBG_IMAGE_LOADED 0x9
#define DBG_BASE_IMAGE 0xA

size_t debug_get_64(FILE * fp, uint64_t * value);
size_t debug_get_32(FILE * fp, uint32_t * value);
Expand All @@ -84,6 +90,8 @@ void debug_context_remove(FILE * fp, uint8_t id, uint16_t context);
void debug_job_add(FILE * fp, uint8_t id, uint32_t code);
void debug_job_send(FILE * fp, uint8_t id, uint32_t code);
void debug_job_aux2(FILE * fp, uint8_t id, uint8_t aux2);
void debug_pe_add(FILE * fp, uint8_t id, uint32_t code, uint64_t addr);
void debug_pe_send(FILE * fp, uint8_t id, uint32_t code, uint64_t addr);
void debug_parm(FILE * fp, uint32_t parm, uint32_t value);
void debug_mmio_map(FILE * fp, uint8_t id, uint16_t context);
void debug_mmio_add(FILE * fp, uint8_t id, uint16_t context, uint8_t rnw,
Expand Down
2 changes: 2 additions & 0 deletions common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
#define PSLSE_MMIO_FAIL 0x12
#define PSLSE_INTERRUPT 0x13
#define PSLSE_AFU_ERROR 0x14
#define PSLSE_MMIO_EBREAD 0x15
#define PSLSE_VSEC_INFO 0x16

// PSLSE states
enum pslse_state {
Expand Down
56 changes: 56 additions & 0 deletions debug/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ static int _parse_parm(FILE * fp)
case DBG_PARM_TIMEOUT:
printf("PARM:TIMEOUT=%d\n", value);
break;
case DBG_PARM_CREDITS:
printf("PARM:CREDITS=%d\n", value);
break;
case DBG_PARM_RESP_PERCENT:
printf("PARM:REPSONSE_PERCENT=%d\n", value);
break;
Expand Down Expand Up @@ -164,6 +167,54 @@ static int _parse_job(FILE * fp, DBG_HEADER header)
return 0;
}

static int _parse_pe(FILE * fp, DBG_HEADER header)
{
uint32_t code;
uint8_t id;
uint64_t addr;
char *name;

if (debug_get_8(fp, &id) < 1)
return -1;
if (debug_get_32(fp, &code) < 1)
return -1;
name = _afu_name(id);

printf("%s:JOB: ", name);
switch (header) {
case DBG_HEADER_PE_ADD:
printf("Added ");
break;
case DBG_HEADER_PE_SEND:
printf("Sent ");
break;
default:
free(name);
return -1;
}
printf("LLCMD ");
if (debug_get_64(fp, &addr) < 1) {
printf("No LLCMD addr?");
return -1;
}
switch (addr) {
case PSL_LLCMD_ADD:
printf("ADD");
break;
case PSL_LLCMD_REMOVE:
printf("REMOVE");
break;
case PSL_LLCMD_TERMINATE:
printf("TERMINATE");
break;
default:
printf(" Unknown LLCMD:0x%016"PRIx64, addr);
}
printf("\n");
free(name);
return 0;
}

static int _parse_map(FILE * fp, DBG_HEADER header)
{
uint16_t context;
Expand Down Expand Up @@ -583,6 +634,11 @@ int main(int argc, char **argv)
if (_parse_job(fp, header) < 0)
return -1;
break;
case DBG_HEADER_PE_ADD:
case DBG_HEADER_PE_SEND:
if (_parse_pe(fp, header) < 0)
return -1;
break;
case DBG_HEADER_JOB_AUX2:
if (_parse_aux(fp, header) < 0)
return -1;
Expand Down
Loading

0 comments on commit c8b6053

Please sign in to comment.