Skip to content

Commit 1a0ca93

Browse files
committed
add minor version to info command
Add the minor version number to the info command through reading the GAS address for firmware version info adding the resulting minor version number to the to the HW revision section of the print device info cmd.
1 parent 3bb6ce6 commit 1a0ca93

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

cli/main.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ static int print_dev_info(struct switchtec_dev *dev)
191191
char version[32];
192192
enum switchtec_boot_phase phase;
193193
enum switchtec_rev hw_rev;
194+
char minor_str[8] = "";
195+
int minor_ver;
194196

195197
device_id = switchtec_device_id(dev);
196198

@@ -203,11 +205,24 @@ static int print_dev_info(struct switchtec_dev *dev)
203205
switchtec_perror("dev info");
204206
return ret;
205207
}
208+
ret = switchtec_get_device_info(dev, &phase, NULL, &hw_rev);
209+
if (ret) {
210+
switchtec_perror("dev info");
211+
return ret;
212+
}
213+
if (switchtec_is_gen5(dev)) {
214+
switchtec_get_minor_version(dev, &minor_ver);
215+
if (ret) {
216+
switchtec_perror("minor ver");
217+
return ret;
218+
}
219+
sprintf(minor_str, ".%d", minor_ver);
220+
}
206221

207222
printf("%s (%s):\n", switchtec_name(dev),
208223
switchtec_phase_id_str(phase));
209224
printf(" Generation: %s\n", switchtec_gen_str(dev));
210-
printf(" HW Revision: %s\n", switchtec_rev_str(hw_rev));
225+
printf(" HW Revision: %s%s\n", switchtec_rev_str(hw_rev), minor_str);
211226
printf(" Variant: %s\n",
212227
device_id ? switchtec_variant_str(dev) : "N/A");
213228
if (device_id)

inc/switchtec/switchtec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ int switchtec_list(struct switchtec_device_info **devlist);
358358
void switchtec_list_free(struct switchtec_device_info *devlist);
359359
int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf,
360360
size_t buflen);
361+
int switchtec_get_minor_version(struct switchtec_dev *dev, int *res);
361362
int switchtec_cmd(struct switchtec_dev *dev, uint32_t cmd,
362363
const void *payload, size_t payload_len, void *resp,
363364
size_t resp_len);

lib/platform/linux.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,28 @@ static int linux_get_fw_version(struct switchtec_dev *dev, char *buf,
300300
return 0;
301301
}
302302

303+
static int linux_get_minor_version(struct switchtec_dev *dev, int *minor_ver)
304+
{
305+
int ret;
306+
int version;
307+
char syspath[PATH_MAX];
308+
struct switchtec_linux *ldev = to_switchtec_linux(dev);
309+
310+
ret = dev_to_sysfs_path(ldev, "device_version", syspath, sizeof(syspath));
311+
if (ret)
312+
return ret;
313+
314+
version = sysfs_read_int(syspath, 16);
315+
if (version < 0)
316+
return version;
317+
318+
version = (version >> 0x10) & 0xFF;
319+
320+
memcpy(minor_ver, &version, sizeof(int));
321+
322+
return 0;
323+
}
324+
303325
static int submit_cmd(struct switchtec_linux *ldev, uint32_t cmd,
304326
const void *payload, size_t payload_len)
305327
{
@@ -971,6 +993,7 @@ static const struct switchtec_ops linux_ops = {
971993
.close = linux_close,
972994
.get_device_id = linux_get_device_id,
973995
.get_fw_version = linux_get_fw_version,
996+
.get_minor_version = linux_get_minor_version,
974997
.cmd = linux_cmd,
975998
.get_devices = linux_get_devices,
976999
.pff_to_port = linux_pff_to_port,

lib/platform/platform.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,22 @@ int switchtec_get_fw_version(struct switchtec_dev *dev, char *buf,
150150
return 0;
151151
}
152152

153+
/**
154+
* @brief Get the minor version number as a user readable int
155+
* @ingroup Device
156+
* @param[in] dev Switchtec device handle
157+
* @param[in] res Int to put the version in
158+
*/
159+
int switchtec_get_minor_version(struct switchtec_dev *dev, int *res)
160+
{
161+
int ret;
162+
ret = dev->ops->get_minor_version(dev, res);
163+
if (ret)
164+
return ret;
165+
166+
return 0;
167+
}
168+
153169
/**
154170
* @brief Execute an MRPC command
155171
* @ingroup Device

lib/switchtec_priv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ struct switchtec_ops {
9393
int (*get_device_id)(struct switchtec_dev *dev);
9494
int (*get_fw_version)(struct switchtec_dev *dev, char *buf,
9595
size_t buflen);
96+
int (*get_minor_version)(struct switchtec_dev *dev, int *minor_ver);
9697
int (*cmd)(struct switchtec_dev *dev, uint32_t cmd,
9798
const void *payload, size_t payload_len, void *resp,
9899
size_t resp_len);

0 commit comments

Comments
 (0)