diff mbox series

[v4,04/11] qla2xxx: Add more BUILD_BUG_ON() statements

Message ID 20200427030310.19687-5-bvanassche@acm.org (mailing list archive)
State Superseded
Headers show
Series Fix qla2xxx endianness annotations | expand

Commit Message

Bart Van Assche April 27, 2020, 3:03 a.m. UTC
Before fixing the endianness annotations in data structures, make the
compiler verify the size of FC protocol and firmware data structures.

Cc: Nilesh Javali <njavali@marvell.com>
Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
Cc: Quinn Tran <qutran@marvell.com>
Cc: Martin Wilck <mwilck@suse.com>
Cc: Daniel Wagner <dwagner@suse.de>
Cc: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla2xxx/qla_os.c      | 59 ++++++++++++++++++++++++++++++
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 14 +++++++
 2 files changed, 73 insertions(+)

Comments

Daniel Wagner April 27, 2020, 8:18 a.m. UTC | #1
On Sun, Apr 26, 2020 at 08:03:03PM -0700, Bart Van Assche wrote:
> Before fixing the endianness annotations in data structures, make the
> compiler verify the size of FC protocol and firmware data structures.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
> Cc: Quinn Tran <qutran@marvell.com>
> Cc: Martin Wilck <mwilck@suse.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

I don't have a manual to check it but this looks reasonable.

