Project

General

Profile

« Previous | Next » 

Revision a84e59a2

Added by Jim Pingle about 8 years ago

Show if a CPU has AES-NI/CPU crypto support even if the module isn't loaded. Implements #7529

View differences:

src/usr/local/www/includes/functions.inc.php
239 239
	return $out;
240 240
}
241 241

  
242
function get_cpu_crypto_support() {
243
	$machine = get_single_sysctl('hw.machine');
244
	$accelerated_arm_platforms = array('am335x');
245
	$cpucrypto_type = "";
246

  
247
	switch ($machine) {
248
		case 'amd64':
249
			$cpucrypto_type = "AES-NI CPU Crypto: ";
250
			exec("/usr/bin/grep -c '  Features.*AESNI' /var/log/dmesg.boot", $cpucrypto_present);
251
			if ($cpucrypto_present[0] > 0) {
252
				$cpucrypto_type .= "Yes ";
253
				$cpucrypto_type .= ($cpucrypto_active) ? "(active)" : "(inactive)";
254
			} else {
255
				$cpucrypto_type .= "No";
256
			}
257
			$cpucrypto_active = is_module_loaded('aesni');
258
		case 'arm':
259
			$armplatform = get_single_sysctl('hw.platform');
260
			if (in_array($armplatform, $accelerated_arm_platforms)) {
261
				/* No drivers yet, so mark inactive! */
262
				$cpucrypto_type = "{$armplatform} built-in CPU Crypto (inactive)";
263
			}
264
		default:
265
			/* Unknown/unidentified platform */
266
	}
267

  
268
	if (!empty($cpucrypto_type)) {
269
		return $cpucrypto_type;
270
	} else {
271
		return "CPU Crypto: None/Unknown Platform";
272
	}
273
}
274

  
242 275
function get_cpu_count($show_detail = false) {
243 276
	$cpucount = get_single_sysctl('kern.smp.cpus');
244 277

  
src/usr/local/www/widgets/widgets/system_information.widget.php
232 232
					<?= htmlspecialchars($cpucount) ?> <?=gettext('CPUs')?>: <?= htmlspecialchars(get_cpu_count(true)); ?>
233 233
				</div>
234 234
		<?php endif; ?>
235
				<div id="cpucrypto">
236
					<?= get_cpu_crypto_support(); ?>
237
				</div>
235 238
			</td>
236 239
		</tr>
237 240
<?php

Also available in: Unified diff