@@ -41,6 +41,19 @@ struct __packed nvme_additional_smart_log_item {
4141 __u8 _rp ;
4242};
4343
44+ struct __packed smart_ref_clk {
45+ __u8 id ;
46+ __u8 _kp [2 ];
47+ __u8 normalized ;
48+ __le16 gainCount0 ;
49+ __le16 lossCount0 ;
50+ __le16 gainCount1 ;
51+ __le16 lossCount1 ;
52+ };
53+
54+ _Static_assert (sizeof (struct nvme_additional_smart_log_item ) == sizeof (struct smart_ref_clk ),
55+ "Size mismatch for smart_ref_clk" );
56+
4457#define VU_SMART_PAGE_SIZE 512
4558#define VU_SMART_MAX_ITEMS (VU_SMART_PAGE_SIZE / sizeof(struct nvme_additional_smart_log_item))
4659struct vu_smart_log {
@@ -113,6 +126,8 @@ static char *id_to_name(__u8 id)
113126
114127static void smart_log_item_print (struct nvme_additional_smart_log_item * item )
115128{
129+ struct smart_ref_clk * pll_item = (struct smart_ref_clk * )item ;
130+
116131 if (!item -> id )
117132 return ;
118133
@@ -131,13 +146,22 @@ static void smart_log_item_print(struct nvme_additional_smart_log_item *item)
131146 item -> thermal_throttle .pct ,
132147 le32_to_cpu (item -> thermal_throttle .count ));
133148 return ;
149+ case 0xF3 :
150+ printf ("gain0: %u, loss0: %u, gain1: %u, loss1: %u, legacy:%lu\n" ,
151+ le16_to_cpu (pll_item -> gainCount0 ),
152+ le16_to_cpu (pll_item -> lossCount0 ),
153+ le16_to_cpu (pll_item -> gainCount1 ),
154+ le16_to_cpu (pll_item -> lossCount1 ),
155+ int48_to_long (item -> raw ));
156+ return ;
134157 default :
135158 printf ("%" PRIu64 "\n" , int48_to_long (item -> raw ));
136159 }
137160}
138161
139162static void smart_log_item_add_json (struct nvme_additional_smart_log_item * item , struct json_object * dev_stats )
140163{
164+ struct smart_ref_clk * pll_item = (struct smart_ref_clk * )item ;
141165 struct json_object * entry_stats = json_create_object ();
142166
143167 if (!item -> id )
@@ -155,6 +179,13 @@ static void smart_log_item_add_json(struct nvme_additional_smart_log_item *item,
155179 json_object_add_value_int (entry_stats , "percentage" , item -> thermal_throttle .pct );
156180 json_object_add_value_int (entry_stats , "count" , le32_to_cpu (item -> thermal_throttle .count ));
157181 break ;
182+ case 0xF3 :
183+ json_object_add_value_int (entry_stats , "gain0" , le16_to_cpu (pll_item -> gainCount0 ));
184+ json_object_add_value_int (entry_stats , "loss0" , le16_to_cpu (pll_item -> lossCount0 ));
185+ json_object_add_value_int (entry_stats , "gain1" , le16_to_cpu (pll_item -> gainCount1 ));
186+ json_object_add_value_int (entry_stats , "loss1" , le16_to_cpu (pll_item -> lossCount1 ));
187+ json_object_add_value_int (entry_stats , "legacy" , int48_to_long (item -> raw ));
188+ break ;
158189 default :
159190 json_object_add_value_int (entry_stats , "raw" , int48_to_long (item -> raw ));
160191 }
@@ -198,7 +229,7 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd
198229 const int solidigm_vu_smart_log_id = 0xCA ;
199230 struct vu_smart_log smart_log_payload ;
200231 nvme_print_flags_t flags ;
201- struct nvme_dev * dev ;
232+ _cleanup_nvme_dev_ struct nvme_dev * dev = NULL ;
202233 int err ;
203234 __u8 uuid_index ;
204235
@@ -215,6 +246,7 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd
215246 OPT_ARGS (opts ) = {
216247 OPT_UINT ("namespace-id" , 'n' , & cfg .namespace_id , "(optional) desired namespace" ),
217248 OPT_FMT ("output-format" , 'o' , & cfg .output_format , output_format ),
249+ OPT_INCR ("verbose" , 'v' , & nvme_cfg .verbose , verbose ),
218250 OPT_END ()
219251 };
220252
@@ -263,9 +295,6 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd
263295 nvme_show_status (err );
264296 }
265297
266- /* Redundant close() to make static code analysis happy */
267- close (dev -> direct .fd );
268- dev_close (dev );
269298 return err ;
270299}
271300
0 commit comments