Reviewed-by: Daniel Wagner <dwagner@suse.de>
Himanshu Madhani April 27, 2020, 2:18 p.m. UTC | #2
On 4/26/20 10:03 PM, Bart Van Assche wrote:
> Before fixing the endianness annotations in data structures, make the
> compiler verify the size of FC protocol and firmware data structures.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
> Cc: Quinn Tran <qutran@marvell.com>
> Cc: Martin Wilck <mwilck@suse.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/qla2xxx/qla_os.c      | 59 ++++++++++++++++++++++++++++++
>   drivers/scsi/qla2xxx/tcm_qla2xxx.c | 14 +++++++
>   2 files changed, 73 insertions(+)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index 497544413aa0..2dd9c2a39cd5 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -7815,13 +7815,19 @@ qla2x00_module_init(void)
>   {
>   	int ret = 0;
>   
> +	BUILD_BUG_ON(sizeof(cmd_a64_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(cmd_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(cont_a64_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(cont_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(init_cb_t) != 96);
> +	BUILD_BUG_ON(sizeof(mrk_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(ms_iocb_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(request_t) != 64);
> +	BUILD_BUG_ON(sizeof(struct abort_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct abort_iocb_entry_fx00) != 64);
> +	BUILD_BUG_ON(sizeof(struct abts_entry_24xx) != 64);
>   	BUILD_BUG_ON(sizeof(struct access_chip_84xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct access_chip_rsp_84xx) != 64);
>   	BUILD_BUG_ON(sizeof(struct cmd_bidir) != 64);
>   	BUILD_BUG_ON(sizeof(struct cmd_nvme) != 64);
>   	BUILD_BUG_ON(sizeof(struct cmd_type_6) != 64);
> @@ -7829,17 +7835,70 @@ qla2x00_module_init(void)
>   	BUILD_BUG_ON(sizeof(struct cmd_type_7_fx00) != 64);
>   	BUILD_BUG_ON(sizeof(struct cmd_type_crc_2) != 64);
>   	BUILD_BUG_ON(sizeof(struct ct_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi1_hba_attributes) != 2344);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi2_hba_attributes) != 4424);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi2_port_attributes) != 4164);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi_hba_attr) != 260);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi_port_attr) != 260);
> +	BUILD_BUG_ON(sizeof(struct ct_rsp_hdr) != 16);
> +	BUILD_BUG_ON(sizeof(struct ct_sns_req) != 4460);
>   	BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct device_reg_24xx) != 256);
> +	BUILD_BUG_ON(sizeof(struct device_reg_25xxmq) != 24);
> +	BUILD_BUG_ON(sizeof(struct device_reg_2xxx) != 256);
> +	BUILD_BUG_ON(sizeof(struct device_reg_82xx) != 1288);
> +	BUILD_BUG_ON(sizeof(struct device_reg_fx00) != 216);
>   	BUILD_BUG_ON(sizeof(struct els_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct els_sts_entry_24xx) != 64);
>   	BUILD_BUG_ON(sizeof(struct fxdisc_entry_fx00) != 64);
> +	BUILD_BUG_ON(sizeof(struct imm_ntfy_from_isp) != 64);
>   	BUILD_BUG_ON(sizeof(struct init_cb_24xx) != 128);
>   	BUILD_BUG_ON(sizeof(struct init_cb_81xx) != 128);
> +	BUILD_BUG_ON(sizeof(struct logio_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct mbx_entry) != 64);
> +	BUILD_BUG_ON(sizeof(struct mid_init_cb_24xx) != 5252);
> +	BUILD_BUG_ON(sizeof(struct mrk_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvram_24xx) != 512);
> +	BUILD_BUG_ON(sizeof(struct nvram_81xx) != 512);
>   	BUILD_BUG_ON(sizeof(struct pt_ls4_request) != 64);
> +	BUILD_BUG_ON(sizeof(struct pt_ls4_rx_unsol) != 64);
> +	BUILD_BUG_ON(sizeof(struct purex_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct qla2100_fw_dump) != 123634);
> +	BUILD_BUG_ON(sizeof(struct qla2300_fw_dump) != 136100);
> +	BUILD_BUG_ON(sizeof(struct qla24xx_fw_dump) != 37976);
> +	BUILD_BUG_ON(sizeof(struct qla25xx_fw_dump) != 39228);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_fce_chain) != 52);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_fw_dump) != 136172);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_mq_chain) != 524);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_mqueue_chain) != 8);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_mqueue_header) != 12);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_offld_chain) != 24);
> +	BUILD_BUG_ON(sizeof(struct qla81xx_fw_dump) != 39420);
> +	BUILD_BUG_ON(sizeof(struct qla82xx_uri_data_desc) != 28);
> +	BUILD_BUG_ON(sizeof(struct qla82xx_uri_table_desc) != 32);
> +	BUILD_BUG_ON(sizeof(struct qla83xx_fw_dump) != 51196);
> +	BUILD_BUG_ON(sizeof(struct qla_fdt_layout) != 128);
>   	BUILD_BUG_ON(sizeof(struct qla_flt_header) != 8);
>   	BUILD_BUG_ON(sizeof(struct qla_flt_region) != 16);
> +	BUILD_BUG_ON(sizeof(struct qla_npiv_entry) != 24);
> +	BUILD_BUG_ON(sizeof(struct qla_npiv_header) != 16);
> +	BUILD_BUG_ON(sizeof(struct rdp_rsp_payload) != 336);
>   	BUILD_BUG_ON(sizeof(struct sns_cmd_pkt) != 2064);
> +	BUILD_BUG_ON(sizeof(struct sts_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct tsk_mgmt_entry) != 64);
> +	BUILD_BUG_ON(sizeof(struct tsk_mgmt_entry_fx00) != 64);
>   	BUILD_BUG_ON(sizeof(struct verify_chip_entry_84xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct verify_chip_rsp_84xx) != 52);
>   	BUILD_BUG_ON(sizeof(struct vf_evfp_entry_24xx) != 56);
> +	BUILD_BUG_ON(sizeof(struct vp_config_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct vp_ctrl_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct vp_rpt_id_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(sts21_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sts22_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sts_cont_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sts_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sw_info_t) != 32);
> +	BUILD_BUG_ON(sizeof(target_id_t) != 2);
>   
>   	/* Allocate cache for SRBs. */
>   	srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
> diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> index 1f0a185b2a95..92e1a5d3928b 100644
> --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> @@ -1958,6 +1958,20 @@ static int __init tcm_qla2xxx_init(void)
>   {
>   	int ret;
>   
> +	BUILD_BUG_ON(sizeof(struct abts_recv_from_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct abts_resp_from_24xx_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct atio7_fcp_cmnd) != 32);
> +	BUILD_BUG_ON(sizeof(struct atio_from_isp) != 64);
> +	BUILD_BUG_ON(sizeof(struct ba_acc_le) != 12);
> +	BUILD_BUG_ON(sizeof(struct ba_rjt_le) != 4);
> +	BUILD_BUG_ON(sizeof(struct ctio7_from_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio7_to_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio_crc_from_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio_to_2xxx) != 64);
> +	BUILD_BUG_ON(sizeof(struct fcp_hdr_le) != 24);
> +	BUILD_BUG_ON(sizeof(struct nack_to_isp) != 64);
> +
>   	ret = tcm_qla2xxx_register_configfs();
>   	if (ret < 0)
>   		return ret;
> 

Looks fine.

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
Hannes Reinecke May 6, 2020, 1:42 p.m. UTC | #3
On 4/27/20 5:03 AM, Bart Van Assche wrote:
> Before fixing the endianness annotations in data structures, make the
> compiler verify the size of FC protocol and firmware data structures.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
> Cc: Quinn Tran <qutran@marvell.com>
> Cc: Martin Wilck <mwilck@suse.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   drivers/scsi/qla2xxx/qla_os.c      | 59 ++++++++++++++++++++++++++++++
>   drivers/scsi/qla2xxx/tcm_qla2xxx.c | 14 +++++++
>   2 files changed, 73 insertions(+)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index 497544413aa0..2dd9c2a39cd5 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -7815,13 +7815,19 @@ qla2x00_module_init(void)
>   {
>   	int ret = 0;
>   
> +	BUILD_BUG_ON(sizeof(cmd_a64_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(cmd_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(cont_a64_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(cont_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(init_cb_t) != 96);
> +	BUILD_BUG_ON(sizeof(mrk_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(ms_iocb_entry_t) != 64);
>   	BUILD_BUG_ON(sizeof(request_t) != 64);
> +	BUILD_BUG_ON(sizeof(struct abort_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct abort_iocb_entry_fx00) != 64);
> +	BUILD_BUG_ON(sizeof(struct abts_entry_24xx) != 64);
>   	BUILD_BUG_ON(sizeof(struct access_chip_84xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct access_chip_rsp_84xx) != 64);
>   	BUILD_BUG_ON(sizeof(struct cmd_bidir) != 64);
>   	BUILD_BUG_ON(sizeof(struct cmd_nvme) != 64);
>   	BUILD_BUG_ON(sizeof(struct cmd_type_6) != 64);
> @@ -7829,17 +7835,70 @@ qla2x00_module_init(void)
>   	BUILD_BUG_ON(sizeof(struct cmd_type_7_fx00) != 64);
>   	BUILD_BUG_ON(sizeof(struct cmd_type_crc_2) != 64);
>   	BUILD_BUG_ON(sizeof(struct ct_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi1_hba_attributes) != 2344);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi2_hba_attributes) != 4424);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi2_port_attributes) != 4164);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi_hba_attr) != 260);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi_port_attr) != 260);
> +	BUILD_BUG_ON(sizeof(struct ct_rsp_hdr) != 16);
> +	BUILD_BUG_ON(sizeof(struct ct_sns_req) != 4460);
>   	BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct device_reg_24xx) != 256);
> +	BUILD_BUG_ON(sizeof(struct device_reg_25xxmq) != 24);
> +	BUILD_BUG_ON(sizeof(struct device_reg_2xxx) != 256);
> +	BUILD_BUG_ON(sizeof(struct device_reg_82xx) != 1288);
> +	BUILD_BUG_ON(sizeof(struct device_reg_fx00) != 216);
>   	BUILD_BUG_ON(sizeof(struct els_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct els_sts_entry_24xx) != 64);
>   	BUILD_BUG_ON(sizeof(struct fxdisc_entry_fx00) != 64);
> +	BUILD_BUG_ON(sizeof(struct imm_ntfy_from_isp) != 64);
>   	BUILD_BUG_ON(sizeof(struct init_cb_24xx) != 128);
>   	BUILD_BUG_ON(sizeof(struct init_cb_81xx) != 128);
> +	BUILD_BUG_ON(sizeof(struct logio_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct mbx_entry) != 64);
> +	BUILD_BUG_ON(sizeof(struct mid_init_cb_24xx) != 5252);
> +	BUILD_BUG_ON(sizeof(struct mrk_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvram_24xx) != 512);
> +	BUILD_BUG_ON(sizeof(struct nvram_81xx) != 512);
>   	BUILD_BUG_ON(sizeof(struct pt_ls4_request) != 64);
> +	BUILD_BUG_ON(sizeof(struct pt_ls4_rx_unsol) != 64);
> +	BUILD_BUG_ON(sizeof(struct purex_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct qla2100_fw_dump) != 123634);
> +	BUILD_BUG_ON(sizeof(struct qla2300_fw_dump) != 136100);
> +	BUILD_BUG_ON(sizeof(struct qla24xx_fw_dump) != 37976);
> +	BUILD_BUG_ON(sizeof(struct qla25xx_fw_dump) != 39228);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_fce_chain) != 52);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_fw_dump) != 136172);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_mq_chain) != 524);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_mqueue_chain) != 8);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_mqueue_header) != 12);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_offld_chain) != 24);
> +	BUILD_BUG_ON(sizeof(struct qla81xx_fw_dump) != 39420);
> +	BUILD_BUG_ON(sizeof(struct qla82xx_uri_data_desc) != 28);
> +	BUILD_BUG_ON(sizeof(struct qla82xx_uri_table_desc) != 32);
> +	BUILD_BUG_ON(sizeof(struct qla83xx_fw_dump) != 51196);
> +	BUILD_BUG_ON(sizeof(struct qla_fdt_layout) != 128);
>   	BUILD_BUG_ON(sizeof(struct qla_flt_header) != 8);
>   	BUILD_BUG_ON(sizeof(struct qla_flt_region) != 16);
> +	BUILD_BUG_ON(sizeof(struct qla_npiv_entry) != 24);
> +	BUILD_BUG_ON(sizeof(struct qla_npiv_header) != 16);
> +	BUILD_BUG_ON(sizeof(struct rdp_rsp_payload) != 336);
>   	BUILD_BUG_ON(sizeof(struct sns_cmd_pkt) != 2064);
> +	BUILD_BUG_ON(sizeof(struct sts_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct tsk_mgmt_entry) != 64);
> +	BUILD_BUG_ON(sizeof(struct tsk_mgmt_entry_fx00) != 64);
>   	BUILD_BUG_ON(sizeof(struct verify_chip_entry_84xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct verify_chip_rsp_84xx) != 52);
>   	BUILD_BUG_ON(sizeof(struct vf_evfp_entry_24xx) != 56);
> +	BUILD_BUG_ON(sizeof(struct vp_config_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct vp_ctrl_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct vp_rpt_id_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(sts21_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sts22_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sts_cont_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sts_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sw_info_t) != 32);
> +	BUILD_BUG_ON(sizeof(target_id_t) != 2);
>   
>   	/* Allocate cache for SRBs. */
>   	srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
> diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> index 1f0a185b2a95..92e1a5d3928b 100644
> --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> @@ -1958,6 +1958,20 @@ static int __init tcm_qla2xxx_init(void)
>   {
>   	int ret;
>   
> +	BUILD_BUG_ON(sizeof(struct abts_recv_from_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct abts_resp_from_24xx_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct atio7_fcp_cmnd) != 32);
> +	BUILD_BUG_ON(sizeof(struct atio_from_isp) != 64);
> +	BUILD_BUG_ON(sizeof(struct ba_acc_le) != 12);
> +	BUILD_BUG_ON(sizeof(struct ba_rjt_le) != 4);
> +	BUILD_BUG_ON(sizeof(struct ctio7_from_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio7_to_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio_crc_from_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio_to_2xxx) != 64);
> +	BUILD_BUG_ON(sizeof(struct fcp_hdr_le) != 24);
> +	BUILD_BUG_ON(sizeof(struct nack_to_isp) != 64);
> +
>   	ret = tcm_qla2xxx_register_configfs();
>   	if (ret < 0)
>   		return ret;
> 
Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
Arun Easi May 11, 2020, 7:34 a.m. UTC | #4
On Sun, 26 Apr 2020, 8:03pm, Bart Van Assche wrote:
>
> Before fixing the endianness annotations in data structures, make the
> compiler verify the size of FC protocol and firmware data structures.
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
> Cc: Quinn Tran <qutran@marvell.com>
> Cc: Martin Wilck <mwilck@suse.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/qla2xxx/qla_os.c      | 59 ++++++++++++++++++++++++++++++
>  drivers/scsi/qla2xxx/tcm_qla2xxx.c | 14 +++++++
>  2 files changed, 73 insertions(+)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index 497544413aa0..2dd9c2a39cd5 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -7815,13 +7815,19 @@ qla2x00_module_init(void)
>  {
>  	int ret = 0;
>  
> +	BUILD_BUG_ON(sizeof(cmd_a64_entry_t) != 64);
>  	BUILD_BUG_ON(sizeof(cmd_entry_t) != 64);
>  	BUILD_BUG_ON(sizeof(cont_a64_entry_t) != 64);
>  	BUILD_BUG_ON(sizeof(cont_entry_t) != 64);
>  	BUILD_BUG_ON(sizeof(init_cb_t) != 96);
> +	BUILD_BUG_ON(sizeof(mrk_entry_t) != 64);
>  	BUILD_BUG_ON(sizeof(ms_iocb_entry_t) != 64);
>  	BUILD_BUG_ON(sizeof(request_t) != 64);
> +	BUILD_BUG_ON(sizeof(struct abort_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct abort_iocb_entry_fx00) != 64);
> +	BUILD_BUG_ON(sizeof(struct abts_entry_24xx) != 64);
>  	BUILD_BUG_ON(sizeof(struct access_chip_84xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct access_chip_rsp_84xx) != 64);
>  	BUILD_BUG_ON(sizeof(struct cmd_bidir) != 64);
>  	BUILD_BUG_ON(sizeof(struct cmd_nvme) != 64);
>  	BUILD_BUG_ON(sizeof(struct cmd_type_6) != 64);
> @@ -7829,17 +7835,70 @@ qla2x00_module_init(void)
>  	BUILD_BUG_ON(sizeof(struct cmd_type_7_fx00) != 64);
>  	BUILD_BUG_ON(sizeof(struct cmd_type_crc_2) != 64);
>  	BUILD_BUG_ON(sizeof(struct ct_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi1_hba_attributes) != 2344);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi2_hba_attributes) != 4424);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi2_port_attributes) != 4164);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi_hba_attr) != 260);
> +	BUILD_BUG_ON(sizeof(struct ct_fdmi_port_attr) != 260);
> +	BUILD_BUG_ON(sizeof(struct ct_rsp_hdr) != 16);
> +	BUILD_BUG_ON(sizeof(struct ct_sns_req) != 4460);
>  	BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct device_reg_24xx) != 256);
> +	BUILD_BUG_ON(sizeof(struct device_reg_25xxmq) != 24);
> +	BUILD_BUG_ON(sizeof(struct device_reg_2xxx) != 256);
> +	BUILD_BUG_ON(sizeof(struct device_reg_82xx) != 1288);
> +	BUILD_BUG_ON(sizeof(struct device_reg_fx00) != 216);
>  	BUILD_BUG_ON(sizeof(struct els_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct els_sts_entry_24xx) != 64);
>  	BUILD_BUG_ON(sizeof(struct fxdisc_entry_fx00) != 64);
> +	BUILD_BUG_ON(sizeof(struct imm_ntfy_from_isp) != 64);
>  	BUILD_BUG_ON(sizeof(struct init_cb_24xx) != 128);
>  	BUILD_BUG_ON(sizeof(struct init_cb_81xx) != 128);
> +	BUILD_BUG_ON(sizeof(struct logio_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct mbx_entry) != 64);
> +	BUILD_BUG_ON(sizeof(struct mid_init_cb_24xx) != 5252);
> +	BUILD_BUG_ON(sizeof(struct mrk_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct nvram_24xx) != 512);
> +	BUILD_BUG_ON(sizeof(struct nvram_81xx) != 512);
>  	BUILD_BUG_ON(sizeof(struct pt_ls4_request) != 64);
> +	BUILD_BUG_ON(sizeof(struct pt_ls4_rx_unsol) != 64);
> +	BUILD_BUG_ON(sizeof(struct purex_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct qla2100_fw_dump) != 123634);
> +	BUILD_BUG_ON(sizeof(struct qla2300_fw_dump) != 136100);
> +	BUILD_BUG_ON(sizeof(struct qla24xx_fw_dump) != 37976);
> +	BUILD_BUG_ON(sizeof(struct qla25xx_fw_dump) != 39228);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_fce_chain) != 52);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_fw_dump) != 136172);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_mq_chain) != 524);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_mqueue_chain) != 8);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_mqueue_header) != 12);
> +	BUILD_BUG_ON(sizeof(struct qla2xxx_offld_chain) != 24);
> +	BUILD_BUG_ON(sizeof(struct qla81xx_fw_dump) != 39420);
> +	BUILD_BUG_ON(sizeof(struct qla82xx_uri_data_desc) != 28);
> +	BUILD_BUG_ON(sizeof(struct qla82xx_uri_table_desc) != 32);
> +	BUILD_BUG_ON(sizeof(struct qla83xx_fw_dump) != 51196);
> +	BUILD_BUG_ON(sizeof(struct qla_fdt_layout) != 128);
>  	BUILD_BUG_ON(sizeof(struct qla_flt_header) != 8);
>  	BUILD_BUG_ON(sizeof(struct qla_flt_region) != 16);
> +	BUILD_BUG_ON(sizeof(struct qla_npiv_entry) != 24);
> +	BUILD_BUG_ON(sizeof(struct qla_npiv_header) != 16);
> +	BUILD_BUG_ON(sizeof(struct rdp_rsp_payload) != 336);
>  	BUILD_BUG_ON(sizeof(struct sns_cmd_pkt) != 2064);
> +	BUILD_BUG_ON(sizeof(struct sts_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct tsk_mgmt_entry) != 64);
> +	BUILD_BUG_ON(sizeof(struct tsk_mgmt_entry_fx00) != 64);
>  	BUILD_BUG_ON(sizeof(struct verify_chip_entry_84xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct verify_chip_rsp_84xx) != 52);
>  	BUILD_BUG_ON(sizeof(struct vf_evfp_entry_24xx) != 56);
> +	BUILD_BUG_ON(sizeof(struct vp_config_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct vp_ctrl_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct vp_rpt_id_entry_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(sts21_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sts22_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sts_cont_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sts_entry_t) != 64);
> +	BUILD_BUG_ON(sizeof(sw_info_t) != 32);
> +	BUILD_BUG_ON(sizeof(target_id_t) != 2);
>  
>  	/* Allocate cache for SRBs. */
>  	srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
> diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> index 1f0a185b2a95..92e1a5d3928b 100644
> --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
> @@ -1958,6 +1958,20 @@ static int __init tcm_qla2xxx_init(void)
>  {
>  	int ret;
>  
> +	BUILD_BUG_ON(sizeof(struct abts_recv_from_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct abts_resp_from_24xx_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct atio7_fcp_cmnd) != 32);
> +	BUILD_BUG_ON(sizeof(struct atio_from_isp) != 64);
> +	BUILD_BUG_ON(sizeof(struct ba_acc_le) != 12);
> +	BUILD_BUG_ON(sizeof(struct ba_rjt_le) != 4);
> +	BUILD_BUG_ON(sizeof(struct ctio7_from_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio7_to_24xx) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio_crc_from_fw) != 64);
> +	BUILD_BUG_ON(sizeof(struct ctio_to_2xxx) != 64);
> +	BUILD_BUG_ON(sizeof(struct fcp_hdr_le) != 24);
> +	BUILD_BUG_ON(sizeof(struct nack_to_isp) != 64);
> +
>  	ret = tcm_qla2xxx_register_configfs();
>  	if (ret < 0)
>  		return ret;

How did you pick the list of structures for this one? IOCB
structures make sense, but why "ct_sns_req", for e.g.? Adding
support for a different request may alter the structure size.

Wondering what made you add all these checks? Anything tripped
while making some changes?
Bart Van Assche May 11, 2020, 3:55 p.m. UTC | #5
On 2020-05-11 00:34, Arun Easi wrote:
> How did you pick the list of structures for this one? IOCB
> structures make sense, but why "ct_sns_req", for e.g.? Adding
> support for a different request may alter the structure size.
> 
> Wondering what made you add all these checks? Anything tripped
> while making some changes?

Hi Arun,

For this patch I selected all data structures that have one or more
little endian or big endian members. Such data structures either are
used to interface with the firmware or represent FC frame information. I
agree that struct ct_sns_req is special. I will leave the size check for
that data structure out when I repost this patch series.

Bart.
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 497544413aa0..2dd9c2a39cd5 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -7815,13 +7815,19 @@  qla2x00_module_init(void)
 {
 	int ret = 0;
 
+	BUILD_BUG_ON(sizeof(cmd_a64_entry_t) != 64);
 	BUILD_BUG_ON(sizeof(cmd_entry_t) != 64);
 	BUILD_BUG_ON(sizeof(cont_a64_entry_t) != 64);
 	BUILD_BUG_ON(sizeof(cont_entry_t) != 64);
 	BUILD_BUG_ON(sizeof(init_cb_t) != 96);
+	BUILD_BUG_ON(sizeof(mrk_entry_t) != 64);
 	BUILD_BUG_ON(sizeof(ms_iocb_entry_t) != 64);
 	BUILD_BUG_ON(sizeof(request_t) != 64);
+	BUILD_BUG_ON(sizeof(struct abort_entry_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct abort_iocb_entry_fx00) != 64);
+	BUILD_BUG_ON(sizeof(struct abts_entry_24xx) != 64);
 	BUILD_BUG_ON(sizeof(struct access_chip_84xx) != 64);
+	BUILD_BUG_ON(sizeof(struct access_chip_rsp_84xx) != 64);
 	BUILD_BUG_ON(sizeof(struct cmd_bidir) != 64);
 	BUILD_BUG_ON(sizeof(struct cmd_nvme) != 64);
 	BUILD_BUG_ON(sizeof(struct cmd_type_6) != 64);
@@ -7829,17 +7835,70 @@  qla2x00_module_init(void)
 	BUILD_BUG_ON(sizeof(struct cmd_type_7_fx00) != 64);
 	BUILD_BUG_ON(sizeof(struct cmd_type_crc_2) != 64);
 	BUILD_BUG_ON(sizeof(struct ct_entry_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct ct_fdmi1_hba_attributes) != 2344);
+	BUILD_BUG_ON(sizeof(struct ct_fdmi2_hba_attributes) != 4424);
+	BUILD_BUG_ON(sizeof(struct ct_fdmi2_port_attributes) != 4164);
+	BUILD_BUG_ON(sizeof(struct ct_fdmi_hba_attr) != 260);
+	BUILD_BUG_ON(sizeof(struct ct_fdmi_port_attr) != 260);
+	BUILD_BUG_ON(sizeof(struct ct_rsp_hdr) != 16);
+	BUILD_BUG_ON(sizeof(struct ct_sns_req) != 4460);
 	BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64);
+	BUILD_BUG_ON(sizeof(struct device_reg_24xx) != 256);
+	BUILD_BUG_ON(sizeof(struct device_reg_25xxmq) != 24);
+	BUILD_BUG_ON(sizeof(struct device_reg_2xxx) != 256);
+	BUILD_BUG_ON(sizeof(struct device_reg_82xx) != 1288);
+	BUILD_BUG_ON(sizeof(struct device_reg_fx00) != 216);
 	BUILD_BUG_ON(sizeof(struct els_entry_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct els_sts_entry_24xx) != 64);
 	BUILD_BUG_ON(sizeof(struct fxdisc_entry_fx00) != 64);
+	BUILD_BUG_ON(sizeof(struct imm_ntfy_from_isp) != 64);
 	BUILD_BUG_ON(sizeof(struct init_cb_24xx) != 128);
 	BUILD_BUG_ON(sizeof(struct init_cb_81xx) != 128);
+	BUILD_BUG_ON(sizeof(struct logio_entry_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct mbx_entry) != 64);
+	BUILD_BUG_ON(sizeof(struct mid_init_cb_24xx) != 5252);
+	BUILD_BUG_ON(sizeof(struct mrk_entry_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct nvram_24xx) != 512);
+	BUILD_BUG_ON(sizeof(struct nvram_81xx) != 512);
 	BUILD_BUG_ON(sizeof(struct pt_ls4_request) != 64);
+	BUILD_BUG_ON(sizeof(struct pt_ls4_rx_unsol) != 64);
+	BUILD_BUG_ON(sizeof(struct purex_entry_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct qla2100_fw_dump) != 123634);
+	BUILD_BUG_ON(sizeof(struct qla2300_fw_dump) != 136100);
+	BUILD_BUG_ON(sizeof(struct qla24xx_fw_dump) != 37976);
+	BUILD_BUG_ON(sizeof(struct qla25xx_fw_dump) != 39228);
+	BUILD_BUG_ON(sizeof(struct qla2xxx_fce_chain) != 52);
+	BUILD_BUG_ON(sizeof(struct qla2xxx_fw_dump) != 136172);
+	BUILD_BUG_ON(sizeof(struct qla2xxx_mq_chain) != 524);
+	BUILD_BUG_ON(sizeof(struct qla2xxx_mqueue_chain) != 8);
+	BUILD_BUG_ON(sizeof(struct qla2xxx_mqueue_header) != 12);
+	BUILD_BUG_ON(sizeof(struct qla2xxx_offld_chain) != 24);
+	BUILD_BUG_ON(sizeof(struct qla81xx_fw_dump) != 39420);
+	BUILD_BUG_ON(sizeof(struct qla82xx_uri_data_desc) != 28);
+	BUILD_BUG_ON(sizeof(struct qla82xx_uri_table_desc) != 32);
+	BUILD_BUG_ON(sizeof(struct qla83xx_fw_dump) != 51196);
+	BUILD_BUG_ON(sizeof(struct qla_fdt_layout) != 128);
 	BUILD_BUG_ON(sizeof(struct qla_flt_header) != 8);
 	BUILD_BUG_ON(sizeof(struct qla_flt_region) != 16);
+	BUILD_BUG_ON(sizeof(struct qla_npiv_entry) != 24);
+	BUILD_BUG_ON(sizeof(struct qla_npiv_header) != 16);
+	BUILD_BUG_ON(sizeof(struct rdp_rsp_payload) != 336);
 	BUILD_BUG_ON(sizeof(struct sns_cmd_pkt) != 2064);
+	BUILD_BUG_ON(sizeof(struct sts_entry_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct tsk_mgmt_entry) != 64);
+	BUILD_BUG_ON(sizeof(struct tsk_mgmt_entry_fx00) != 64);
 	BUILD_BUG_ON(sizeof(struct verify_chip_entry_84xx) != 64);
+	BUILD_BUG_ON(sizeof(struct verify_chip_rsp_84xx) != 52);
 	BUILD_BUG_ON(sizeof(struct vf_evfp_entry_24xx) != 56);
+	BUILD_BUG_ON(sizeof(struct vp_config_entry_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct vp_ctrl_entry_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct vp_rpt_id_entry_24xx) != 64);
+	BUILD_BUG_ON(sizeof(sts21_entry_t) != 64);
+	BUILD_BUG_ON(sizeof(sts22_entry_t) != 64);
+	BUILD_BUG_ON(sizeof(sts_cont_entry_t) != 64);
+	BUILD_BUG_ON(sizeof(sts_entry_t) != 64);
+	BUILD_BUG_ON(sizeof(sw_info_t) != 32);
+	BUILD_BUG_ON(sizeof(target_id_t) != 2);
 
 	/* Allocate cache for SRBs. */
 	srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 1f0a185b2a95..92e1a5d3928b 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -1958,6 +1958,20 @@  static int __init tcm_qla2xxx_init(void)
 {
 	int ret;
 
+	BUILD_BUG_ON(sizeof(struct abts_recv_from_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct abts_resp_from_24xx_fw) != 64);
+	BUILD_BUG_ON(sizeof(struct atio7_fcp_cmnd) != 32);
+	BUILD_BUG_ON(sizeof(struct atio_from_isp) != 64);
+	BUILD_BUG_ON(sizeof(struct ba_acc_le) != 12);
+	BUILD_BUG_ON(sizeof(struct ba_rjt_le) != 4);
+	BUILD_BUG_ON(sizeof(struct ctio7_from_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct ctio7_to_24xx) != 64);
+	BUILD_BUG_ON(sizeof(struct ctio_crc2_to_fw) != 64);
+	BUILD_BUG_ON(sizeof(struct ctio_crc_from_fw) != 64);
+	BUILD_BUG_ON(sizeof(struct ctio_to_2xxx) != 64);
+	BUILD_BUG_ON(sizeof(struct fcp_hdr_le) != 24);
+	BUILD_BUG_ON(sizeof(struct nack_to_isp) != 64);
+
 	ret = tcm_qla2xxx_register_configfs();
 	if (ret < 0)
 		return ret;