Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update qla2x00t-32gbit to Linux Kernel v6.6 (Part 2) #197

Merged
merged 11 commits into from
Oct 10, 2023
2 changes: 0 additions & 2 deletions qla2x00t-32gbit/qla_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3164,8 +3164,6 @@ qla24xx_vport_create(struct fc_vport *fc_vport, bool disable)
vha->flags.difdix_supported = 1;
ql_dbg(ql_dbg_user, vha, 0x7082,
"Registered for DIF/DIX type 1 and 3 protection.\n");
if (ql2xenabledif == 1)
prot = SHOST_DIX_TYPE0_PROTECTION;
scsi_host_set_prot(vha->host,
prot | SHOST_DIF_TYPE1_PROTECTION
| SHOST_DIF_TYPE2_PROTECTION
Expand Down
2 changes: 1 addition & 1 deletion qla2x00t-32gbit/qla_dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* | Queue Command and IO tracing | 0x3074 | 0x300b |
* | | | 0x3027-0x3028 |
* | | | 0x303d-0x3041 |
* | | | 0x302d,0x3033 |
* | | | 0x302e,0x3033 |
* | | | 0x3036,0x3038 |
* | | | 0x303a |
* | DPC Thread | 0x4023 | 0x4002,0x4013 |
Expand Down
23 changes: 17 additions & 6 deletions qla2x00t-32gbit/qla_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -3794,6 +3794,16 @@ struct qla_fw_resources {
u16 pad;
};

struct qla_fw_res {
u16 iocb_total;
u16 iocb_limit;
atomic_t iocb_used;

u16 exch_total;
u16 exch_limit;
atomic_t exch_used;
};

#define QLA_IOCB_PCT_LIMIT 95

struct qla_buf_pool {
Expand Down Expand Up @@ -3839,6 +3849,12 @@ struct qla_qpair {

uint16_t id; /* qp number used with FW */
uint16_t vp_idx; /* vport ID */

uint16_t dsd_inuse;
uint16_t dsd_avail;
struct list_head dsd_list;
#define NUM_DSD_CHAIN 4096

mempool_t *srb_mempool;

struct pci_dev *pdev;
Expand Down Expand Up @@ -4436,7 +4452,6 @@ struct qla_hw_data {
uint8_t aen_mbx_count;
atomic_t num_pend_mbx_stage1;
atomic_t num_pend_mbx_stage2;
atomic_t num_pend_mbx_stage3;
uint16_t frame_payload_size;

uint32_t login_retry_count;
Expand Down Expand Up @@ -4766,11 +4781,6 @@ struct qla_hw_data {
struct fw_blob *hablob;
struct qla82xx_legacy_intr_set nx_legacy_intr;

uint16_t gbl_dsd_inuse;
uint16_t gbl_dsd_avail;
struct list_head gbl_dsd_list;
#define NUM_DSD_CHAIN 4096

uint8_t fw_type;
uint32_t file_prd_off; /* File firmware product offset */

Expand Down Expand Up @@ -4852,6 +4862,7 @@ struct qla_hw_data {
struct els_reject elsrej;
u8 edif_post_stop_cnt_down;
struct qla_vp_map *vp_map;
struct qla_fw_res fwres ____cacheline_aligned;
};

#define RX_ELS_SIZE (roundup(sizeof(struct enode) + ELS_MAX_PAYLOAD, SMP_CACHE_BYTES))
Expand Down
10 changes: 10 additions & 0 deletions qla2x00t-32gbit/qla_dfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused)

seq_printf(s, "estimate exchange used[%d] high water limit [%d] n",
exch_used, ha->base_qpair->fwres.exch_limit);

if (ql2xenforce_iocb_limit == 2) {
iocbs_used = atomic_read(&ha->fwres.iocb_used);
exch_used = atomic_read(&ha->fwres.exch_used);
seq_printf(s, " estimate iocb2 used [%d] high water limit [%d]\n",
iocbs_used, ha->fwres.iocb_limit);

seq_printf(s, " estimate exchange2 used[%d] high water limit [%d] \n",
exch_used, ha->fwres.exch_limit);
}
}

return 0;
Expand Down
10 changes: 0 additions & 10 deletions qla2x00t-32gbit/qla_gbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ extern int qla24xx_els_dcmd2_iocb(scsi_qla_host_t *, int, fc_port_t *, bool);
extern void qla2x00_els_dcmd2_free(scsi_qla_host_t *vha,
struct els_plogi *els_plogi);

extern void qla2x00_update_fcports(scsi_qla_host_t *);

extern int qla2x00_abort_isp(scsi_qla_host_t *);
extern void qla2x00_abort_isp_cleanup(scsi_qla_host_t *);
extern void qla2x00_quiesce_io(scsi_qla_host_t *);
Expand Down Expand Up @@ -212,8 +210,6 @@ extern int qla2x00_post_async_logout_work(struct scsi_qla_host *, fc_port_t *,
uint16_t *);
extern int qla2x00_post_async_adisc_work(struct scsi_qla_host *, fc_port_t *,
uint16_t *);
extern int qla2x00_post_async_adisc_done_work(struct scsi_qla_host *,
fc_port_t *, uint16_t *);
extern int qla2x00_set_exlogins_buffer(struct scsi_qla_host *);
extern void qla2x00_free_exlogin_buffer(struct qla_hw_data *);
extern int qla2x00_set_exchoffld_buffer(struct scsi_qla_host *);
Expand All @@ -223,7 +219,6 @@ extern int qla81xx_restart_mpi_firmware(scsi_qla_host_t *);

extern struct scsi_qla_host *qla2x00_create_host(const struct scsi_host_template *,
struct qla_hw_data *);
extern void qla2x00_free_host(struct scsi_qla_host *);
extern void qla2x00_relogin(struct scsi_qla_host *);
extern void qla2x00_do_work(struct scsi_qla_host *);
extern void qla2x00_free_fcports(struct scsi_qla_host *);
Expand All @@ -245,13 +240,10 @@ extern int __qla83xx_clear_drv_presence(scsi_qla_host_t *vha);

extern int qla2x00_post_uevent_work(struct scsi_qla_host *, u32);
extern void qla2x00_disable_board_on_pci_error(struct work_struct *);
extern void qla_eeh_work(struct work_struct *);
extern void qla2x00_sp_compl(srb_t *sp, int);
extern void qla2xxx_qpair_sp_free_dma(srb_t *sp);
extern void qla2xxx_qpair_sp_compl(srb_t *sp, int);
extern void qla24xx_sched_upd_fcport(fc_port_t *);
void qla2x00_handle_login_done_event(struct scsi_qla_host *, fc_port_t *,
uint16_t *);
int qla24xx_post_gnl_work(struct scsi_qla_host *, fc_port_t *);
int qla24xx_post_relogin_work(struct scsi_qla_host *vha);
void qla2x00_wait_for_sess_deletion(scsi_qla_host_t *);
Expand Down Expand Up @@ -735,7 +727,6 @@ int qla24xx_post_gpsc_work(struct scsi_qla_host *, fc_port_t *);
int qla24xx_async_gpsc(scsi_qla_host_t *, fc_port_t *);
void qla24xx_handle_gpsc_event(scsi_qla_host_t *, struct event_arg *);
int qla2x00_mgmt_svr_login(scsi_qla_host_t *);
void qla24xx_handle_gffid_event(scsi_qla_host_t *vha, struct event_arg *ea);
int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport, bool);
int qla24xx_async_gpnft(scsi_qla_host_t *, u8, srb_t *);
void qla24xx_async_gpnft_done(scsi_qla_host_t *, srb_t *);
Expand Down Expand Up @@ -865,7 +856,6 @@ extern void qla2x00_start_iocbs(struct scsi_qla_host *, struct req_que *);

/* Interrupt related */
extern irqreturn_t qla82xx_intr_handler(int, void *);
extern irqreturn_t qla82xx_msi_handler(int, void *);
extern irqreturn_t qla82xx_msix_default(int, void *);
extern irqreturn_t qla82xx_msix_rsp_q(int, void *);
extern void qla82xx_enable_intrs(struct qla_hw_data *);
Expand Down
35 changes: 30 additions & 5 deletions qla2x00t-32gbit/qla_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -2223,6 +2223,8 @@ __qla2x00_async_tm_cmd(struct tmf_arg *arg)
rval = QLA_FUNCTION_FAILED;
}
}
if (tm_iocb->u.tmf.data)
rval = tm_iocb->u.tmf.data;

