Skip to content

Commit 5a54b1d

Browse files
Krishna GudipatiJames Bottomley
authored andcommitted
[SCSI] bfa: Added support for flash configuration
- Added flash sub-module. - Implemented the interface to read/erase/update flash partition. Signed-off-by: Krishna Gudipati <kgudipat@brocade.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
1 parent 51e569a commit 5a54b1d

9 files changed

Lines changed: 910 additions & 47 deletions

File tree

‎drivers/scsi/bfa/bfa.h‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
struct bfa_s;
2828

2929
typedef void (*bfa_isr_func_t) (struct bfa_s *bfa, struct bfi_msg_s *m);
30-
typedef void (*bfa_cb_cbfn_t) (void *cbarg, bfa_boolean_t complete);
3130

3231
/*
3332
* Interrupt message handlers
@@ -76,16 +75,6 @@ void bfa_isr_unhandled(struct bfa_s *bfa, struct bfi_msg_s *m);
7675
(__index) &= ((__size) - 1); \
7776
} while (0)
7877

79-
/*
80-
* Queue element to wait for room in request queue. FIFO order is
81-
* maintained when fullfilling requests.
82-
*/
83-
struct bfa_reqq_wait_s {
84-
struct list_head qe;
85-
void (*qresume) (void *cbarg);
86-
void *cbarg;
87-
};
88-
8978
/*
9079
* Circular queue usage assignments
9180
*/
@@ -129,17 +118,6 @@ bfa_reqq_winit(struct bfa_reqq_wait_s *wqe, void (*qresume) (void *cbarg),
129118

130119
#define bfa_reqq_wcancel(__wqe) list_del(&(__wqe)->qe)
131120

132-
133-
/*
134-
* Generic BFA callback element.
135-
*/
136-
struct bfa_cb_qe_s {
137-
struct list_head qe;
138-
bfa_cb_cbfn_t cbfn;
139-
bfa_boolean_t once;
140-
void *cbarg;
141-
};
142-
143121
#define bfa_cb_queue(__bfa, __hcb_qe, __cbfn, __cbarg) do { \
144122
(__hcb_qe)->cbfn = (__cbfn); \
145123
(__hcb_qe)->cbarg = (__cbarg); \

‎drivers/scsi/bfa/bfa_core.c‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ bfa_com_sfp_attach(struct bfa_s *bfa)
132132
bfa_sfp_memclaim(sfp, sfp_dma->kva_curp, sfp_dma->dma_curp);
133133
}
134134

135+
static void
136+
bfa_com_flash_attach(struct bfa_s *bfa, bfa_boolean_t mincfg)
137+
{
138+
struct bfa_flash_s *flash = BFA_FLASH(bfa);
139+
struct bfa_mem_dma_s *flash_dma = BFA_MEM_FLASH_DMA(bfa);
140+
141+
bfa_flash_attach(flash, &bfa->ioc, bfa, bfa->trcmod, mincfg);
142+
bfa_flash_memclaim(flash, flash_dma->kva_curp,
143+
flash_dma->dma_curp, mincfg);
144+
}
145+
135146
/*
136147
* BFA IOC FC related definitions
137148
*/
@@ -1371,6 +1382,7 @@ bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
13711382
struct bfa_mem_dma_s *ablk_dma = BFA_MEM_ABLK_DMA(bfa);
13721383
struct bfa_mem_dma_s *cee_dma = BFA_MEM_CEE_DMA(bfa);
13731384
struct bfa_mem_dma_s *sfp_dma = BFA_MEM_SFP_DMA(bfa);
1385+
struct bfa_mem_dma_s *flash_dma = BFA_MEM_FLASH_DMA(bfa);
13741386

13751387
WARN_ON((cfg == NULL) || (meminfo == NULL));
13761388

@@ -1390,6 +1402,8 @@ bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg, struct bfa_meminfo_s *meminfo,
13901402
bfa_mem_dma_setup(meminfo, ablk_dma, bfa_ablk_meminfo());
13911403
bfa_mem_dma_setup(meminfo, cee_dma, bfa_cee_meminfo());
13921404
bfa_mem_dma_setup(meminfo, sfp_dma, bfa_sfp_meminfo());
1405+
bfa_mem_dma_setup(meminfo, flash_dma,
1406+
bfa_flash_meminfo(cfg->drvcfg.min_cfg));
13931407
}
13941408

