Example #1
0
/*
 * Attach an interface that successfully probed.
 */
static int
xlp_rsa_attach(device_t dev)
{
	struct xlp_rsa_softc *sc = device_get_softc(dev);
	uint64_t base;
	int qstart, qnum;
	int freq, node;

	sc->sc_dev = dev;

	node = nlm_get_device_node(pci_get_slot(dev));
	freq = nlm_set_device_frequency(node, DFS_DEVICE_RSA, 250);
	if (bootverbose)
		device_printf(dev, "RSA Freq: %dMHz\n", freq);
	if (pci_get_device(dev) == PCI_DEVICE_ID_NLM_RSA) {
		device_set_desc(dev, "XLP RSA/ECC Accelerator");
		if ((sc->sc_cid = crypto_get_driverid(dev,
		    CRYPTOCAP_F_HARDWARE)) < 0) {
			printf("xlp_rsaecc-err:couldn't get the driver id\n");
			goto error_exit;
		}
		if (crypto_kregister(sc->sc_cid, CRK_MOD_EXP, 0) != 0)
			goto error_exit;

		base = nlm_get_rsa_pcibase(node);
		qstart = nlm_qidstart(base);
		qnum = nlm_qnum(base);
		sc->rsaecc_vc_start = qstart;
		sc->rsaecc_vc_end = qstart + qnum - 1;
	}
	if (xlp_rsa_init(sc, node) != 0)
		goto error_exit;
	device_printf(dev, "RSA Initialization complete!\n");
	return (0);

error_exit:
	return (ENXIO);
}
Example #2
0
/*
 * Attach an interface that successfully probed.
 */
static int
xlp_sec_attach(device_t dev)
{
	struct xlp_sec_softc *sc = device_get_softc(dev);
	uint64_t base;
	int qstart, qnum;
	int freq, node;

	sc->sc_dev = dev;

	node = nlm_get_device_node(pci_get_slot(dev));
	freq = nlm_set_device_frequency(node, DFS_DEVICE_SAE, 250);
	if (bootverbose)
		device_printf(dev, "SAE Freq: %dMHz\n", freq);
	if(pci_get_device(dev) == PCI_DEVICE_ID_NLM_SAE) {
		device_set_desc(dev, "XLP Security Accelerator");
		sc->sc_cid = crypto_get_driverid(dev, CRYPTOCAP_F_HARDWARE);
		if (sc->sc_cid < 0) {
			printf("xlp_sec - error : could not get the driver"
			    " id\n");
			goto error_exit;
		}
		if (crypto_register(sc->sc_cid, CRYPTO_DES_CBC, 0, 0) != 0)
			printf("register failed for CRYPTO_DES_CBC\n");

		if (crypto_register(sc->sc_cid, CRYPTO_3DES_CBC, 0, 0) != 0)
			printf("register failed for CRYPTO_3DES_CBC\n");

		if (crypto_register(sc->sc_cid, CRYPTO_AES_CBC, 0, 0) != 0)
			printf("register failed for CRYPTO_AES_CBC\n");

		if (crypto_register(sc->sc_cid, CRYPTO_ARC4, 0, 0) != 0)
			printf("register failed for CRYPTO_ARC4\n");

		if (crypto_register(sc->sc_cid, CRYPTO_MD5, 0, 0) != 0)
			printf("register failed for CRYPTO_MD5\n");

		if (crypto_register(sc->sc_cid, CRYPTO_SHA1, 0, 0) != 0)
			printf("register failed for CRYPTO_SHA1\n");

		if (crypto_register(sc->sc_cid, CRYPTO_MD5_HMAC, 0, 0) != 0)
			printf("register failed for CRYPTO_MD5_HMAC\n");

		if (crypto_register(sc->sc_cid, CRYPTO_SHA1_HMAC, 0, 0) != 0)
			printf("register failed for CRYPTO_SHA1_HMAC\n");

		base = nlm_get_sec_pcibase(node);
		qstart = nlm_qidstart(base);
		qnum = nlm_qnum(base);
		sc->sec_vc_start = qstart;
		sc->sec_vc_end = qstart + qnum - 1;
	}

	if (xlp_sec_init(sc) != 0)
		goto error_exit;
	if (bootverbose)
		device_printf(dev, "SEC Initialization complete!\n");
	return (0);

error_exit:
	return (ENXIO);

}