diff mbox

[RESEND,v1,08/11] ibm-fsp/firenze: Nest Alink unit support

Message ID 1436115333-18657-9-git-send-email-maddy@linux.vnet.ibm.com
State Changes Requested
Headers show

Commit Message

maddy July 5, 2015, 4:55 p.m. UTC
Patch adds support for Nest Alink unit. Alinks connects sockets.

Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
---
 hw/nest.c      | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 include/nest.h |  3 +++
 2 files changed, 50 insertions(+)

Comments

Joel Stanley July 16, 2015, 1:53 a.m. UTC | #1
On Sun, 2015-07-05 at 22:25 +0530, Madhavan Srinivasan wrote:
> diff --git a/hw/nest.c b/hw/nest.c
> index bc87ec0..df93601 100644
> --- a/hw/nest.c
> +++ b/hw/nest.c
> @@ -151,6 +151,49 @@ int dt_create_ima_chip_powerbus_type( struct dt_node *ima,
>  	return 0;
>  }
>  
> +int dt_create_ima_chip_alink_event(struct dt_node *ima,
> +					int idx, u32 offset)
> +{
> +	char ev_name[MAX_NAME_SIZE];
> +	const char *unit = "MiB", *scale = "7.629e-6";
> +
> +	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
> +	snprintf(ev_name, MAX_NAME_SIZE, "Alink%d", idx);

No need to memset, snprintf will add a trailing null for you.

> +	dt_add_property_cells(ima, ev_name, offset);
> +
> +	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
> +	snprintf(ev_name, MAX_NAME_SIZE, "unit.Alink%d.unit", idx);

Again.

> +	dt_add_property_string(ima, ev_name, unit);
> +
> +	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
> +	snprintf(ev_name, MAX_NAME_SIZE, "scale.Alink%d.scale", idx);

Again.

This code seems to be very similar to patch 7. Could you merge
dt_create_ima_chip_powerbus_event and dt_create_ima_chip_alink_event?

> +	dt_add_property_string(ima, ev_name, scale);
> +
> +	return 0;
> +}
> +
> +int dt_create_ima_chip_alink_type( struct dt_node *ima,
> +			struct ima_catalogue_group_data *gptr, char *name)
> +{
> +	struct dt_node *type;
> +	int idx;
> +	u32 offset;
> +
> +	type = dt_new(ima, name);
> +	if (!type) {
> +		prlog(PR_DEBUG, "ima %s type creation failed \n", name);
> +		return -1;
> +	}
> +
> +	dt_add_property_string(type, "device_type", "nest-ima-unit");
> +	for(idx=0;idx < 3; idx++) {

we normally space things like this, and there's no harm in using i for
your counter:

 for (i = 0; i < 3; i++)

> +		offset = get_chip_event_offset(gptr->event_index[idx]);
> +		dt_create_ima_chip_alink_event(type, idx, offset);
> +	}
> +
> +	return 0;
> +}
> +
maddy July 16, 2015, 3:45 a.m. UTC | #2
On Thursday 16 July 2015 07:23 AM, Joel Stanley wrote:
> On Sun, 2015-07-05 at 22:25 +0530, Madhavan Srinivasan wrote:
>> diff --git a/hw/nest.c b/hw/nest.c
>> index bc87ec0..df93601 100644
>> --- a/hw/nest.c
>> +++ b/hw/nest.c
>> @@ -151,6 +151,49 @@ int dt_create_ima_chip_powerbus_type( struct dt_node *ima,
>>  	return 0;
>>  }
>>  
>> +int dt_create_ima_chip_alink_event(struct dt_node *ima,
>> +					int idx, u32 offset)
>> +{
>> +	char ev_name[MAX_NAME_SIZE];
>> +	const char *unit = "MiB", *scale = "7.629e-6";
>> +
>> +	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
>> +	snprintf(ev_name, MAX_NAME_SIZE, "Alink%d", idx);
> No need to memset, snprintf will add a trailing null for you.
>
>> +	dt_add_property_cells(ima, ev_name, offset);
>> +
>> +	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
>> +	snprintf(ev_name, MAX_NAME_SIZE, "unit.Alink%d.unit", idx);
> Again.
>
>> +	dt_add_property_string(ima, ev_name, unit);
>> +
>> +	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
>> +	snprintf(ev_name, MAX_NAME_SIZE, "scale.Alink%d.scale", idx);
> Again.
>
> This code seems to be very similar to patch 7. Could you merge
> dt_create_ima_chip_powerbus_event and dt_create_ima_chip_alink_event?

Will remove the memset.
No. would prefer to have separate function that way,
it is easier to handle changes specific to that unit in
the meta-data file.

>> +	dt_add_property_string(ima, ev_name, scale);
>> +
>> +	return 0;
>> +}
>> +
>> +int dt_create_ima_chip_alink_type( struct dt_node *ima,
>> +			struct ima_catalogue_group_data *gptr, char *name)
>> +{
>> +	struct dt_node *type;
>> +	int idx;
>> +	u32 offset;
>> +
>> +	type = dt_new(ima, name);
>> +	if (!type) {
>> +		prlog(PR_DEBUG, "ima %s type creation failed \n", name);
>> +		return -1;
>> +	}
>> +
>> +	dt_add_property_string(type, "device_type", "nest-ima-unit");
>> +	for(idx=0;idx < 3; idx++) {
> we normally space things like this, and there's no harm in using i for
> your counter:

Will fix the spacing. Thanks

>  for (i = 0; i < 3; i++)
>
>> +		offset = get_chip_event_offset(gptr->event_index[idx]);
>> +		dt_create_ima_chip_alink_event(type, idx, offset);
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>
diff mbox

Patch

diff --git a/hw/nest.c b/hw/nest.c
index bc87ec0..df93601 100644
--- a/hw/nest.c
+++ b/hw/nest.c
@@ -151,6 +151,49 @@  int dt_create_ima_chip_powerbus_type( struct dt_node *ima,
 	return 0;
 }
 
+int dt_create_ima_chip_alink_event(struct dt_node *ima,
+					int idx, u32 offset)
+{
+	char ev_name[MAX_NAME_SIZE];
+	const char *unit = "MiB", *scale = "7.629e-6";
+
+	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
+	snprintf(ev_name, MAX_NAME_SIZE, "Alink%d", idx);
+	dt_add_property_cells(ima, ev_name, offset);
+
+	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
+	snprintf(ev_name, MAX_NAME_SIZE, "unit.Alink%d.unit", idx);
+	dt_add_property_string(ima, ev_name, unit);
+
+	memset((void *)ev_name, '\0', MAX_NAME_SIZE);
+	snprintf(ev_name, MAX_NAME_SIZE, "scale.Alink%d.scale", idx);
+	dt_add_property_string(ima, ev_name, scale);
+
+	return 0;
+}
+
+int dt_create_ima_chip_alink_type( struct dt_node *ima,
+			struct ima_catalogue_group_data *gptr, char *name)
+{
+	struct dt_node *type;
+	int idx;
+	u32 offset;
+
+	type = dt_new(ima, name);
+	if (!type) {
+		prlog(PR_DEBUG, "ima %s type creation failed \n", name);
+		return -1;
+	}
+
+	dt_add_property_string(type, "device_type", "nest-ima-unit");
+	for(idx=0;idx < 3; idx++) {
+		offset = get_chip_event_offset(gptr->event_index[idx]);
+		dt_create_ima_chip_alink_event(type, idx, offset);
+	}
+
+	return 0;
+}
+
 /*
  * Wrapper Function to call Corresponding Nest unit functions
  * for event dt creation. Not all the Chip Groups in the Catalog are
@@ -161,6 +204,7 @@  int dt_create_ima_chip_type (struct dt_node *ima,
 {
 	char *name;
 	int rc = -EINVAL;
+	char al[]="Alink_BW";
 
 	name = (char *)malloc(gptr->group_name_len);
 	if (!name)
@@ -173,6 +217,9 @@  int dt_create_ima_chip_type (struct dt_node *ima,
 	} else if (strstr(name, "PowerBus_BW")) {
 		if (dt_create_ima_chip_powerbus_type(ima, gptr,name))
 			goto out;
+	} else if (strstr(name, "A-link_data")) {
+		if (dt_create_ima_chip_alink_type(ima, gptr,al))
+			goto out;
 	} else
 		goto out;
 
diff --git a/include/nest.h b/include/nest.h
index f569998..9a5669c 100644
--- a/include/nest.h
+++ b/include/nest.h
@@ -233,6 +233,9 @@  int dt_create_ima_chip_mcs_event(struct dt_node *,int,u32);
 int dt_create_ima_chip_powerbus_type(struct dt_node *,
 				struct ima_catalogue_group_data *,char *);
 int dt_create_ima_chip_powerbus_event(struct dt_node *,u32, const char *);
+int dt_create_ima_chip_alink_type(struct dt_node *,
+				struct ima_catalogue_group_data *,char *);
+int dt_create_ima_chip_alink_event(struct dt_node *,int,u32);
 void nest_ima_init(void);
 
 #endif	/* __NEST_H__ */