13951409
/*
@@ -1459,6 +1473,7 @@ bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
14591473
bfa_com_ablk_attach(bfa);
14601474
bfa_com_cee_attach(bfa);
14611475
bfa_com_sfp_attach(bfa);
1476+
bfa_com_flash_attach(bfa, cfg->drvcfg.min_cfg);
14621477
}
14631478

14641479
/*

‎drivers/scsi/bfa/bfa_defs.h‎

Lines changed: 81 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ enum bfa_status {
133133
BFA_STATUS_SFP_UNSUPP = 10, /* Unsupported SFP - Replace SFP */
134134
BFA_STATUS_UNKNOWN_VFID = 11, /* VF_ID not found */
135135
BFA_STATUS_DEVBUSY = 13, /* Device busy - Retry operation */
136+
BFA_STATUS_FLASH_BAD_LEN = 17, /* Flash bad length */
136137
BFA_STATUS_UNKNOWN_LWWN = 18, /* LPORT PWWN not found */
137138
BFA_STATUS_UNKNOWN_RWWN = 19, /* RPORT PWWN not found */
138139
BFA_STATUS_VPORT_EXISTS = 21, /* VPORT already exists */
@@ -384,31 +385,39 @@ struct bfa_ioc_attr_s {
384385
* All numerical fields are in big-endian format.
385386
*/
386387
struct bfa_mfg_block_s {
387-
u8 version; /* manufacturing block version */
388-
u8 mfg_sig[3]; /* characters 'M', 'F', 'G' */
389-
u16 mfgsize; /* mfg block size */
390-
u16 u16_chksum; /* old u16 checksum */
391-
char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
392-
char brcd_partnum[STRSZ(BFA_MFG_PARTNUM_SIZE)];
393-
u8 mfg_day; /* manufacturing day */
394-
u8 mfg_month; /* manufacturing month */
395-
u16 mfg_year; /* manufacturing year */
396-
wwn_t mfg_wwn; /* wwn base for this adapter */
397-
u8 num_wwn; /* number of wwns assigned */
398-
u8 mfg_speeds; /* speeds allowed for this adapter */
399-
u8 rsv[2];
400-
char supplier_id[STRSZ(BFA_MFG_SUPPLIER_ID_SIZE)];
401-
char supplier_partnum[STRSZ(BFA_MFG_SUPPLIER_PARTNUM_SIZE)];
402-
char
403-
supplier_serialnum[STRSZ(BFA_MFG_SUPPLIER_SERIALNUM_SIZE)];
404-
char
405-
supplier_revision[STRSZ(BFA_MFG_SUPPLIER_REVISION_SIZE)];
406-
mac_t mfg_mac; /* mac address */
407-
u8 num_mac; /* number of mac addresses */
408-
u8 rsv2;
409-
u32 mfg_type; /* card type */
410-
u8 rsv3[108];
411-
u8 md5_chksum[BFA_MFG_CHKSUM_SIZE]; /* md5 checksum */
388+
u8 version; /*!< manufacturing block version */
389+
u8 mfg_sig[3]; /*!< characters 'M', 'F', 'G' */
390+
u16 mfgsize; /*!< mfg block size */
391+
u16 u16_chksum; /*!< old u16 checksum */
392+
char brcd_serialnum[STRSZ(BFA_MFG_SERIALNUM_SIZE)];
393+
char brcd_partnum[STRSZ(BFA_MFG_PARTNUM_SIZE)];
394+
u8 mfg_day; /*!< manufacturing day */
395+
u8 mfg_month; /*!< manufacturing month */
396+
u16 mfg_year; /*!< manufacturing year */
397+
wwn_t mfg_wwn; /*!< wwn base for this adapter */
398+
u8 num_wwn; /*!< number of wwns assigned */
399+
u8 mfg_speeds; /*!< speeds allowed for this adapter */
400+
u8 rsv[2];
401+
char supplier_id[STRSZ(BFA_MFG_SUPPLIER_ID_SIZE)];
402+
char supplier_partnum[STRSZ(BFA_MFG_SUPPLIER_PARTNUM_SIZE)];
403+
char supplier_serialnum[STRSZ(BFA_MFG_SUPPLIER_SERIALNUM_SIZE)];
404+
char supplier_revision[STRSZ(BFA_MFG_SUPPLIER_REVISION_SIZE)];
405+
mac_t mfg_mac; /*!< base mac address */
406+
u8 num_mac; /*!< number of mac addresses */
407+
u8 rsv2;
408+
u32 card_type; /*!< card type */
409+
char cap_nic; /*!< capability nic */
410+
char cap_cna; /*!< capability cna */
411+
char cap_hba; /*!< capability hba */
412+
char cap_fc16g; /*!< capability fc 16g */
413+
char cap_sriov; /*!< capability sriov */
414+
char cap_mezz; /*!< capability mezz */
415+
u8 rsv3;
416+
u8 mfg_nports; /*!< number of ports */
417+
char media[8]; /*!< xfi/xaui */
418+
char initial_mode[8]; /*!< initial mode: hba/cna/nic */
419+
u8 rsv4[84];
420+
u8 md5_chksum[BFA_MFG_CHKSUM_SIZE]; /*!< md5 checksum */
412421
};
413422

414423
#pragma pack()
@@ -825,6 +834,53 @@ struct sfp_xcvr_s {
825834
union sfp_xcvr_fc3_code_u fc3;
826835
};
827836

837+
/*
838+
* Flash module specific
839+
*/
840+
#define BFA_FLASH_PART_ENTRY_SIZE 32 /* partition entry size */
841+
#define BFA_FLASH_PART_MAX 32 /* maximal # of partitions */
842+
843+
enum bfa_flash_part_type {
844+
BFA_FLASH_PART_OPTROM = 1, /* option rom partition */
845+
BFA_FLASH_PART_FWIMG = 2, /* firmware image partition */
846+
BFA_FLASH_PART_FWCFG = 3, /* firmware tuneable config */
847+
BFA_FLASH_PART_DRV = 4, /* IOC driver config */
848+
BFA_FLASH_PART_BOOT = 5, /* boot config */
849+
BFA_FLASH_PART_ASIC = 6, /* asic bootstrap configuration */
850+
BFA_FLASH_PART_MFG = 7, /* manufacturing block partition */
851+
BFA_FLASH_PART_OPTROM2 = 8, /* 2nd option rom partition */
852+
BFA_FLASH_PART_VPD = 9, /* vpd data of OEM info */
853+
BFA_FLASH_PART_PBC = 10, /* pre-boot config */
854+
BFA_FLASH_PART_BOOTOVL = 11, /* boot overlay partition */
855+
BFA_FLASH_PART_LOG = 12, /* firmware log partition */
856+
BFA_FLASH_PART_PXECFG = 13, /* pxe boot config partition */
857+
BFA_FLASH_PART_PXEOVL = 14, /* pxe boot overlay partition */
858+
BFA_FLASH_PART_PORTCFG = 15, /* port cfg partition */
859+
BFA_FLASH_PART_ASICBK = 16, /* asic backup partition */
860+
};
861+
862+
/*
863+
* flash partition attributes
864+
*/
865+
struct bfa_flash_part_attr_s {
866+
u32 part_type; /* partition type */
867+
u32 part_instance; /* partition instance */
868+
u32 part_off; /* partition offset */
869+
u32 part_size; /* partition size */
870+
u32 part_len; /* partition content length */
871+
u32 part_status; /* partition status */
872+
char rsv[BFA_FLASH_PART_ENTRY_SIZE - 24];
873+
};
874+
875+
/*
876+
* flash attributes
877+
*/
878+
struct bfa_flash_attr_s {
879+
u32 status; /* flash overall status */
880+
u32 npart; /* num of partitions */
881+
struct bfa_flash_part_attr_s part[BFA_FLASH_PART_MAX];
882+
};
883+
828884
#pragma pack()
829885

830886
#endif /* __BFA_DEFS_H__ */

0 commit comments

Comments
 (0)