done_free_sp:
/* ref: INIT */
Expand Down Expand Up @@ -4206,7 +4208,7 @@ void qla_init_iocb_limit(scsi_qla_host_t *vha)
u8 i;
struct qla_hw_data *ha = vha->hw;

__qla_adjust_iocb_limit(ha->base_qpair);
__qla_adjust_iocb_limit(ha->base_qpair);
ha->base_qpair->fwres.iocbs_used = 0;
ha->base_qpair->fwres.exch_used = 0;

Expand All @@ -4217,6 +4219,14 @@ void qla_init_iocb_limit(scsi_qla_host_t *vha)
ha->queue_pair_map[i]->fwres.exch_used = 0;
}
}

ha->fwres.iocb_total = ha->orig_fw_iocb_count;
ha->fwres.iocb_limit = (ha->orig_fw_iocb_count * QLA_IOCB_PCT_LIMIT) / 100;
ha->fwres.exch_total = ha->orig_fw_xcb_count;
ha->fwres.exch_limit = (ha->orig_fw_xcb_count * QLA_IOCB_PCT_LIMIT) / 100;

atomic_set(&ha->fwres.iocb_used, 0);
atomic_set(&ha->fwres.exch_used, 0);
}

void qla_adjust_iocb_limit(scsi_qla_host_t *vha)
Expand Down Expand Up @@ -5599,7 +5609,7 @@ static void qla_get_login_template(scsi_qla_host_t *vha)
__be32 *q;

