Skip to content

Commit 3b0009c

Browse files
jsmart-ghmartinkpetersen
authored andcommitted
scsi: lpfc: Add SET_HOST_DATA mbox cmd to pass date/time info to firmware
Implement the SET_HOST_DATA mbox command to set date / time during initialization. It is used by the firmware for various purposes including congestion management and firmware dumps. Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Justin Tee <[email protected]> Signed-off-by: Justin Tee <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 54404d3 commit 3b0009c

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed

drivers/scsi/lpfc/lpfc_hw4.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3427,12 +3427,40 @@ struct lpfc_mbx_set_feature {
34273427

34283428

34293429
#define LPFC_SET_HOST_OS_DRIVER_VERSION 0x2
3430+
#define LPFC_SET_HOST_DATE_TIME 0x4
3431+
3432+
struct lpfc_mbx_set_host_date_time {
3433+
uint32_t word6;
3434+
#define lpfc_mbx_set_host_month_WORD word6
3435+
#define lpfc_mbx_set_host_month_SHIFT 16
3436+
#define lpfc_mbx_set_host_month_MASK 0xFF
3437+
#define lpfc_mbx_set_host_day_WORD word6
3438+
#define lpfc_mbx_set_host_day_SHIFT 8
3439+
#define lpfc_mbx_set_host_day_MASK 0xFF
3440+
#define lpfc_mbx_set_host_year_WORD word6
3441+
#define lpfc_mbx_set_host_year_SHIFT 0
3442+
#define lpfc_mbx_set_host_year_MASK 0xFF
3443+
uint32_t word7;
3444+
#define lpfc_mbx_set_host_hour_WORD word7
3445+
#define lpfc_mbx_set_host_hour_SHIFT 16
3446+
#define lpfc_mbx_set_host_hour_MASK 0xFF
3447+
#define lpfc_mbx_set_host_min_WORD word7
3448+
#define lpfc_mbx_set_host_min_SHIFT 8
3449+
#define lpfc_mbx_set_host_min_MASK 0xFF
3450+
#define lpfc_mbx_set_host_sec_WORD word7
3451+
#define lpfc_mbx_set_host_sec_SHIFT 0
3452+
#define lpfc_mbx_set_host_sec_MASK 0xFF
3453+
};
3454+
34303455
struct lpfc_mbx_set_host_data {
34313456
#define LPFC_HOST_OS_DRIVER_VERSION_SIZE 48
34323457
struct mbox_header header;
34333458
uint32_t param_id;
34343459
uint32_t param_len;
3435-
uint8_t data[LPFC_HOST_OS_DRIVER_VERSION_SIZE];
3460+
union {
3461+
uint8_t data[LPFC_HOST_OS_DRIVER_VERSION_SIZE];
3462+
struct lpfc_mbx_set_host_date_time tm;
3463+
} un;
34363464
};
34373465

34383466
struct lpfc_mbx_set_trunk_mode {

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7369,7 +7369,7 @@ lpfc_set_host_data(struct lpfc_hba *phba, LPFC_MBOXQ_t *mbox)
73697369
mbox->u.mqe.un.set_host_data.param_id = LPFC_SET_HOST_OS_DRIVER_VERSION;
73707370
mbox->u.mqe.un.set_host_data.param_len =
73717371
LPFC_HOST_OS_DRIVER_VERSION_SIZE;
7372-
snprintf(mbox->u.mqe.un.set_host_data.data,
7372+
snprintf(mbox->u.mqe.un.set_host_data.un.data,
73737373
LPFC_HOST_OS_DRIVER_VERSION_SIZE,
73747374
"Linux %s v"LPFC_DRIVER_VERSION,
73757375
(phba->hba_flag & HBA_FCOE_MODE) ? "FCoE" : "FC");
@@ -7499,6 +7499,51 @@ static void lpfc_sli4_dip(struct lpfc_hba *phba)
74997499
}
75007500
}
75017501

7502+
static int
7503+
lpfc_set_host_tm(struct lpfc_hba *phba)
7504+
{
7505+
LPFC_MBOXQ_t *mboxq;
7506+
uint32_t len, rc;
7507+
struct timespec64 cur_time;
7508+
struct tm broken;
7509+
uint32_t month, day, year;
7510+
uint32_t hour, minute, second;
7511+
struct lpfc_mbx_set_host_date_time *tm;
7512+
7513+
mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL);
7514+
if (!mboxq)
7515+
return -ENOMEM;
7516+
7517+
len = sizeof(struct lpfc_mbx_set_host_data) -
7518+
sizeof(struct lpfc_sli4_cfg_mhdr);
7519+
lpfc_sli4_config(phba, mboxq, LPFC_MBOX_SUBSYSTEM_COMMON,
7520+
LPFC_MBOX_OPCODE_SET_HOST_DATA, len,
7521+
LPFC_SLI4_MBX_EMBED);
7522+
7523+
mboxq->u.mqe.un.set_host_data.param_id = LPFC_SET_HOST_DATE_TIME;
7524+
mboxq->u.mqe.un.set_host_data.param_len =
7525+
sizeof(struct lpfc_mbx_set_host_date_time);
7526+
tm = &mboxq->u.mqe.un.set_host_data.un.tm;
7527+
ktime_get_real_ts64(&cur_time);
7528+
time64_to_tm(cur_time.tv_sec, 0, &broken);
7529+
month = broken.tm_mon + 1;
7530+
day = broken.tm_mday;
7531+
year = broken.tm_year - 100;
7532+
hour = broken.tm_hour;
7533+
minute = broken.tm_min;
7534+
second = broken.tm_sec;
7535+
bf_set(lpfc_mbx_set_host_month, tm, month);
7536+
bf_set(lpfc_mbx_set_host_day, tm, day);
7537+
bf_set(lpfc_mbx_set_host_year, tm, year);
7538+
bf_set(lpfc_mbx_set_host_hour, tm, hour);
7539+
bf_set(lpfc_mbx_set_host_min, tm, minute);
7540+
bf_set(lpfc_mbx_set_host_sec, tm, second);
7541+
7542+
rc = lpfc_sli_issue_mbox(phba, mboxq, MBX_POLL);
7543+
mempool_free(mboxq, phba->mbox_mem_pool);
7544+
return rc;
7545+
}
7546+
75027547
/**
75037548
* lpfc_sli4_hba_setup - SLI4 device initialization PCI function
75047549
* @phba: Pointer to HBA context object.
@@ -7588,6 +7633,10 @@ lpfc_sli4_hba_setup(struct lpfc_hba *phba)
75887633
goto out_free_mbox;
75897634
}
75907635

7636+
rc = lpfc_set_host_tm(phba);
7637+
lpfc_printf_log(phba, KERN_ERR, LOG_MBOX | LOG_INIT,
7638+
"6468 Set host date / time: Status x%x:\n", rc);
7639+
75917640
/*
75927641
* Continue initialization with default values even if driver failed
75937642
* to read FCoE param config regions, only read parameters if the

0 commit comments

Comments
 (0)