Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/bnxt/bnxt_hwrm.c
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct input *req = msg; | struct input *req = msg; | ||||
struct hwrm_err_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; | struct hwrm_err_output *resp = (void *)softc->hwrm_cmd_resp.idi_vaddr; | ||||
uint32_t *data = msg; | uint32_t *data = msg; | ||||
int i; | int i; | ||||
uint16_t cp_ring_id; | uint16_t cp_ring_id; | ||||
uint8_t *valid; | uint8_t *valid; | ||||
uint16_t err; | uint16_t err; | ||||
uint16_t max_req_len = HWRM_MAX_REQ_LEN; | |||||
struct hwrm_short_input short_input = {0}; | |||||
/* TODO: DMASYNC in here. */ | /* TODO: DMASYNC in here. */ | ||||
req->seq_id = htole16(softc->hwrm_cmd_seq++); | req->seq_id = htole16(softc->hwrm_cmd_seq++); | ||||
memset(resp, 0, PAGE_SIZE); | memset(resp, 0, PAGE_SIZE); | ||||
cp_ring_id = le16toh(req->cmpl_ring); | cp_ring_id = le16toh(req->cmpl_ring); | ||||
if (softc->flags & BNXT_FLAG_SHORT_CMD) { | |||||
void *short_cmd_req = softc->hwrm_short_cmd_req_addr.idi_vaddr; | |||||
memcpy(short_cmd_req, req, msg_len); | |||||
memset((uint8_t *) short_cmd_req + msg_len, 0, softc->hwrm_max_req_len- | |||||
msg_len); | |||||
short_input.req_type = req->req_type; | |||||
short_input.signature = | |||||
htole16(HWRM_SHORT_INPUT_SIGNATURE_SHORT_CMD); | |||||
short_input.size = htole16(msg_len); | |||||
short_input.req_addr = | |||||
htole64(softc->hwrm_short_cmd_req_addr.idi_paddr); | |||||
data = (uint32_t *)&short_input; | |||||
msg_len = sizeof(short_input); | |||||
/* Sync memory write before updating doorbell */ | |||||
wmb(); | |||||
max_req_len = BNXT_HWRM_SHORT_REQ_LEN; | |||||
} | |||||
/* Write request msg to hwrm channel */ | /* Write request msg to hwrm channel */ | ||||
for (i = 0; i < msg_len; i += 4) { | for (i = 0; i < msg_len; i += 4) { | ||||
bus_space_write_4(softc->hwrm_bar.tag, | bus_space_write_4(softc->hwrm_bar.tag, | ||||
softc->hwrm_bar.handle, | softc->hwrm_bar.handle, | ||||
i, *data); | i, *data); | ||||
data++; | data++; | ||||
} | } | ||||
/* Clear to the end of the request buffer */ | /* Clear to the end of the request buffer */ | ||||
for (i = msg_len; i < HWRM_MAX_REQ_LEN; i += 4) | for (i = msg_len; i < max_req_len; i += 4) | ||||
bus_space_write_4(softc->hwrm_bar.tag, softc->hwrm_bar.handle, | bus_space_write_4(softc->hwrm_bar.tag, softc->hwrm_bar.handle, | ||||
i, 0); | i, 0); | ||||
/* Ring channel doorbell */ | /* Ring channel doorbell */ | ||||
bus_space_write_4(softc->hwrm_bar.tag, | bus_space_write_4(softc->hwrm_bar.tag, | ||||
softc->hwrm_bar.handle, | softc->hwrm_bar.handle, | ||||
0x100, htole32(1)); | 0x100, htole32(1)); | ||||
▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | |||||
bnxt_hwrm_ver_get(struct bnxt_softc *softc) | bnxt_hwrm_ver_get(struct bnxt_softc *softc) | ||||
{ | { | ||||
struct hwrm_ver_get_input req = {0}; | struct hwrm_ver_get_input req = {0}; | ||||
struct hwrm_ver_get_output *resp = | struct hwrm_ver_get_output *resp = | ||||
(void *)softc->hwrm_cmd_resp.idi_vaddr; | (void *)softc->hwrm_cmd_resp.idi_vaddr; | ||||
int rc; | int rc; | ||||
const char nastr[] = "<not installed>"; | const char nastr[] = "<not installed>"; | ||||
const char naver[] = "<N/A>"; | const char naver[] = "<N/A>"; | ||||
uint32_t dev_caps_cfg; | |||||
softc->hwrm_max_req_len = HWRM_MAX_REQ_LEN; | softc->hwrm_max_req_len = HWRM_MAX_REQ_LEN; | ||||
softc->hwrm_cmd_timeo = 1000; | softc->hwrm_cmd_timeo = 1000; | ||||
bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VER_GET); | bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_VER_GET); | ||||
req.hwrm_intf_maj = HWRM_VERSION_MAJOR; | req.hwrm_intf_maj = HWRM_VERSION_MAJOR; | ||||
req.hwrm_intf_min = HWRM_VERSION_MINOR; | req.hwrm_intf_min = HWRM_VERSION_MINOR; | ||||
req.hwrm_intf_upd = HWRM_VERSION_UPDATE; | req.hwrm_intf_upd = HWRM_VERSION_UPDATE; | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | bnxt_hwrm_ver_get(struct bnxt_softc *softc) | ||||
softc->ver_info->chip_metal = resp->chip_metal; | softc->ver_info->chip_metal = resp->chip_metal; | ||||
softc->ver_info->chip_bond_id = resp->chip_bond_id; | softc->ver_info->chip_bond_id = resp->chip_bond_id; | ||||
softc->ver_info->chip_type = resp->chip_platform_type; | softc->ver_info->chip_type = resp->chip_platform_type; | ||||
if (resp->max_req_win_len) | if (resp->max_req_win_len) | ||||
softc->hwrm_max_req_len = le16toh(resp->max_req_win_len); | softc->hwrm_max_req_len = le16toh(resp->max_req_win_len); | ||||
if (resp->def_req_timeout) | if (resp->def_req_timeout) | ||||
softc->hwrm_cmd_timeo = le16toh(resp->def_req_timeout); | softc->hwrm_cmd_timeo = le16toh(resp->def_req_timeout); | ||||
dev_caps_cfg = le32toh(resp->dev_caps_cfg); | |||||
if ((dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_SUPPORTED) && | |||||
(dev_caps_cfg & HWRM_VER_GET_OUTPUT_DEV_CAPS_CFG_SHORT_CMD_REQUIRED)) | |||||
softc->flags |= BNXT_FLAG_SHORT_CMD; | |||||
fail: | fail: | ||||
BNXT_HWRM_UNLOCK(softc); | BNXT_HWRM_UNLOCK(softc); | ||||
return rc; | return rc; | ||||
} | } | ||||
int | int | ||||
bnxt_hwrm_func_drv_rgtr(struct bnxt_softc *softc) | bnxt_hwrm_func_drv_rgtr(struct bnxt_softc *softc) | ||||
▲ Show 20 Lines • Show All 1,447 Lines • Show Last 20 Lines |