memset(ha->init_cb, 0, ha->init_cb_size);
sz = min_t(int, sizeof(struct fc_els_csp), ha->init_cb_size);
sz = min_t(int, sizeof(struct fc_els_flogi), ha->init_cb_size);
rval = qla24xx_get_port_login_templ(vha, ha->init_cb_dma,
ha->init_cb, sz);
if (rval != QLA_SUCCESS) {
Expand Down Expand Up @@ -7393,14 +7403,15 @@ qla2x00_abort_isp_cleanup(scsi_qla_host_t *vha)
}

/* purge MBox commands */
if (atomic_read(&ha->num_pend_mbx_stage3)) {
spin_lock_irqsave(&ha->hardware_lock, flags);
if (test_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags)) {
clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
complete(&ha->mbx_intr_comp);
}
spin_unlock_irqrestore(&ha->hardware_lock, flags);

i = 0;
while (atomic_read(&ha->num_pend_mbx_stage3) ||
atomic_read(&ha->num_pend_mbx_stage2) ||
while (atomic_read(&ha->num_pend_mbx_stage2) ||
atomic_read(&ha->num_pend_mbx_stage1)) {
msleep(20);
i++;
Expand Down Expand Up @@ -9646,6 +9657,7 @@ struct qla_qpair *qla2xxx_create_qpair(struct scsi_qla_host *vha, int qos,
qpair->vp_idx = vp_idx;
qpair->fw_started = ha->flags.fw_started;
INIT_LIST_HEAD(&qpair->hints_list);
INIT_LIST_HEAD(&qpair->dsd_list);
qpair->chip_reset = ha->base_qpair->chip_reset;
qpair->enable_class_2 = ha->base_qpair->enable_class_2;
qpair->enable_explicit_conf =
Expand Down Expand Up @@ -9774,6 +9786,19 @@ int qla2xxx_delete_qpair(struct scsi_qla_host *vha, struct qla_qpair *qpair)
if (ret != QLA_SUCCESS)
goto fail;

if (!list_empty(&qpair->dsd_list)) {
struct dsd_dma *dsd_ptr, *tdsd_ptr;

/* clean up allocated prev pool */
list_for_each_entry_safe(dsd_ptr, tdsd_ptr,
&qpair->dsd_list, list) {
dma_pool_free(ha->dl_dma_pool, dsd_ptr->dsd_addr,
dsd_ptr->dsd_list_dma);
list_del(&dsd_ptr->list);
kfree(dsd_ptr);
}
}

mutex_lock(&ha->mq_lock);
ha->queue_pair_map[qpair->id] = NULL;
clear_bit(qpair->id, ha->qpair_qid_map);
Expand Down
57 changes: 56 additions & 1 deletion qla2x00t-32gbit/qla_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,15 @@ enum {
RESOURCE_IOCB = BIT_0,
RESOURCE_EXCH = BIT_1, /* exchange */
RESOURCE_FORCE = BIT_2,
RESOURCE_HA = BIT_3,
};

static inline int
qla_get_fw_resources(struct qla_qpair *qp, struct iocb_resource *iores)
{
u16 iocbs_used, i;
u16 exch_used;
struct qla_hw_data *ha = qp->vha->hw;
struct qla_hw_data *ha = qp->hw;

if (!ql2xenforce_iocb_limit) {
iores->res_type = RESOURCE_NONE;
Expand Down Expand Up @@ -436,15 +437,69 @@ qla_get_fw_resources(struct qla_qpair *qp, struct iocb_resource *iores)
return -ENOSPC;
}
}

if (ql2xenforce_iocb_limit == 2) {
if ((iores->iocb_cnt + atomic_read(&ha->fwres.iocb_used)) >=
ha->fwres.iocb_limit) {
iores->res_type = RESOURCE_NONE;
return -ENOSPC;
}

if (iores->res_type & RESOURCE_EXCH) {
if ((iores->exch_cnt + atomic_read(&ha->fwres.exch_used)) >=
ha->fwres.exch_limit) {
iores->res_type = RESOURCE_NONE;
return -ENOSPC;
}
}
}

force:
qp->fwres.iocbs_used += iores->iocb_cnt;
qp->fwres.exch_used += iores->exch_cnt;
if (ql2xenforce_iocb_limit == 2) {
atomic_add(iores->iocb_cnt, &ha->fwres.iocb_used);
atomic_add(iores->exch_cnt, &ha->fwres.exch_used);
iores->res_type |= RESOURCE_HA;
}
return 0;
}

/*
* decrement to zero. This routine will not decrement below zero
* @v: pointer of type atomic_t
* @amount: amount to decrement from v
*/
static void qla_atomic_dtz(atomic_t *v, int amount)
{
int c, old, dec;

c = atomic_read(v);
for (;;) {
dec = c - amount;
if (unlikely(dec < 0))
dec = 0;

old = atomic_cmpxchg((v), c, dec);
if (likely(old == c))
break;
c = old;
}
}

static inline void
qla_put_fw_resources(struct qla_qpair *qp, struct iocb_resource *iores)
{
struct qla_hw_data *ha = qp->hw;

if (iores->res_type & RESOURCE_HA) {
if (iores->res_type & RESOURCE_IOCB)
qla_atomic_dtz(&ha->fwres.iocb_used, iores->iocb_cnt);

if (iores->res_type & RESOURCE_EXCH)
qla_atomic_dtz(&ha->fwres.exch_used, iores->exch_cnt);
}

if (iores->res_type & RESOURCE_IOCB) {
if (qp->fwres.iocbs_used >= iores->iocb_cnt) {
qp->fwres.iocbs_used -= iores->iocb_cnt;
Expand Down
Loading
Loading