1 // SPDX-License-Identifier: GPL-2.0-only
3 * Linux network driver for QLogic BR-series Converged Network Adapter.
6 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
7 * Copyright (c) 2014-2015 QLogic Corporation
11 #include <linux/firmware.h>
16 const struct firmware
*bfi_fw
;
17 static u32
*bfi_image_ct_cna
, *bfi_image_ct2_cna
;
18 static u32 bfi_image_ct_cna_size
, bfi_image_ct2_cna_size
;
21 cna_read_firmware(struct pci_dev
*pdev
, u32
**bfi_image
,
22 u32
*bfi_image_size
, char *fw_name
)
24 const struct firmware
*fw
;
27 if (request_firmware(&fw
, fw_name
, &pdev
->dev
)) {
28 dev_alert(&pdev
->dev
, "can't load firmware %s\n", fw_name
);
32 *bfi_image
= (u32
*)fw
->data
;
33 *bfi_image_size
= fw
->size
/sizeof(u32
);
36 /* Convert loaded firmware to host order as it is stored in file
37 * as sequence of LE32 integers.
39 for (n
= 0; n
< *bfi_image_size
; n
++)
40 le32_to_cpus(*bfi_image
+ n
);
48 cna_get_firmware_buf(struct pci_dev
*pdev
)
50 if (pdev
->device
== BFA_PCI_DEVICE_ID_CT2
) {
51 if (bfi_image_ct2_cna_size
== 0)
52 cna_read_firmware(pdev
, &bfi_image_ct2_cna
,
53 &bfi_image_ct2_cna_size
, CNA_FW_FILE_CT2
);
54 return bfi_image_ct2_cna
;
55 } else if (bfa_asic_id_ct(pdev
->device
)) {
56 if (bfi_image_ct_cna_size
== 0)
57 cna_read_firmware(pdev
, &bfi_image_ct_cna
,
58 &bfi_image_ct_cna_size
, CNA_FW_FILE_CT
);
59 return bfi_image_ct_cna
;
66 bfa_cb_image_get_chunk(enum bfi_asic_gen asic_gen
, u32 off
)
70 return (bfi_image_ct_cna
+ off
);
71 case BFI_ASIC_GEN_CT2
:
72 return (bfi_image_ct2_cna
+ off
);
79 bfa_cb_image_get_size(enum bfi_asic_gen asic_gen
)
83 return bfi_image_ct_cna_size
;
84 case BFI_ASIC_GEN_CT2
:
85 return bfi_image_ct2_cna_size
;