Lines Matching +full:idma +full:- +full:addr
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
48 * t4_wait_op_done_val - wait until an operation is completed
51 * @mask: a single-bit field within @reg that indicates completion
60 * operation completes and -EAGAIN otherwise.
73 if (--attempts == 0) in t4_wait_op_done_val()
74 return -EAGAIN; in t4_wait_op_done_val()
88 * t7_wait_sram_done - wait until an operation is completed
99 * operation completes successfully and -EAGAIN if it times out.
114 if (--attempts == 0) in t7_wait_sram_done()
115 return -EAGAIN; in t7_wait_sram_done()
123 * t4_set_reg_field - set a register field to a value
125 * @addr: the register address
132 void t4_set_reg_field(struct adapter *adapter, unsigned int addr, u32 mask, in t4_set_reg_field() argument
135 u32 v = t4_read_reg(adapter, addr) & ~mask; in t4_set_reg_field()
137 t4_write_reg(adapter, addr, v | val); in t4_set_reg_field()
138 (void) t4_read_reg(adapter, addr); /* flush */ in t4_set_reg_field()
142 * t4_read_indirect - read indirectly addressed registers
157 while (nregs--) { in t4_read_indirect()
165 * t4_write_indirect - write indirectly addressed registers
180 while (nregs--) { in t4_write_indirect()
187 * Read a 32-bit PCI Configuration Space register via the PCI-E backdoor
198 u32 req = V_FUNCTION(adap->pf) | V_REGISTER(reg); in t4_hw_pci_read_cfg4()
216 * read-modify-write via t4_set_reg_field().) in t4_hw_pci_read_cfg4()
224 * t4_report_fw_error - report firmware error
253 * Get the reply to a mailbox command and store it in @rpl in big-endian order.
258 for ( ; nflit; nflit--, mbox_addr += 8) in get_mbox_rpl()
269 asrt->u.assert.filename_0_7, in fw_asrt()
270 be32_to_cpu(asrt->u.assert.line), in fw_asrt()
271 be32_to_cpu(asrt->u.assert.x), in fw_asrt()
272 be32_to_cpu(asrt->u.assert.y)); in fw_asrt()
298 tx_state->rx_pause = t4_read_reg64(sc, rx_pause_reg); in read_tx_state_one()
299 tx_state->tx_frames = t4_read_reg64(sc, tx_frames_reg); in read_tx_state_one()
308 if (sc->chan_map[i] != 0xff) in read_tx_state()
321 if (sc->chan_map[i] == 0xff) in check_tx_state()
340 * t4_wr_mbox_meat_timeout - send a command to FW through the given mailbox
387 if (adap->flags & CHK_MBOX_ACCESS) in t4_wr_mbox_meat_timeout()
391 return -EINVAL; in t4_wr_mbox_meat_timeout()
393 if (adap->flags & IS_VF) { in t4_wr_mbox_meat_timeout()
406 timeout = -timeout; in t4_wr_mbox_meat_timeout()
413 if (!(adap->flags & IS_VF)) { in t4_wr_mbox_meat_timeout()
429 if (!(adap->flags & IS_VF)) { in t4_wr_mbox_meat_timeout()
434 ret = (v == X_MBOWNER_FW) ? -EBUSY : -ETIMEDOUT; in t4_wr_mbox_meat_timeout()
458 if (adap->flags & IS_VF) { in t4_wr_mbox_meat_timeout()
464 * to the VF's PL-register-backed Mailbox Control can in t4_wr_mbox_meat_timeout()
465 * race in front of the writes to the MA-backed VF in t4_wr_mbox_meat_timeout()
467 * read-back on at least one byte of the VF Mailbox in t4_wr_mbox_meat_timeout()
485 if (!(adap->flags & IS_VF)) { in t4_wr_mbox_meat_timeout()
498 if (delay_idx < ARRAY_SIZE(delay) - 1) in t4_wr_mbox_meat_timeout()
528 return -G_FW_CMD_RETVAL((int)res); in t4_wr_mbox_meat_timeout()
542 adap->flags &= ~FW_OK; in t4_wr_mbox_meat_timeout()
543 ret = pcie_fw & F_PCIE_FW_ERR ? -ENXIO : -ETIMEDOUT; in t4_wr_mbox_meat_timeout()
573 "edc%d err addr 0x%x: 0x%x.\n", in t4_edc_err_read()
593 * t4_mc_read - read from MC through backdoor accesses
596 * @addr: address of first byte requested
598 * @ecc: where to store the corresponding 64-bit ECC word
600 * Read 64 bytes of data from MC starting at a 64-byte-aligned address
601 * that covers the requested address @addr. If @parity is not %NULL it
602 * is assigned the 64-bit ECC word for the read data.
604 int t4_mc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc) in t4_mc_read() argument
624 return (-ENOTSUP); in t4_mc_read()
628 return -EBUSY; in t4_mc_read()
629 t4_write_reg(adap, mc_bist_cmd_addr_reg, addr & ~0x3fU); in t4_mc_read()
640 for (i = 15; i >= 0; i--) in t4_mc_read()
649 * t4_edc_read - read from EDC through backdoor accesses
652 * @addr: address of first byte requested
654 * @ecc: where to store the corresponding 64-bit ECC word
656 * Read 64 bytes of data from EDC starting at a 64-byte-aligned address
657 * that covers the requested address @addr. If @parity is not %NULL it
658 * is assigned the 64-bit ECC word for the read data.
660 int t4_edc_read(struct adapter *adap, int idx, u32 addr, __be32 *data, u64 *ecc) in t4_edc_read() argument
685 return -EBUSY; in t4_edc_read()
686 t4_write_reg(adap, edc_bist_cmd_addr_reg, addr & ~0x3fU); in t4_edc_read()
697 for (i = 15; i >= 0; i--) in t4_edc_read()
706 * t4_mem_read - read EDC 0, EDC 1 or MC into buffer
709 * @addr: address within indicated memory type
715 * 32-bit boudaries. The memory is returned as a raw byte sequence from
717 * contain multi-byte integers, it's the callers responsibility to
720 int t4_mem_read(struct adapter *adap, int mtype, u32 addr, u32 len, in t4_mem_read() argument
729 if ((addr & 0x3) || (len & 0x3)) in t4_mem_read()
730 return -EINVAL; in t4_mem_read()
735 * copying out of the first line at (addr - start) a word at a time. in t4_mem_read()
737 start = rounddown2(addr, 64); in t4_mem_read()
738 end = roundup2(addr + len, 64); in t4_mem_read()
739 offset = (addr - start)/sizeof(__be32); in t4_mem_read()
748 ret = t4_mc_read(adap, mtype - MEM_MC, pos, data, NULL); in t4_mem_read()
759 len -= sizeof(__be32); in t4_mem_read()
767 * Return the specified PCI-E Configuration Space register from our Physical
777 * retrieve the specified PCI-E Configuration Space register. in t4_read_pcie_cfg4()
792 (F_FW_LDST_CMD_LC | V_FW_LDST_CMD_FN(adap->pf)); in t4_read_pcie_cfg4()
799 ret = t4_wr_mbox(adap, adap->mbox, &ldst_cmd, sizeof(ldst_cmd), in t4_read_pcie_cfg4()
806 reg, -ret); in t4_read_pcie_cfg4()
810 * Read the desired Configuration Space register via the PCI-E in t4_read_pcie_cfg4()
817 * t4_get_regs_len - return the size of the chips register set
828 if (adapter->flags & IS_VF) in t4_get_regs_len()
835 if (adapter->flags & IS_VF) in t4_get_regs_len()
846 * t4_get_regs - read chip registers into provided buffer
1325 ((NUM_CIM_PF_MAILBOX_DATA_INSTANCES - 1) * 4), in t4_get_regs()
2102 ((NUM_CIM_PF_MAILBOX_DATA_INSTANCES - 1) * 4), in t4_get_regs()
2672 ((NUM_CIM_PF_MAILBOX_DATA_INSTANCES - 1) * 4), in t4_get_regs()
3324 if (adap->flags & IS_VF) { in t4_get_regs()
3334 if (adap->flags & IS_VF) { in t4_get_regs()
3344 if (adap->flags & IS_VF) { in t4_get_regs()
3354 if (adap->flags & IS_VF) { in t4_get_regs()
3392 * header followed by one or more VPD-R sections, each with its own header.
3421 * We have a per-adapter state variable "VPD Busy" to indicate when we have a
3424 * Request before any in-flight VPD reguest has completed.
3428 unsigned int base = adapter->params.pci.vpd_cap_addr; in t4_seeprom_wait()
3435 if (!adapter->vpd_busy) in t4_seeprom_wait()
3453 if ((val & PCI_VPD_ADDR_F) == adapter->vpd_flag) { in t4_seeprom_wait()
3454 adapter->vpd_busy = 0; in t4_seeprom_wait()
3457 } while (--max_poll); in t4_seeprom_wait()
3466 return -ETIMEDOUT; in t4_seeprom_wait()
3470 * t4_seeprom_read - read a serial EEPROM location
3472 * @addr: EEPROM virtual address
3475 * Read a 32-bit word from a location in serial EEPROM using the card's PCI
3479 int t4_seeprom_read(struct adapter *adapter, u32 addr, u32 *data) in t4_seeprom_read() argument
3481 unsigned int base = adapter->params.pci.vpd_cap_addr; in t4_seeprom_read()
3485 * VPD Accesses must alway be 4-byte aligned! in t4_seeprom_read()
3487 if (addr >= EEPROMVSIZE || (addr & 3)) in t4_seeprom_read()
3488 return -EINVAL; in t4_seeprom_read()
3506 t4_os_pci_write_cfg2(adapter, base + PCI_VPD_ADDR, (u16)addr); in t4_seeprom_read()
3507 adapter->vpd_busy = 1; in t4_seeprom_read()
3508 adapter->vpd_flag = PCI_VPD_ADDR_F; in t4_seeprom_read()
3511 CH_ERR(adapter, "VPD read of address %#x failed\n", addr); in t4_seeprom_read()
3525 * t4_seeprom_write - write a serial EEPROM location
3527 * @addr: virtual EEPROM address
3530 * Write a 32-bit word to a location in serial EEPROM using the card's PCI
3534 int t4_seeprom_write(struct adapter *adapter, u32 addr, u32 data) in t4_seeprom_write() argument
3536 unsigned int base = adapter->params.pci.vpd_cap_addr; in t4_seeprom_write()
3542 * VPD Accesses must alway be 4-byte aligned! in t4_seeprom_write()
3544 if (addr >= EEPROMVSIZE || (addr & 3)) in t4_seeprom_write()
3545 return -EINVAL; in t4_seeprom_write()
3566 (u16)addr | PCI_VPD_ADDR_F); in t4_seeprom_write()
3567 adapter->vpd_busy = 1; in t4_seeprom_write()
3568 adapter->vpd_flag = 0; in t4_seeprom_write()
3571 CH_ERR(adapter, "VPD write of address %#x failed\n", addr); in t4_seeprom_write()
3584 } while ((stats_reg & 0x1) && --max_poll); in t4_seeprom_write()
3586 return -ETIMEDOUT; in t4_seeprom_write()
3593 * t4_eeprom_ptov - translate a physical EEPROM address to virtual
3596 * @sz: size of function-specific area
3603 * [0..1K) -> [31K..32K)
3604 * [1K..1K+A) -> [ES-A..ES)
3605 * [1K+A..ES) -> [0..ES-A-1K)
3615 return EEPROMSIZE - fn + phys_addr - 1024; in t4_eeprom_ptov()
3617 return phys_addr - 1024 - fn; in t4_eeprom_ptov()
3618 return -EINVAL; in t4_eeprom_ptov()
3622 * t4_seeprom_wp - enable/disable EEPROM write protection
3634 * get_vpd_keyword_val - Locates an information field keyword in the VPD
3640 * -ENOENT otherwise.
3650 tag = vpdr->vpdr_tag; in get_vpd_keyword_val()
3651 len = (u16)vpdr->vpdr_len[0] + ((u16)vpdr->vpdr_len[1] << 8); in get_vpd_keyword_val()
3652 while (region--) { in get_vpd_keyword_val()
3655 if (++tag != vpdr->vpdr_tag) in get_vpd_keyword_val()
3656 return -ENOENT; in get_vpd_keyword_val()
3657 len = (u16)vpdr->vpdr_len[0] + ((u16)vpdr->vpdr_len[1] << 8); in get_vpd_keyword_val()
3662 return -ENOENT; in get_vpd_keyword_val()
3674 return -ENOENT; in get_vpd_keyword_val()
3679 * get_vpd_params - read VPD parameters from VPD EEPROM
3689 int i, ret, addr; in get_vpd_params() local
3709 addr = *vpd == CHELSIO_VPD_UNIQUE_ID ? VPD_BASE : VPD_BASE_OLD; in get_vpd_params()
3712 ret = t4_seeprom_read(adapter, addr + i, buf++); in get_vpd_params()
3721 return -EINVAL; \ in get_vpd_params()
3726 for (csum = 0; i >= 0; i--) in get_vpd_params()
3732 return -EINVAL; in get_vpd_params()
3741 memcpy(p->id, vpd + offsetof(struct t4_vpd_hdr, id_data), ID_LEN); in get_vpd_params()
3742 strstrip(p->id); in get_vpd_params()
3743 memcpy(p->ec, vpd + ec, EC_LEN); in get_vpd_params()
3744 strstrip(p->ec); in get_vpd_params()
3745 i = vpd[sn - VPD_INFO_FLD_HDR_SIZE + 2]; in get_vpd_params()
3746 memcpy(p->sn, vpd + sn, min(i, SERNUM_LEN)); in get_vpd_params()
3747 strstrip(p->sn); in get_vpd_params()
3748 i = vpd[pn - VPD_INFO_FLD_HDR_SIZE + 2]; in get_vpd_params()
3749 memcpy(p->pn, vpd + pn, min(i, PN_LEN)); in get_vpd_params()
3750 strstrip((char *)p->pn); in get_vpd_params()
3751 i = vpd[na - VPD_INFO_FLD_HDR_SIZE + 2]; in get_vpd_params()
3752 memcpy(p->na, vpd + na, min(i, MACADDR_LEN)); in get_vpd_params()
3753 strstrip((char *)p->na); in get_vpd_params()
3760 snprintf(p->md, sizeof(p->md), "unknown"); in get_vpd_params()
3762 i = vpd[md - VPD_INFO_FLD_HDR_SIZE + 2]; in get_vpd_params()
3763 memcpy(p->md, vpd + md, min(i, MD_LEN)); in get_vpd_params()
3764 strstrip((char *)p->md); in get_vpd_params()
3816 *lenp = FLASH_MAX_SIZE(l->nsecs); in t4_flash_loc_start()
3817 return (FLASH_START(l->start_sec)); in t4_flash_loc_start()
3835 * sf1_read - read data from the serial flash
3853 return -EINVAL; in sf1_read()
3855 return -EBUSY; in sf1_read()
3856 op = V_SF_LOCK(lock) | V_CONT(cont) | V_BYTECNT(byte_cnt - 1); in sf1_read()
3867 * sf1_write - write data to the serial flash
3882 return -EINVAL; in sf1_write()
3884 return -EBUSY; in sf1_write()
3887 V_CONT(cont) | V_BYTECNT(byte_cnt - 1) | V_OP(1)); in sf1_write()
3892 * flash_wait_op - wait for a flash operation to complete
3910 if (--attempts == 0) in flash_wait_op()
3911 return -EAGAIN; in flash_wait_op()
3918 * t4_read_flash - read words from serial flash
3920 * @addr: the start address for the read
3921 * @nwords: how many 32-bit words to read
3925 * Read the specified number of 32-bit words from the serial flash.
3927 * (i.e., big-endian), otherwise as 32-bit words in the platform's
3930 int t4_read_flash(struct adapter *adapter, unsigned int addr, in t4_read_flash() argument
3935 if (addr + nwords * sizeof(u32) > adapter->params.sf_size || (addr & 3)) in t4_read_flash()
3936 return -EINVAL; in t4_read_flash()
3938 addr = swab32(addr) | SF_RD_DATA_FAST; in t4_read_flash()
3940 if ((ret = sf1_write(adapter, 4, 1, 0, addr)) != 0 || in t4_read_flash()
3944 for ( ; nwords; nwords--, data++) { in t4_read_flash()
3957 * t4_write_flash - write up to a page of data to the serial flash
3959 * @addr: the start address to write
3967 * (i.e. matches what on disk), otherwise in big-endian.
3969 int t4_write_flash(struct adapter *adapter, unsigned int addr, in t4_write_flash() argument
3974 unsigned int i, c, left, val, offset = addr & 0xff; in t4_write_flash()
3976 if (addr >= adapter->params.sf_size || offset + n > SF_PAGE_SIZE) in t4_write_flash()
3977 return -EINVAL; in t4_write_flash()
3979 val = swab32(addr) | SF_PROG_PAGE; in t4_write_flash()
3985 for (left = n; left; left -= c) { in t4_write_flash()
4004 ret = t4_read_flash(adapter, addr & ~0xff, ARRAY_SIZE(buf), buf, in t4_write_flash()
4009 if (memcmp(data - n, (u8 *)buf + offset, n)) { in t4_write_flash()
4012 addr); in t4_write_flash()
4013 return -EIO; in t4_write_flash()
4023 * t4_get_fw_version - read the firmware version
4038 * t4_get_fw_hdr - read the firmware header
4053 * t4_get_bs_version - read the firmware bootstrap version
4069 * t4_get_tp_version - read the TP microcode version
4084 * t4_get_exprom_version - return the Expansion ROM version (if any)
4091 * 0 on success, -ENOENT if no Expansion ROM is present.
4110 if (hdr->hdr_arr[0] != 0x55 || hdr->hdr_arr[1] != 0xaa) in t4_get_exprom_version()
4111 return -ENOENT; in t4_get_exprom_version()
4113 *vers = (V_FW_HDR_FW_VER_MAJOR(hdr->hdr_ver[0]) | in t4_get_exprom_version()
4114 V_FW_HDR_FW_VER_MINOR(hdr->hdr_ver[1]) | in t4_get_exprom_version()
4115 V_FW_HDR_FW_VER_MICRO(hdr->hdr_ver[2]) | in t4_get_exprom_version()
4116 V_FW_HDR_FW_VER_BUILD(hdr->hdr_ver[3])); in t4_get_exprom_version()
4121 * t4_get_scfg_version - return the Serial Configuration version
4131 * to retrieve the Serial Configuration version, so we zero-out the
4132 * return-value parameter in that case to avoid leaving it with
4150 ret = t4_query_params(adapter, adapter->mbox, adapter->pf, 0, in t4_get_scfg_version()
4158 * t4_get_vpd_version - return the VPD version
4168 * to retrieve the VPD version, so we zero-out the return-value parameter
4185 ret = t4_query_params(adapter, adapter->mbox, adapter->pf, 0, in t4_get_vpd_version()
4193 * t4_get_version_info - extract various chip/firmware version information
4212 FIRST_RET(t4_get_fw_version(adapter, &adapter->params.fw_vers)); in t4_get_version_info()
4213 FIRST_RET(t4_get_bs_version(adapter, &adapter->params.bs_vers)); in t4_get_version_info()
4214 FIRST_RET(t4_get_tp_version(adapter, &adapter->params.tp_vers)); in t4_get_version_info()
4215 FIRST_RET(t4_get_exprom_version(adapter, &adapter->params.er_vers)); in t4_get_version_info()
4216 FIRST_RET(t4_get_scfg_version(adapter, &adapter->params.scfg_vers)); in t4_get_version_info()
4217 FIRST_RET(t4_get_vpd_version(adapter, &adapter->params.vpd_vers)); in t4_get_version_info()
4225 * t4_flash_erase_sectors - erase a range of flash sectors
4236 if (end >= adapter->params.sf_nsec) in t4_flash_erase_sectors()
4237 return -EINVAL; in t4_flash_erase_sectors()
4256 * t4_flash_cfg_addr - return the address of the flash configuration file
4272 if (adapter->params.sf_size < cfg_start + len) in t4_flash_cfg_addr()
4273 return -ENOSPC; in t4_flash_cfg_addr()
4292 if ((is_t4(adap) && hdr->chip == FW_HDR_CHIP_T4) || in t4_fw_matches_chip()
4293 (is_t5(adap) && hdr->chip == FW_HDR_CHIP_T5) || in t4_fw_matches_chip()
4294 (is_t6(adap) && hdr->chip == FW_HDR_CHIP_T6) || in t4_fw_matches_chip()
4295 (is_t7(adap) && hdr->chip == FW_HDR_CHIP_T7)) in t4_fw_matches_chip()
4300 hdr->chip, chip_id(adap)); in t4_fw_matches_chip()
4305 * t4_load_fw - download firmware
4315 int ret, addr; in t4_load_fw() local
4325 loc = ntohl(hdr->magic) == FW_HDR_MAGIC_BOOTSTRAP ? in t4_load_fw()
4332 return -EINVAL; in t4_load_fw()
4337 return -EINVAL; in t4_load_fw()
4339 if ((unsigned int) be16_to_cpu(hdr->len512) * 512 != size) { in t4_load_fw()
4342 return -EINVAL; in t4_load_fw()
4347 return -EFBIG; in t4_load_fw()
4350 return -EINVAL; in t4_load_fw()
4358 return -EINVAL; in t4_load_fw()
4362 ret = t4_flash_erase_sectors(adap, fw_start_sec, fw_start_sec + i - 1); in t4_load_fw()
4372 ((struct fw_hdr *)first_page)->fw_ver = cpu_to_be32(0xffffffff); in t4_load_fw()
4377 addr = fw_start; in t4_load_fw()
4378 for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) { in t4_load_fw()
4379 addr += SF_PAGE_SIZE; in t4_load_fw()
4381 ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, fw_data, 1); in t4_load_fw()
4388 sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver, 1); in t4_load_fw()
4397 * t4_fwcache - firmware cache operation
4409 V_FW_PARAMS_CMD_PFN(adap->pf) | in t4_fwcache()
4417 return t4_wr_mbox(adap, adap->mbox, &c, sizeof(c), NULL); in t4_fwcache()
4491 * fwcaps16_to_caps32 - convert 16-bit Port Capabilities to 32-bits
4492 * @caps16: a 16-bit Port Capabilities value
4494 * Returns the equivalent 32-bit Port Capabilities value.
4529 * fwcaps32_to_caps16 - convert 32-bit Port Capabilities to 16-bits
4530 * @caps32: a 32-bit Port Capabilities value
4532 * Returns the equivalent 16-bit Port Capabilities value. Note that
4533 * not all 32-bit Port Capabilities can be represented in the 16-bit
4606 * t4_link_l1cfg - apply link configuration to MAC/PHY
4612 * - If the PHY can auto-negotiate first decide what to advertise, then
4613 * enable/disable auto-negotiation as desired, and reset.
4614 * - If the PHY does not auto-negotiate just reset it.
4615 * - If auto-negotiation is off set the MAC to the proper speed/duplex/FC,
4616 * otherwise do it later based on the outcome of auto-negotiation.
4626 if (lc->requested_fc & PAUSE_RX) in t4_link_l1cfg()
4628 if (lc->requested_fc & PAUSE_TX) in t4_link_l1cfg()
4630 if (!(lc->requested_fc & PAUSE_AUTONEG)) in t4_link_l1cfg()
4633 if (lc->requested_aneg == AUTONEG_DISABLE) in t4_link_l1cfg()
4635 else if (lc->requested_aneg == AUTONEG_ENABLE) in t4_link_l1cfg()
4638 aneg = lc->pcaps & FW_PORT_CAP32_ANEG; in t4_link_l1cfg()
4641 speed = lc->pcaps & in t4_link_l1cfg()
4643 } else if (lc->requested_speed != 0) in t4_link_l1cfg()
4644 speed = speed_to_fwcap(lc->requested_speed); in t4_link_l1cfg()
4646 speed = fwcap_top_speed(lc->pcaps); in t4_link_l1cfg()
4652 if (lc->pcaps & FW_PORT_CAP32_FORCE_FEC) in t4_link_l1cfg()
4653 force_fec = lc->force_fec; in t4_link_l1cfg()
4657 if (lc->requested_fec == FEC_AUTO) { in t4_link_l1cfg()
4680 fec |= fec_to_fwcap(lc->fec_hint); in t4_link_l1cfg()
4700 fec |= fec_to_fwcap(lc->requested_fec & in t4_link_l1cfg()
4702 if (lc->requested_fec & FEC_MODULE) in t4_link_l1cfg()
4703 fec |= fec_to_fwcap(lc->fec_hint); in t4_link_l1cfg()
4716 if (isset(&adap->bt_map, port)) in t4_link_l1cfg()
4717 aneg = lc->pcaps & FW_PORT_CAP32_ANEG; in t4_link_l1cfg()
4720 if ((rcap | lc->pcaps) != lc->pcaps) { in t4_link_l1cfg()
4723 lc->pcaps, rcap & (rcap ^ lc->pcaps)); in t4_link_l1cfg()
4725 rcap &= lc->pcaps; in t4_link_l1cfg()
4733 if (adap->params.port_caps32) { in t4_link_l1cfg()
4745 lc->requested_caps = rcap; in t4_link_l1cfg()
4750 * t4_restart_aneg - restart autonegotiation
4802 return ('-'); in intr_alert_char()
4812 enable = t4_read_reg(adap, ii->enable_reg); in t4_show_intr_info()
4813 if (ii->flags & NONFATAL_IF_DISABLED) in t4_show_intr_info()
4814 fatal = ii->fatal & t4_read_reg(adap, ii->enable_reg); in t4_show_intr_info()
4816 fatal = ii->fatal; in t4_show_intr_info()
4819 alert, ii->name, ii->cause_reg, cause, enable, fatal); in t4_show_intr_info()
4822 for (details = ii->details; details && details->mask != 0; details++) { in t4_show_intr_info()
4823 u32 msgbits = details->mask & cause; in t4_show_intr_info()
4826 alert = intr_alert_char(msgbits, enable, ii->fatal); in t4_show_intr_info()
4828 details->msg); in t4_show_intr_info()
4851 cause = t4_read_reg(adap, ii->cause_reg); in t4_handle_intr()
4852 if (ii->cause_reg == A_PL_INT_CAUSE) in t4_handle_intr()
4853 cause &= t4_read_reg(adap, ii->enable_reg); in t4_handle_intr()
4856 fatal = cause & ii->fatal; in t4_handle_intr()
4857 if (fatal != 0 && ii->flags & NONFATAL_IF_DISABLED) in t4_handle_intr()
4858 fatal &= t4_read_reg(adap, ii->enable_reg); in t4_handle_intr()
4864 for (action = ii->actions; action && action->mask != 0; action++) { in t4_handle_intr()
4865 if (!(action->mask & cause)) in t4_handle_intr()
4867 rc |= (action->action)(adap, action->arg, verbose); in t4_handle_intr()
4871 t4_write_reg(adap, ii->cause_reg, cause); in t4_handle_intr()
4872 (void)t4_read_reg(adap, ii->cause_reg); in t4_handle_intr()
4925 { F_MSIXADDRLPERR, "MSI-X AddrL parity error" }, in pcie_intr_handler()
4926 { F_MSIXADDRHPERR, "MSI-X AddrH parity error" }, in pcie_intr_handler()
4927 { F_MSIXDATAPERR, "MSI-X data parity error" }, in pcie_intr_handler()
4928 { F_MSIXDIPERR, "MSI-X DI parity error" }, in pcie_intr_handler()
4956 { F_NONFATALERR, "PCIe non-fatal error" }, in pcie_intr_handler()
4979 { F_MSIXDIPERR, "MSI-X DI SRAM parity error" }, in pcie_intr_handler()
4980 { F_MSIXDATAPERR, "MSI-X data SRAM parity error" }, in pcie_intr_handler()
4981 { F_MSIXADDRHPERR, "MSI-X AddrH SRAM parity error" }, in pcie_intr_handler()
4982 { F_MSIXADDRLPERR, "MSI-X AddrL SRAM parity error" }, in pcie_intr_handler()
4983 { F_MSIXSTIPERR, "MSI-X STI SRAM parity error" }, in pcie_intr_handler()
5062 "Invalid QID or header request by IDMA" }, in sge_intr_handler()
5069 "SGE GTS with timer 0-5 for IQID > 1023" }, in sge_intr_handler()
5074 { F_ERR_CPL_OPCODE_0, "SGE received 0-length CPL" }, in sge_intr_handler()
5097 "Invalid QID or header request by IDMA" }, in sge_intr_handler()
5104 "SGE GTS with timer 0-5 for IQID > 1023" }, in sge_intr_handler()
5109 { F_ERR_CPL_OPCODE_0, "SGE received 0-length CPL" }, in sge_intr_handler()
5210 { F_NCSI2CIMINTFPARERR, "CIM IBQ NC-SI interface parity error" }, in cim_intr_handler()
5228 { F_IBQNCSIPARERR, "CIM IBQ NC-SI parity error" }, in cim_intr_handler()
5234 { F_OBQNCSIPARERR, "CIM OBQ NC-SI parity error" }, in cim_intr_handler()
5425 CH_ALERT(adap, " - PM_TX_DBG_STAT%u (0x%x) = 0x%08x\n", i, in pmtx_dump_dbg_stats()
5445 { F_ZERO_C_CMD_ERROR, "PMTX 0-length pcmd" }, in pmtx_intr_handler()
5485 { F_ZERO_E_CMD_ERROR, "PMRX 0-length pcmd" }, in pmrx_intr_handler()
5527 { F_ZERO_SWITCH_ERROR, "CPLSW no-switch error" }, in cplsw_intr_handler()
5576 { F_T6_ACTCNTIPV6TZERO, "LE IPv6 active open TCAM counter -ve" }, in le_intr_handler()
5577 { F_T6_ACTCNTIPV4TZERO, "LE IPv4 active open TCAM counter -ve" }, in le_intr_handler()
5578 { F_T6_ACTCNTIPV6ZERO, "LE IPv6 active open counter -ve" }, in le_intr_handler()
5579 { F_T6_ACTCNTIPV4ZERO, "LE IPv4 active open counter -ve" }, in le_intr_handler()
5634 { F_NCSIFIFO, "MPS Tx NC-SI FIFO parity error" }, in mps_intr_handler()
5846 "MA address wrap-around error by client %u to address %#x\n", in ma_wrap_status()
5926 * NC-SI interrupt handler.
5931 { F_CIM_DM_PRTY_ERR, "NC-SI CIM parity error" }, in ncsi_intr_handler()
5932 { F_MPS_DM_PRTY_ERR, "NC-SI MPS parity error" }, in ncsi_intr_handler()
5933 { F_TXFIFO_PRTY_ERR, "NC-SI Tx FIFO parity error" }, in ncsi_intr_handler()
5934 { F_RXFIFO_PRTY_ERR, "NC-SI Rx FIFO parity error" }, in ncsi_intr_handler()
6081 * t4_slow_intr_handler - control path interrupt handler
6085 * T4 interrupt handler for non-data global interrupt events, e.g., errors.
6116 { F_NCSI, "NC-SI" }, in t4_slow_intr_handler()
6145 { F_NCSI, "NC-SI" }, in t4_slow_intr_handler()
6164 { F_ULP_TX, -1, ulptx_intr_handler }, in t4_slow_intr_handler()
6165 { F_SGE, -1, sge_intr_handler }, in t4_slow_intr_handler()
6166 { F_CPL_SWITCH, -1, cplsw_intr_handler }, in t4_slow_intr_handler()
6167 { F_ULP_RX, -1, ulprx_intr_handler }, in t4_slow_intr_handler()
6168 { F_PM_RX, -1, pmrx_intr_handler}, in t4_slow_intr_handler()
6169 { F_PM_TX, -1, pmtx_intr_handler}, in t4_slow_intr_handler()
6170 { F_MA, -1, ma_intr_handler }, in t4_slow_intr_handler()
6171 { F_TP, -1, tp_intr_handler }, in t4_slow_intr_handler()
6172 { F_LE, -1, le_intr_handler }, in t4_slow_intr_handler()
6176 { F_PCIE, -1, pcie_intr_handler }, in t4_slow_intr_handler()
6181 { F_SMB, -1, smb_intr_handler}, in t4_slow_intr_handler()
6182 { F_PL, -1, plpl_intr_handler }, in t4_slow_intr_handler()
6183 { F_NCSI, -1, ncsi_intr_handler}, in t4_slow_intr_handler()
6184 { F_MPS, -1, mps_intr_handler }, in t4_slow_intr_handler()
6185 { F_CIM, -1, cim_intr_handler }, in t4_slow_intr_handler()
6189 { F_T7_ULP_TX, -1, ulptx_intr_handler }, in t4_slow_intr_handler()
6190 { F_T7_SGE, -1, sge_intr_handler }, in t4_slow_intr_handler()
6191 { F_T7_CPL_SWITCH, -1, cplsw_intr_handler }, in t4_slow_intr_handler()
6192 { F_T7_ULP_RX, -1, ulprx_intr_handler }, in t4_slow_intr_handler()
6193 { F_T7_PM_RX, -1, pmrx_intr_handler}, in t4_slow_intr_handler()
6194 { F_T7_PM_TX, -1, pmtx_intr_handler}, in t4_slow_intr_handler()
6195 { F_T7_MA, -1, ma_intr_handler }, in t4_slow_intr_handler()
6196 { F_T7_TP, -1, tp_intr_handler }, in t4_slow_intr_handler()
6197 { F_T7_LE, -1, le_intr_handler }, in t4_slow_intr_handler()
6202 { F_T7_PCIE, -1, pcie_intr_handler }, in t4_slow_intr_handler()
6207 { F_SMB, -1, smb_intr_handler}, in t4_slow_intr_handler()
6208 { F_PL, -1, plpl_intr_handler }, in t4_slow_intr_handler()
6209 { F_NCSI, -1, ncsi_intr_handler}, in t4_slow_intr_handler()
6210 { F_MPS, -1, mps_intr_handler }, in t4_slow_intr_handler()
6211 { F_CIM, -1, cim_intr_handler }, in t4_slow_intr_handler()
6250 * t4_intr_enable - enable interrupts
6253 * Enable PF-specific interrupts for the calling function and the top-level
6259 * non PF-specific interrupts from the various HW modules. Only one PCI
6280 t4_set_reg_field(adap, A_PL_INT_MAP0, 0, 1 << adap->pf); in t4_intr_enable()
6284 * t4_intr_disable - disable interrupts
6287 * Disable interrupts. We only disable the top-level interrupt
6295 t4_set_reg_field(adap, A_PL_INT_MAP0, 1 << adap->pf, 0); in t4_intr_disable()
6299 * hash_mac_addr - return the hash value of a MAC address
6300 * @addr: the 48-bit Ethernet MAC address
6305 static int hash_mac_addr(const u8 *addr) in hash_mac_addr() argument
6307 u32 a = ((u32)addr[0] << 16) | ((u32)addr[1] << 8) | addr[2]; in hash_mac_addr()
6308 u32 b = ((u32)addr[3] << 16) | ((u32)addr[4] << 8) | addr[5]; in hash_mac_addr()
6316 * t4_config_rss_range - configure a portion of the RSS mapping table
6349 * a 32-bit word as 10-bit values with the upper remaining 2 bits in t4_config_rss_range()
6368 n -= nq; in t4_config_rss_range()
6380 * current 3-tuple position within the commad. in t4_config_rss_range()
6386 nq -= nqbuf; in t4_config_rss_range()
6389 nqbuf--; in t4_config_rss_range()
6412 * t4_config_glbl_rss - configure the global RSS mode
6416 * @flags: mode-specific flags
6437 return -EINVAL; in t4_config_glbl_rss()
6442 * t4_config_vi_rss - configure per VI RSS settings
6448 * @skeyidx: RSS secret key table index for non-global mode
6451 * Configures VI-specific RSS properties.
6488 * t4_read_rss - read the contents of the RSS mapping table
6492 * Reads the contents of the RSS hash->queue mapping table.
6498 int rss_nentries = adapter->chip_params->rss_nentries; in t4_read_rss()
6511 * t4_tp_fw_ldst_rw - Access TP indirect register through LDST
6539 c.u.addrval.addr = cpu_to_be32(start_index + i); in t4_tp_fw_ldst_rw()
6541 ret = t4_wr_mbox_meat(adap, adap->mbox, &c, sizeof(c), &c, in t4_tp_fw_ldst_rw()
6553 * t4_tp_indirect_rw - Read/Write TP indirect register through LDST or backdoor
6570 int rc = -EINVAL; in t4_tp_indirect_rw()
6604 * t4_tp_pio_read - Read TP PIO registers
6621 * t4_tp_pio_write - Write TP PIO registers
6638 * t4_tp_tm_pio_read - Read TP TM PIO registers
6655 * t4_tp_mib_read - Read TP MIB registers
6672 * t4_read_rss_key - read the global RSS key
6674 * @key: 10-entry array holding the 320-bit RSS key
6677 * Reads the global 320-bit RSS key.
6685 * t4_write_rss_key - program one of the RSS keys
6687 * @key: 10-entry array holding the 320-bit RSS key
6691 * Writes one of the RSS keys with the given 320-bit value. If @idx is
6702 * T6 and later: for KeyMode 3 (per-vf and per-vf scramble), in t4_write_rss_key()
6703 * allows access to key addresses 16-63 by using KeyWrAddrX in t4_write_rss_key()
6724 * t4_read_rss_pf_config - read PF RSS Configuration Table
6740 * t4_write_rss_pf_config - write PF RSS Configuration Table
6757 * t4_read_rss_vf_config - read VF RSS Configuration Table
6795 * t4_write_rss_vf_config - write VF RSS Configuration Table
6834 * t4_read_rss_pf_map - read PF RSS Map
6850 * t4_write_rss_pf_map - write PF RSS Map
6862 * t4_read_rss_pf_mask - read PF RSS Mask
6878 * t4_write_rss_pf_mask - write PF RSS Mask
6890 * t4_tp_get_tcp_stats - read TP's TCP MIB counters
6902 u32 val[A_TP_MIB_TCP_RXT_SEG_LO - A_TP_MIB_TCP_OUT_RST + 1]; in t4_tp_get_tcp_stats()
6904 #define STAT_IDX(x) ((A_TP_MIB_TCP_##x) - A_TP_MIB_TCP_OUT_RST) in t4_tp_get_tcp_stats()
6911 v4->tcp_out_rsts = STAT(OUT_RST); in t4_tp_get_tcp_stats()
6912 v4->tcp_in_segs = STAT64(IN_SEG); in t4_tp_get_tcp_stats()
6913 v4->tcp_out_segs = STAT64(OUT_SEG); in t4_tp_get_tcp_stats()
6914 v4->tcp_retrans_segs = STAT64(RXT_SEG); in t4_tp_get_tcp_stats()
6919 v6->tcp_out_rsts = STAT(OUT_RST); in t4_tp_get_tcp_stats()
6920 v6->tcp_in_segs = STAT64(IN_SEG); in t4_tp_get_tcp_stats()
6921 v6->tcp_out_segs = STAT64(OUT_SEG); in t4_tp_get_tcp_stats()
6922 v6->tcp_retrans_segs = STAT64(RXT_SEG); in t4_tp_get_tcp_stats()
6930 * t4_tp_get_err_stats - read TP's error MIB counters
6940 int nchan = adap->chip_params->nchan; in t4_tp_get_err_stats()
6942 t4_tp_mib_read(adap, st->mac_in_errs, nchan, A_TP_MIB_MAC_IN_ERR_0, in t4_tp_get_err_stats()
6945 t4_tp_mib_read(adap, st->hdr_in_errs, nchan, A_TP_MIB_HDR_IN_ERR_0, in t4_tp_get_err_stats()
6948 t4_tp_mib_read(adap, st->tcp_in_errs, nchan, A_TP_MIB_TCP_IN_ERR_0, in t4_tp_get_err_stats()
6951 t4_tp_mib_read(adap, st->tnl_cong_drops, nchan, in t4_tp_get_err_stats()
6954 t4_tp_mib_read(adap, st->ofld_chan_drops, nchan, in t4_tp_get_err_stats()
6957 t4_tp_mib_read(adap, st->tnl_tx_drops, nchan, A_TP_MIB_TNL_DROP_0, in t4_tp_get_err_stats()
6960 t4_tp_mib_read(adap, st->ofld_vlan_drops, nchan, in t4_tp_get_err_stats()
6963 t4_tp_mib_read(adap, st->tcp6_in_errs, nchan, in t4_tp_get_err_stats()
6966 t4_tp_mib_read(adap, &st->ofld_no_neigh, 2, A_TP_MIB_OFD_ARP_DROP, in t4_tp_get_err_stats()
6971 * t4_tp_get_err_stats - read TP's error MIB counters
6981 int nchan = adap->chip_params->nchan; in t4_tp_get_tnl_stats()
6983 t4_tp_mib_read(adap, st->out_pkt, nchan, A_TP_MIB_TNL_OUT_PKT_0, in t4_tp_get_tnl_stats()
6985 t4_tp_mib_read(adap, st->in_pkt, nchan, A_TP_MIB_TNL_IN_PKT_0, in t4_tp_get_tnl_stats()
6990 * t4_tp_get_proxy_stats - read TP's proxy MIB counters
6999 int nchan = adap->chip_params->nchan; in t4_tp_get_proxy_stats()
7001 t4_tp_mib_read(adap, st->proxy, nchan, A_TP_MIB_TNL_LPBK_0, sleep_ok); in t4_tp_get_proxy_stats()
7005 * t4_tp_get_cpl_stats - read TP's CPL MIB counters
7015 int nchan = adap->chip_params->nchan; in t4_tp_get_cpl_stats()
7017 t4_tp_mib_read(adap, st->req, nchan, A_TP_MIB_CPL_IN_REQ_0, sleep_ok); in t4_tp_get_cpl_stats()
7019 t4_tp_mib_read(adap, st->rsp, nchan, A_TP_MIB_CPL_OUT_RSP_0, sleep_ok); in t4_tp_get_cpl_stats()
7023 * t4_tp_get_rdma_stats - read TP's RDMA MIB counters
7032 t4_tp_mib_read(adap, &st->rqe_dfr_pkt, 2, A_TP_MIB_RQE_DFR_PKT, in t4_tp_get_rdma_stats()
7037 t4_tp_mib_read(adap, &st->pkts_in[0], 28, A_TP_MIB_RDMA_IN_PKT_0, in t4_tp_get_rdma_stats()
7042 * t4_get_fcoe_stats - read TP's FCoE MIB counters for a port
7055 t4_tp_mib_read(adap, &st->frames_ddp, 1, A_TP_MIB_FCOE_DDP_0 + idx, in t4_get_fcoe_stats()
7058 t4_tp_mib_read(adap, &st->frames_drop, 1, in t4_get_fcoe_stats()
7064 st->octets_ddp = ((u64)val[0] << 32) | val[1]; in t4_get_fcoe_stats()
7068 * t4_get_usm_stats - read TP's non-TCP DDP MIB counters
7073 * Returns the values of TP's counters for non-TCP directly-placed packets.
7082 st->frames = val[0]; in t4_get_usm_stats()
7083 st->drops = val[1]; in t4_get_usm_stats()
7084 st->octets = ((u64)val[2] << 32) | val[3]; in t4_get_usm_stats()
7088 * t4_tp_get_tid_stats - read TP's tid MIB counters.
7099 t4_tp_mib_read(adap, &st->del, 4, A_TP_MIB_TID_DEL, sleep_ok); in t4_tp_get_tid_stats()
7103 * t4_read_mtu_tbl - returns the values in the HW path MTU table
7106 * @mtu_log: where to store the MTU base-2 log (may be %NULL)
7126 * t4_read_cong_tbl - reads the congestion control table
7147 * t4_tp_wr_bits_indirect - set/clear bits in an indirect TP register
7149 * @addr: the indirect TP register address
7155 void t4_tp_wr_bits_indirect(struct adapter *adap, unsigned int addr, in t4_tp_wr_bits_indirect() argument
7158 t4_write_reg(adap, A_TP_PIO_ADDR, addr); in t4_tp_wr_bits_indirect()
7164 * init_cong_ctrl - initialize congestion control parameters
7211 * t4_load_mtus - write the MTU and congestion control HW tables
7217 * Write the HW MTU table with the supplied MTUs and the high-speed
7238 log2--; in t4_load_mtus()
7245 inc = max(((mtu - 40) * alpha[w]) / avg_pkts[w], in t4_load_mtus()
7255 * t4_set_pace_tbl - set the pace table
7270 return -ERANGE; in t4_set_pace_tbl()
7276 return -ERANGE; in t4_set_pace_tbl()
7278 return -ERANGE; in t4_set_pace_tbl()
7286 * t4_set_sched_bps - set the bit rate for a HW traffic scheduler
7296 unsigned int clk = adap->params.vpd.cclk * 1000; in t4_set_sched_bps()
7300 kbps *= 125; /* -> bytes */ in t4_set_sched_bps()
7306 delta = v >= kbps ? v - kbps : kbps - v; in t4_set_sched_bps()
7316 return -EINVAL; in t4_set_sched_bps()
7319 A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2); in t4_set_sched_bps()
7330 * t4_set_sched_ipg - set the IPG for a Tx HW packet rate scheduler
7339 unsigned int v, addr = A_TP_TX_MOD_Q1_Q0_TIMER_SEPARATOR - sched / 2; in t4_set_sched_ipg() local
7345 return -EINVAL; in t4_set_sched_ipg()
7347 t4_write_reg(adap, A_TP_TM_PIO_ADDR, addr); in t4_set_sched_ipg()
7359 * Calculates a rate in bytes/s given the number of 256-byte units per 4K core
7370 u64 v = (u64)bytes256 * adap->params.vpd.cclk; in chan_rate()
7376 * t4_get_chan_txrate - get the current per channel Tx rates
7391 if (adap->chip_params->nchan > 2) { in t4_get_chan_txrate()
7399 if (adap->chip_params->nchan > 2) { in t4_get_chan_txrate()
7406 * t4_set_trace_filter - configure one of the tracing filters
7425 return -EINVAL; in t4_set_trace_filter()
7441 * TODO - After T4 data book is updated, specify the exact in t4_set_trace_filter()
7444 * See T4 data book - MPS section for a complete description in t4_set_trace_filter()
7455 if (tp->snap_len > ((10 * 1024 / 4) - (2 * 8))) in t4_set_trace_filter()
7456 return -EINVAL; in t4_set_trace_filter()
7463 if (tp->snap_len > 9600 || idx) in t4_set_trace_filter()
7464 return -EINVAL; in t4_set_trace_filter()
7467 if (tp->port > (is_t4(adap) ? 11 : 19) || tp->invert > 1 || in t4_set_trace_filter()
7468 tp->skip_len > M_TFLENGTH || tp->skip_ofst > M_TFOFFSET || in t4_set_trace_filter()
7469 tp->min_len > M_TFMINPKTSIZE) in t4_set_trace_filter()
7470 return -EINVAL; in t4_set_trace_filter()
7475 ofst = (A_MPS_TRC_FILTER1_MATCH - A_MPS_TRC_FILTER0_MATCH) * idx; in t4_set_trace_filter()
7480 t4_write_reg(adap, data_reg, tp->data[i]); in t4_set_trace_filter()
7481 t4_write_reg(adap, mask_reg, ~tp->mask[i]); in t4_set_trace_filter()
7483 t4_write_reg(adap, match_ctl_b, V_TFCAPTUREMAX(tp->snap_len) | in t4_set_trace_filter()
7484 V_TFMINPKTSIZE(tp->min_len)); in t4_set_trace_filter()
7485 t4_write_reg(adap, match_ctl_a, V_TFOFFSET(tp->skip_ofst) | in t4_set_trace_filter()
7486 V_TFLENGTH(tp->skip_len) | en | (is_t4(adap) ? in t4_set_trace_filter()
7487 V_TFPORT(tp->port) | V_TFINVERTMATCH(tp->invert) : in t4_set_trace_filter()
7488 V_T5_TFPORT(tp->port) | V_T5_TFINVERTMATCH(tp->invert))); in t4_set_trace_filter()
7494 * t4_get_trace_filter - query one of the tracing filters
7498 * @enabled: non-zero if the filter is enabled
7519 tp->port = G_TFPORT(ctla); in t4_get_trace_filter()
7520 tp->invert = !!(ctla & F_TFINVERTMATCH); in t4_get_trace_filter()
7523 tp->port = G_T5_TFPORT(ctla); in t4_get_trace_filter()
7524 tp->invert = !!(ctla & F_T5_TFINVERTMATCH); in t4_get_trace_filter()
7526 tp->snap_len = G_TFCAPTUREMAX(ctlb); in t4_get_trace_filter()
7527 tp->min_len = G_TFMINPKTSIZE(ctlb); in t4_get_trace_filter()
7528 tp->skip_ofst = G_TFOFFSET(ctla); in t4_get_trace_filter()
7529 tp->skip_len = G_TFLENGTH(ctla); in t4_get_trace_filter()
7531 ofst = (A_MPS_TRC_FILTER1_MATCH - A_MPS_TRC_FILTER0_MATCH) * idx; in t4_get_trace_filter()
7536 tp->mask[i] = ~t4_read_reg(adap, mask_reg); in t4_get_trace_filter()
7537 tp->data[i] = t4_read_reg(adap, data_reg) & tp->mask[i]; in t4_get_trace_filter()
7542 * t4_set_trace_rss_control - configure the trace rss control register
7573 * t4_pmtx_get_stats - returns the HW stats from PMTX
7585 for (i = 0; i < adap->chip_params->pm_stats_cnt; i++) { in t4_pmtx_get_stats()
7602 * t4_pmrx_get_stats - returns the HW stats from PMRX
7614 for (i = 0; i < adap->chip_params->pm_stats_cnt; i++) { in t4_pmrx_get_stats()
7629 * t4_pmrx_cache_get_stats - returns the HW PMRX cache stats
7648 * t4_get_mps_bg_map - return the buffer groups associated with a port
7660 if (adap->params.mps_bg_map != UINT32_MAX) in t4_get_mps_bg_map()
7661 return ((adap->params.mps_bg_map >> (idx << 3)) & 0xff); in t4_get_mps_bg_map()
7663 n = adap->params.nports; in t4_get_mps_bg_map()
7673 * TP RX e-channels associated with the port.
7677 const u32 n = adap->params.nports; in t4_get_rx_e_chan_map()
7678 const u32 all_chan = (1 << adap->chip_params->nchan) - 1; in t4_get_rx_e_chan_map()
7680 switch (adap->params.tp.lb_mode) { in t4_get_rx_e_chan_map()
7695 adap->params.tp.lb_mode); in t4_get_rx_e_chan_map()
7701 * TP RX c-channel associated with the port.
7705 if (adap->params.tp_ch_map != UINT32_MAX) in t4_get_rx_c_chan()
7706 return (adap->params.tp_ch_map >> (8 * idx)) & 0xff; in t4_get_rx_c_chan()
7711 * TP TX c-channel associated with the port.
7715 if (adap->params.tx_tp_ch_map != UINT32_MAX) in t4_get_tx_c_chan()
7716 return (adap->params.tx_tp_ch_map >> (8 * idx)) & 0xff; in t4_get_tx_c_chan()
7721 * t4_get_port_type_description - return Port Type string description
7758 * t4_get_port_stats_offset - collect port stats relative to a previous
7776 *s -= *o; in t4_get_port_stats_offset()
7780 * t4_get_port_stats - collect port statistics
7793 port_id = adap->port_map[idx]; in t4_get_port_stats()
7794 MPASS(port_id >= 0 && port_id <= adap->params.nports); in t4_get_port_stats()
7795 pi = adap->port[port_id]; in t4_get_port_stats()
7801 for (tx_chan = pi->tx_chan; in t4_get_port_stats()
7802 tx_chan < pi->tx_chan + adap->params.tp.lb_nchan; tx_chan++) { in t4_get_port_stats()
7803 p->tx_pause += GET_STAT(TX_PORT_PAUSE); in t4_get_port_stats()
7804 p->tx_octets += GET_STAT(TX_PORT_BYTES); in t4_get_port_stats()
7805 p->tx_frames += GET_STAT(TX_PORT_FRAMES); in t4_get_port_stats()
7806 p->tx_bcast_frames += GET_STAT(TX_PORT_BCAST); in t4_get_port_stats()
7807 p->tx_mcast_frames += GET_STAT(TX_PORT_MCAST); in t4_get_port_stats()
7808 p->tx_ucast_frames += GET_STAT(TX_PORT_UCAST); in t4_get_port_stats()
7809 p->tx_error_frames += GET_STAT(TX_PORT_ERROR); in t4_get_port_stats()
7810 p->tx_frames_64 += GET_STAT(TX_PORT_64B); in t4_get_port_stats()
7811 p->tx_frames_65_127 += GET_STAT(TX_PORT_65B_127B); in t4_get_port_stats()
7812 p->tx_frames_128_255 += GET_STAT(TX_PORT_128B_255B); in t4_get_port_stats()
7813 p->tx_frames_256_511 += GET_STAT(TX_PORT_256B_511B); in t4_get_port_stats()
7814 p->tx_frames_512_1023 += GET_STAT(TX_PORT_512B_1023B); in t4_get_port_stats()
7815 p->tx_frames_1024_1518 += GET_STAT(TX_PORT_1024B_1518B); in t4_get_port_stats()
7816 p->tx_frames_1519_max += GET_STAT(TX_PORT_1519B_MAX); in t4_get_port_stats()
7817 p->tx_drop += GET_STAT(TX_PORT_DROP); in t4_get_port_stats()
7818 p->tx_ppp0 += GET_STAT(TX_PORT_PPP0); in t4_get_port_stats()
7819 p->tx_ppp1 += GET_STAT(TX_PORT_PPP1); in t4_get_port_stats()
7820 p->tx_ppp2 += GET_STAT(TX_PORT_PPP2); in t4_get_port_stats()
7821 p->tx_ppp3 += GET_STAT(TX_PORT_PPP3); in t4_get_port_stats()
7822 p->tx_ppp4 += GET_STAT(TX_PORT_PPP4); in t4_get_port_stats()
7823 p->tx_ppp5 += GET_STAT(TX_PORT_PPP5); in t4_get_port_stats()
7824 p->tx_ppp6 += GET_STAT(TX_PORT_PPP6); in t4_get_port_stats()
7825 p->tx_ppp7 += GET_STAT(TX_PORT_PPP7); in t4_get_port_stats()
7827 p->rx_pause += GET_STAT(RX_PORT_PAUSE); in t4_get_port_stats()
7828 p->rx_octets += GET_STAT(RX_PORT_BYTES); in t4_get_port_stats()
7829 p->rx_frames += GET_STAT(RX_PORT_FRAMES); in t4_get_port_stats()
7830 p->rx_bcast_frames += GET_STAT(RX_PORT_BCAST); in t4_get_port_stats()
7831 p->rx_mcast_frames += GET_STAT(RX_PORT_MCAST); in t4_get_port_stats()
7832 p->rx_ucast_frames += GET_STAT(RX_PORT_UCAST); in t4_get_port_stats()
7833 p->rx_too_long += GET_STAT(RX_PORT_MTU_ERROR); in t4_get_port_stats()
7834 p->rx_jabber += GET_STAT(RX_PORT_MTU_CRC_ERROR); in t4_get_port_stats()
7835 p->rx_len_err += GET_STAT(RX_PORT_LEN_ERROR); in t4_get_port_stats()
7836 p->rx_symbol_err += GET_STAT(RX_PORT_SYM_ERROR); in t4_get_port_stats()
7837 p->rx_runt += GET_STAT(RX_PORT_LESS_64B); in t4_get_port_stats()
7838 p->rx_frames_64 += GET_STAT(RX_PORT_64B); in t4_get_port_stats()
7839 p->rx_frames_65_127 += GET_STAT(RX_PORT_65B_127B); in t4_get_port_stats()
7840 p->rx_frames_128_255 += GET_STAT(RX_PORT_128B_255B); in t4_get_port_stats()
7841 p->rx_frames_256_511 += GET_STAT(RX_PORT_256B_511B); in t4_get_port_stats()
7842 p->rx_frames_512_1023 += GET_STAT(RX_PORT_512B_1023B); in t4_get_port_stats()
7843 p->rx_frames_1024_1518 += GET_STAT(RX_PORT_1024B_1518B); in t4_get_port_stats()
7844 p->rx_frames_1519_max += GET_STAT(RX_PORT_1519B_MAX); in t4_get_port_stats()
7845 p->rx_ppp0 += GET_STAT(RX_PORT_PPP0); in t4_get_port_stats()
7846 p->rx_ppp1 += GET_STAT(RX_PORT_PPP1); in t4_get_port_stats()
7847 p->rx_ppp2 += GET_STAT(RX_PORT_PPP2); in t4_get_port_stats()
7848 p->rx_ppp3 += GET_STAT(RX_PORT_PPP3); in t4_get_port_stats()
7849 p->rx_ppp4 += GET_STAT(RX_PORT_PPP4); in t4_get_port_stats()
7850 p->rx_ppp5 += GET_STAT(RX_PORT_PPP5); in t4_get_port_stats()
7851 p->rx_ppp6 += GET_STAT(RX_PORT_PPP6); in t4_get_port_stats()
7852 p->rx_ppp7 += GET_STAT(RX_PORT_PPP7); in t4_get_port_stats()
7854 MPASS(pi->fcs_reg == A_MPS_PORT_STAT_RX_PORT_CRC_ERROR_L); in t4_get_port_stats()
7855 p->rx_fcs_err += GET_STAT(RX_PORT_CRC_ERROR); in t4_get_port_stats()
7860 if (is_t6(adap) && pi->fcs_reg != -1) in t4_get_port_stats()
7861 p->rx_fcs_err = t4_read_reg64(adap, in t4_get_port_stats()
7862 t4_port_reg(adap, pi->tx_chan, pi->fcs_reg)) - pi->fcs_base; in t4_get_port_stats()
7867 p->tx_frames -= p->tx_pause; in t4_get_port_stats()
7868 p->tx_octets -= p->tx_pause * 64; in t4_get_port_stats()
7871 p->tx_mcast_frames -= p->tx_pause; in t4_get_port_stats()
7873 p->rx_frames -= p->rx_pause; in t4_get_port_stats()
7874 p->rx_octets -= p->rx_pause * 64; in t4_get_port_stats()
7877 p->rx_mcast_frames -= p->rx_pause; in t4_get_port_stats()
7881 bgmap = pi->mps_bg_map; in t4_get_port_stats()
7882 p->rx_ovflow0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_MAC_DROP_FRAME) : 0; in t4_get_port_stats()
7883 p->rx_ovflow1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_MAC_DROP_FRAME) : 0; in t4_get_port_stats()
7884 p->rx_ovflow2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_MAC_DROP_FRAME) : 0; in t4_get_port_stats()
7885 p->rx_ovflow3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_MAC_DROP_FRAME) : 0; in t4_get_port_stats()
7886 p->rx_trunc0 = (bgmap & 1) ? GET_STAT_COM(RX_BG_0_MAC_TRUNC_FRAME) : 0; in t4_get_port_stats()
7887 p->rx_trunc1 = (bgmap & 2) ? GET_STAT_COM(RX_BG_1_MAC_TRUNC_FRAME) : 0; in t4_get_port_stats()
7888 p->rx_trunc2 = (bgmap & 4) ? GET_STAT_COM(RX_BG_2_MAC_TRUNC_FRAME) : 0; in t4_get_port_stats()
7889 p->rx_trunc3 = (bgmap & 8) ? GET_STAT_COM(RX_BG_3_MAC_TRUNC_FRAME) : 0; in t4_get_port_stats()
7894 * t4_get_lb_stats - collect loopback port statistics
7909 p->octets = GET_STAT(BYTES); in t4_get_lb_stats()
7910 p->frames = GET_STAT(FRAMES); in t4_get_lb_stats()
7911 p->bcast_frames = GET_STAT(BCAST); in t4_get_lb_stats()
7912 p->mcast_frames = GET_STAT(MCAST); in t4_get_lb_stats()
7913 p->ucast_frames = GET_STAT(UCAST); in t4_get_lb_stats()
7914 p->error_frames = GET_STAT(ERROR); in t4_get_lb_stats()
7916 p->frames_64 = GET_STAT(64B); in t4_get_lb_stats()
7917 p->frames_65_127 = GET_STAT(65B_127B); in t4_get_lb_stats()
7918 p->frames_128_255 = GET_STAT(128B_255B); in t4_get_lb_stats()
7919 p->frames_256_511 = GET_STAT(256B_511B); in t4_get_lb_stats()
7920 p->frames_512_1023 = GET_STAT(512B_1023B); in t4_get_lb_stats()
7921 p->frames_1024_1518 = GET_STAT(1024B_1518B); in t4_get_lb_stats()
7922 p->frames_1519_max = GET_STAT(1519B_MAX); in t4_get_lb_stats()
7923 p->drop = GET_STAT(DROP_FRAMES); in t4_get_lb_stats()
7925 if (idx < adap->params.nports) { in t4_get_lb_stats()
7926 u32 bg = adap2pinfo(adap, idx)->mps_bg_map; in t4_get_lb_stats()
7928 p->ovflow0 = (bg & 1) ? GET_STAT_COM(RX_BG_0_LB_DROP_FRAME) : 0; in t4_get_lb_stats()
7929 p->ovflow1 = (bg & 2) ? GET_STAT_COM(RX_BG_1_LB_DROP_FRAME) : 0; in t4_get_lb_stats()
7930 p->ovflow2 = (bg & 4) ? GET_STAT_COM(RX_BG_2_LB_DROP_FRAME) : 0; in t4_get_lb_stats()
7931 p->ovflow3 = (bg & 8) ? GET_STAT_COM(RX_BG_3_LB_DROP_FRAME) : 0; in t4_get_lb_stats()
7932 p->trunc0 = (bg & 1) ? GET_STAT_COM(RX_BG_0_LB_TRUNC_FRAME) : 0; in t4_get_lb_stats()
7933 p->trunc1 = (bg & 2) ? GET_STAT_COM(RX_BG_1_LB_TRUNC_FRAME) : 0; in t4_get_lb_stats()
7934 p->trunc2 = (bg & 4) ? GET_STAT_COM(RX_BG_2_LB_TRUNC_FRAME) : 0; in t4_get_lb_stats()
7935 p->trunc3 = (bg & 8) ? GET_STAT_COM(RX_BG_3_LB_TRUNC_FRAME) : 0; in t4_get_lb_stats()
7943 * t4_wol_magic_enable - enable/disable magic packet WoL
7946 * @addr: MAC address expected in magic packets, %NULL to disable
7948 * Enables/disables magic packet wake-on-LAN for the selected port.
7951 const u8 *addr) in t4_wol_magic_enable() argument
7969 if (addr) { in t4_wol_magic_enable()
7971 (addr[2] << 24) | (addr[3] << 16) | in t4_wol_magic_enable()
7972 (addr[4] << 8) | addr[5]); in t4_wol_magic_enable()
7974 (addr[0] << 8) | addr[1]); in t4_wol_magic_enable()
7977 V_MAGICEN(addr != NULL)); in t4_wol_magic_enable()
7981 * t4_wol_pat_enable - enable/disable pattern-based WoL
7985 * @mask0: byte mask for bytes 0-63 of a packet
7986 * @mask1: byte mask for bytes 64-127 of a packet
7992 * the resulting packet against @crc. If @enable is %true pattern-based
8013 return -EINVAL; in t4_wol_pat_enable()
8032 return -ETIMEDOUT; in t4_wol_pat_enable()
8039 return -ETIMEDOUT; in t4_wol_pat_enable()
8047 /* t4_mk_filtdelwr - create a delete filter WR
8058 wr->op_pkd = cpu_to_be32(V_FW_WR_OP(FW_FILTER_WR)); in t4_mk_filtdelwr()
8059 wr->len16_pkd = cpu_to_be32(V_FW_WR_LEN16(sizeof(*wr) / 16)); in t4_mk_filtdelwr()
8060 wr->tid_to_iq = cpu_to_be32(V_FW_FILTER_WR_TID(ftid) | in t4_mk_filtdelwr()
8062 wr->del_filter_to_l2tix = cpu_to_be32(F_FW_FILTER_WR_DEL_FILTER); in t4_mk_filtdelwr()
8064 wr->rx_chan_rx_rpl_iq = in t4_mk_filtdelwr()
8076 u32 addr, u32 val) in t4_fwaddrspace_write() argument
8088 c.u.addrval.addr = cpu_to_be32(addr); in t4_fwaddrspace_write()
8095 * t4_mdio_rd - read a PHY register through MDIO
8129 * t4_mdio_wr - write a PHY register through MDIO
8161 * t4_sge_decode_idma_state - decode the idma state
8163 * @state: the state idma is stuck in
8308 CH_WARN(adapter, "idma state %s\n", sge_idma_decode[state]); in t4_sge_decode_idma_state()
8310 CH_WARN(adapter, "idma state %d unknown\n", state); in t4_sge_decode_idma_state()
8318 * t4_sge_ctxt_flush - flush the SGE context cache
8346 * t4_fw_hello - establish communication with FW
8351 * @state: returns the current device state (if non-NULL)
8386 if ((ret == -EBUSY || ret == -ETIMEDOUT) && retries-- > 0) in t4_fw_hello()
8406 * Note that we also do this wait if we're a non-Master-capable PF and in t4_fw_hello()
8428 waiting -= 50; in t4_fw_hello()
8439 if (retries-- > 0) in t4_fw_hello()
8442 return -ETIMEDOUT; in t4_fw_hello()
8474 * t4_fw_bye - end communication with FW
8490 * t4_fw_reset - issue a reset to FW
8508 * t4_fw_halt - issue a reset/halt to FW and put uP into RESET
8531 if (adap->flags & FW_OK && mbox <= M_PCIE_FW_MASTER) { in t4_fw_halt()
8568 * t4_fw_restart - restart the firmware by taking the uP out of RESET
8587 return -ETIMEDOUT; in t4_fw_restart()
8591 * t4_fw_upgrade - perform all of the steps necessary to upgrade FW
8616 be32_to_cpu(fw_hdr->magic) == FW_HDR_MAGIC_BOOTSTRAP; in t4_fw_upgrade()
8620 return -EINVAL; in t4_fw_upgrade()
8636 * t4_fw_initialize - ask FW to initialize the device
8653 * t4_query_params_rw - query FW or device parameters
8675 return -EINVAL; in t4_query_params_rw()
8715 * t4_set_params_timeout - sets FW or device parameters
8737 return -EINVAL; in t4_set_params_timeout()
8746 while (nparams--) { in t4_set_params_timeout()
8755 * t4_set_params - sets FW or device parameters
8776 * t4_cfg_pfvf - configure PF/VF resource limits
8783 * @rxqi: the max number of interrupt-capable ingress queues
8824 * t4_alloc_vi_func - allocate a virtual interface
8841 * Returns a negative error number or the non-negative VI id.
8860 c.nmac = nmac - 1; in t4_alloc_vi_func()
8885 *vfvld = adap->params.viid_smt_extn_support ? in t4_alloc_vi_func()
8890 *vin = adap->params.viid_smt_extn_support ? in t4_alloc_vi_func()
8899 * t4_alloc_vi - allocate an [Ethernet Function] virtual interface
8922 * t4_free_vi - free a virtual interface
8949 * t4_set_rxmode - set Rx properties of a virtual interface
8953 * @mtu: the new MTU or -1
8954 * @promisc: 1 to enable promiscuous mode, 0 to disable it, -1 no change
8955 * @all_multi: 1 to enable all-multi mode, 0 to disable it, -1 no change
8956 * @bcast: 1 to enable broadcast Rx, 0 to disable it, -1 no change
8957 * @vlanex: 1 to enable HW VLAN extraction, 0 to disable it, -1 no change
8995 * t4_alloc_encap_mac_filt - Adds a mac entry in mps tcam with VNI support
9011 const u8 *addr, const u8 *mask, unsigned int vni, in t4_alloc_encap_mac_filt() argument
9027 p->valid_to_idx = cpu_to_be16(F_FW_VI_MAC_CMD_VALID | in t4_alloc_encap_mac_filt()
9029 memcpy(p->macaddr, addr, sizeof(p->macaddr)); in t4_alloc_encap_mac_filt()
9030 memcpy(p->macaddr_mask, mask, sizeof(p->macaddr_mask)); in t4_alloc_encap_mac_filt()
9032 p->lookup_type_to_vni = cpu_to_be32(V_FW_VI_MAC_CMD_VNI(vni) | in t4_alloc_encap_mac_filt()
9035 p->vni_mask_pkd = cpu_to_be32(V_FW_VI_MAC_CMD_VNI_MASK(vni_mask)); in t4_alloc_encap_mac_filt()
9037 ret = t4_wr_mbox_meat(adap, adap->mbox, &c, sizeof(c), &c, sleep_ok); in t4_alloc_encap_mac_filt()
9039 ret = G_FW_VI_MAC_CMD_IDX(be16_to_cpu(p->valid_to_idx)); in t4_alloc_encap_mac_filt()
9044 * t4_alloc_raw_mac_filt - Adds a mac entry in mps tcam
9059 const u8 *addr, const u8 *mask, unsigned int idx, in t4_alloc_raw_mac_filt() argument
9076 p->raw_idx_pkd = cpu_to_be32(V_FW_VI_MAC_CMD_RAW_IDX(idx)); in t4_alloc_raw_mac_filt()
9079 p->data0_pkd = cpu_to_be32(V_DATALKPTYPE(lookup_type) | in t4_alloc_raw_mac_filt()
9082 p->data0m_pkd = cpu_to_be64(V_DATALKPTYPE(M_DATALKPTYPE) | in t4_alloc_raw_mac_filt()
9086 memcpy((u8 *)&p->data1[0] + 2, addr, ETHER_ADDR_LEN); in t4_alloc_raw_mac_filt()
9087 memcpy((u8 *)&p->data1m[0] + 2, mask, ETHER_ADDR_LEN); in t4_alloc_raw_mac_filt()
9089 ret = t4_wr_mbox_meat(adap, adap->mbox, &c, sizeof(c), &c, sleep_ok); in t4_alloc_raw_mac_filt()
9091 ret = G_FW_VI_MAC_CMD_RAW_IDX(be32_to_cpu(p->raw_idx_pkd)); in t4_alloc_raw_mac_filt()
9093 ret = -ENOMEM; in t4_alloc_raw_mac_filt()
9100 * t4_alloc_mac_filt - allocates exact-match filters for MAC addresses
9106 * @addr: the MAC address(es)
9111 * Allocates an exact-match filter for each of the supplied addresses and
9123 const u8 **addr, u16 *idx, u64 *hash, bool sleep_ok) in t4_alloc_mac_filt() argument
9128 unsigned int max_naddr = adap->chip_params->mps_tcam_size; in t4_alloc_mac_filt()
9132 return -EINVAL; in t4_alloc_mac_filt()
9153 p->valid_to_idx = in t4_alloc_mac_filt()
9156 memcpy(p->macaddr, addr[offset+i], sizeof(p->macaddr)); in t4_alloc_mac_filt()
9165 if (ret && ret != -FW_ENOMEM) in t4_alloc_mac_filt()
9170 be16_to_cpu(p->valid_to_idx)); in t4_alloc_mac_filt()
9179 *hash |= (1ULL << hash_mac_addr(addr[offset+i])); in t4_alloc_mac_filt()
9184 rem -= fw_naddr; in t4_alloc_mac_filt()
9187 if (ret == 0 || ret == -FW_ENOMEM) in t4_alloc_mac_filt()
9193 * t4_free_encap_mac_filt - frees MPS entry at given index
9208 u8 addr[] = {0,0,0,0,0,0}; in t4_free_encap_mac_filt() local
9223 p->valid_to_idx = cpu_to_be16(F_FW_VI_MAC_CMD_VALID | in t4_free_encap_mac_filt()
9225 memcpy(p->macaddr, addr, sizeof(p->macaddr)); in t4_free_encap_mac_filt()
9227 ret = t4_wr_mbox_meat(adap, adap->mbox, &c, sizeof(c), &c, sleep_ok); in t4_free_encap_mac_filt()
9232 * t4_free_raw_mac_filt - Frees a raw mac entry in mps tcam
9235 * @addr: the MAC address
9247 const u8 *addr, const u8 *mask, unsigned int idx, in t4_free_raw_mac_filt() argument
9264 p->raw_idx_pkd = cpu_to_be32(V_FW_VI_MAC_CMD_RAW_IDX(idx) | in t4_free_raw_mac_filt()
9268 p->data0_pkd = cpu_to_be32(V_DATALKPTYPE(lookup_type) | in t4_free_raw_mac_filt()
9271 p->data0m_pkd = cpu_to_be64(V_DATALKPTYPE(M_DATALKPTYPE) | in t4_free_raw_mac_filt()
9275 memcpy((u8 *)&p->data1[0] + 2, addr, ETHER_ADDR_LEN); in t4_free_raw_mac_filt()
9276 memcpy((u8 *)&p->data1m[0] + 2, mask, ETHER_ADDR_LEN); in t4_free_raw_mac_filt()
9278 return t4_wr_mbox_meat(adap, adap->mbox, &c, sizeof(c), &c, sleep_ok); in t4_free_raw_mac_filt()
9282 * t4_free_mac_filt - frees exact-match filters of given MAC addresses
9287 * @addr: the MAC address(es)
9290 * Frees the exact-match filter for each of the supplied addresses
9296 const u8 **addr, bool sleep_ok) in t4_free_mac_filt() argument
9301 unsigned int max_naddr = adap->chip_params->mps_tcam_size; in t4_free_mac_filt()
9305 return -EINVAL; in t4_free_mac_filt()
9327 p->valid_to_idx = cpu_to_be16( in t4_free_mac_filt()
9330 memcpy(p->macaddr, addr[offset+i], sizeof(p->macaddr)); in t4_free_mac_filt()
9339 be16_to_cpu(p->valid_to_idx)); in t4_free_mac_filt()
9346 rem -= fw_naddr; in t4_free_mac_filt()
9355 * t4_change_mac - modifies the exact-match filter for a MAC address
9359 * @idx: index of existing filter for old value of MAC address, or -1
9360 * @addr: the new MAC address value
9364 * Modifies an exact-match filter and sets it to the new MAC address if
9377 int idx, const u8 *addr, bool persist, uint16_t *smt_idx) in t4_change_mac() argument
9382 unsigned int max_mac_addr = adap->chip_params->mps_tcam_size; in t4_change_mac()
9393 p->valid_to_idx = cpu_to_be16(F_FW_VI_MAC_CMD_VALID | in t4_change_mac()
9396 memcpy(p->macaddr, addr, sizeof(p->macaddr)); in t4_change_mac()
9400 ret = G_FW_VI_MAC_CMD_IDX(be16_to_cpu(p->valid_to_idx)); in t4_change_mac()
9402 ret = -ENOMEM; in t4_change_mac()
9404 if (adap->params.viid_smt_extn_support) in t4_change_mac()
9418 * t4_set_addr_hash - program the MAC inexact-match hash filter
9426 * Sets the 64-bit inexact-match hash filter for a virtual interface.
9446 * t4_enable_vi_params - enable/disable a virtual interface
9474 * t4_enable_vi - enable/disable a virtual interface
9491 * t4_identify_port - identify a VI's port by blinking its LED
9514 * t4_iq_stop - stop an ingress queue and its FLs
9547 * t4_iq_free - free an ingress queue and its FLs
9578 * t4_eth_eq_stop - stop an Ethernet egress queue
9604 * t4_eth_eq_free - free an Ethernet egress queue
9629 * t4_ctrl_eq_free - free a control egress queue
9654 * t4_ofld_eq_free - free an offload egress queue
9679 * t4_link_down_rc_str - return a string for a Link Down Reason Code
9689 "Auto-negotiation Failure", in t4_link_down_rc_str()
9782 * lstatus_to_fwcap - translate old lstatus to 32-bit Port Capabilities
9786 * 32-bit Port Capabilities value.
9794 * 16-bit Port Information message isn't the same as the in lstatus_to_fwcap()
9795 * 16-bit Port Capabilities bitfield used everywhere else ... in lstatus_to_fwcap()
9825 struct link_config old_lc, *lc = &pi->link_cfg; in handle_port_info()
9830 old_ptype = pi->port_type; in handle_port_info()
9831 old_mtype = pi->mod_type; in handle_port_info()
9834 stat = be32_to_cpu(p->u.info.lstatus_to_modtype); in handle_port_info()
9836 pi->port_type = G_FW_PORT_CMD_PTYPE(stat); in handle_port_info()
9837 pi->mod_type = G_FW_PORT_CMD_MODTYPE(stat); in handle_port_info()
9838 pi->mdio_addr = stat & F_FW_PORT_CMD_MDIOCAP ? in handle_port_info()
9839 G_FW_PORT_CMD_MDIOADDR(stat) : -1; in handle_port_info()
9841 lc->pcaps = fwcaps16_to_caps32(be16_to_cpu(p->u.info.pcap)); in handle_port_info()
9842 lc->acaps = fwcaps16_to_caps32(be16_to_cpu(p->u.info.acap)); in handle_port_info()
9843 lc->lpacaps = fwcaps16_to_caps32(be16_to_cpu(p->u.info.lpacap)); in handle_port_info()
9844 lc->link_ok = (stat & F_FW_PORT_CMD_LSTATUS) != 0; in handle_port_info()
9845 lc->link_down_rc = G_FW_PORT_CMD_LINKDNRC(stat); in handle_port_info()
9849 stat = be32_to_cpu(p->u.info32.lstatus32_to_cbllen32); in handle_port_info()
9851 pi->port_type = G_FW_PORT_CMD_PORTTYPE32(stat); in handle_port_info()
9852 pi->mod_type = G_FW_PORT_CMD_MODTYPE32(stat); in handle_port_info()
9853 pi->mdio_addr = stat & F_FW_PORT_CMD_MDIOCAP32 ? in handle_port_info()
9854 G_FW_PORT_CMD_MDIOADDR32(stat) : -1; in handle_port_info()
9856 lc->pcaps = be32_to_cpu(p->u.info32.pcaps32); in handle_port_info()
9857 lc->acaps = be32_to_cpu(p->u.info32.acaps32); in handle_port_info()
9858 lc->lpacaps = be32_to_cpu(p->u.info32.lpacaps32); in handle_port_info()
9859 lc->link_ok = (stat & F_FW_PORT_CMD_LSTATUS32) != 0; in handle_port_info()
9860 lc->link_down_rc = G_FW_PORT_CMD_LINKDNRC32(stat); in handle_port_info()
9862 linkattr = be32_to_cpu(p->u.info32.linkattr32); in handle_port_info()
9864 CH_ERR(pi->adapter, "bad port_info action 0x%x\n", action); in handle_port_info()
9868 lc->speed = fwcap_to_speed(linkattr); in handle_port_info()
9869 lc->fec = fwcap_to_fec(linkattr, true); in handle_port_info()
9876 lc->fc = fc; in handle_port_info()
9882 if (old_ptype != pi->port_type || old_mtype != pi->mod_type || in handle_port_info()
9883 old_lc.pcaps != lc->pcaps) { in handle_port_info()
9884 if (pi->mod_type != FW_PORT_MOD_TYPE_NONE) in handle_port_info()
9885 lc->fec_hint = fwcap_to_fec(lc->acaps, true); in handle_port_info()
9889 if (old_lc.link_ok != lc->link_ok || old_lc.speed != lc->speed || in handle_port_info()
9890 old_lc.fec != lc->fec || old_lc.fc != lc->fc) { in handle_port_info()
9897 * t4_update_port_info - retrieve and update port information if changed
9906 struct adapter *sc = pi->adapter; in t4_update_port_info()
9914 V_FW_PORT_CMD_PORTID(pi->hw_port)); in t4_update_port_info()
9915 action = sc->params.port_caps32 ? FW_PORT_ACTION_GET_PORT_INFO32 : in t4_update_port_info()
9919 ret = t4_wr_mbox_ns(sc, sc->mbox, &cmd, sizeof(cmd), &cmd); in t4_update_port_info()
9928 * t4_handle_fw_rpl - process a FW reply message
9939 G_FW_PORT_CMD_ACTION(be32_to_cpu(p->action_to_len16)); in t4_handle_fw_rpl()
9946 int hw_port = G_FW_PORT_CMD_PORTID(be32_to_cpu(p->op_to_portid)); in t4_handle_fw_rpl()
9947 int port_id = adap->port_map[hw_port]; in t4_handle_fw_rpl()
9950 MPASS(port_id >= 0 && port_id < adap->params.nports); in t4_handle_fw_rpl()
9951 pi = adap->port[port_id]; in t4_handle_fw_rpl()
9964 return -EINVAL; in t4_handle_fw_rpl()
9970 * get_pci_mode - determine a card's PCI mode
9986 p->speed = val & PCI_EXP_LNKSTA_CLS; in get_pci_mode()
9987 p->width = (val & PCI_EXP_LNKSTA_NLW) >> 4; in get_pci_mode()
9999 * Table for non-standard supported Flash parts. Note, all Flash in t4_get_flash_params()
10026 * Check to see if it's one of our non-standard supported Flash parts. in t4_get_flash_params()
10030 adapter->params.sf_size = in t4_get_flash_params()
10032 adapter->params.sf_nsec = in t4_get_flash_params()
10033 adapter->params.sf_size / SF_SEC_SIZE; in t4_get_flash_params()
10050 * This Density -> Size decoding table is taken from Micron in t4_get_flash_params()
10067 case 0x9d: /* ISSI -- Integrated Silicon Solution, Inc. */ in t4_get_flash_params()
10069 * This Density -> Size decoding table is taken from ISSI in t4_get_flash_params()
10081 * This Density -> Size decoding table is taken from Macronix in t4_get_flash_params()
10093 * This Density -> Size decoding table is taken from Winbond in t4_get_flash_params()
10119 adapter->params.sf_size = size; in t4_get_flash_params()
10120 adapter->params.sf_nsec = size / SF_SEC_SIZE; in t4_get_flash_params()
10128 if (adapter->params.sf_size < FLASH_MIN_SIZE) in t4_get_flash_params()
10130 flashid, adapter->params.sf_size, FLASH_MIN_SIZE); in t4_get_flash_params()
10227 chipid -= CHELSIO_T4; in t4_get_chip_params()
10235 * t4_prep_adapter - prepare SW and HW for operation
10249 get_pci_mode(adapter, &adapter->params.pci); in t4_prep_adapter()
10252 adapter->params.chipid = G_CHIPID(pl_rev); in t4_prep_adapter()
10253 adapter->params.rev = G_REV(pl_rev); in t4_prep_adapter()
10254 if (adapter->params.chipid == 0) { in t4_prep_adapter()
10256 adapter->params.chipid = CHELSIO_T4; in t4_prep_adapter()
10259 if (adapter->params.rev == 1) { in t4_prep_adapter()
10261 return -EINVAL; in t4_prep_adapter()
10265 adapter->chip_params = t4_get_chip_params(chip_id(adapter)); in t4_prep_adapter()
10266 if (adapter->chip_params == NULL) in t4_prep_adapter()
10267 return -EINVAL; in t4_prep_adapter()
10269 adapter->params.pci.vpd_cap_addr = in t4_prep_adapter()
10279 adapter->params.cim_la_size = adapter->chip_params->cim_la_size; in t4_prep_adapter()
10282 adapter->params.fpga = 1; in t4_prep_adapter()
10283 adapter->params.cim_la_size = 2 * adapter->chip_params->cim_la_size; in t4_prep_adapter()
10286 ret = get_vpd_params(adapter, &adapter->params.vpd, device_id, buf); in t4_prep_adapter()
10290 init_cong_ctrl(adapter->params.a_wnd, adapter->params.b_wnd); in t4_prep_adapter()
10295 adapter->params.nports = 1; in t4_prep_adapter()
10296 adapter->params.portvec = 1; in t4_prep_adapter()
10297 adapter->params.vpd.cclk = 50000; in t4_prep_adapter()
10305 * t4_shutdown_adapter - shut down adapter, host & wire
10313 * the port Link Status to go down -- if register writes work --
10319 const bool bt = adapter->bt_map != 0; in t4_shutdown_adapter()
10348 * t4_bar2_sge_qregs - return BAR2 SGE Queue register information
10388 return -EINVAL; in t4_bar2_sge_qregs()
10392 page_shift = adapter->params.sge.page_shift; in t4_bar2_sge_qregs()
10398 ? adapter->params.sge.eq_s_qpp in t4_bar2_sge_qregs()
10399 : adapter->params.sge.iq_s_qpp); in t4_bar2_sge_qregs()
10400 qpp_mask = (1 << qpp_shift) - 1; in t4_bar2_sge_qregs()
10422 * from the writes to the registers -- the Write Combined Doorbell in t4_bar2_sge_qregs()
10440 * t4_init_devlog_ncores_params - initialize adap->params.devlog and ncores
10446 struct devlog_params *dparams = &adap->params.devlog; in t4_init_devlog_ncores_params()
10463 adap->params.ncores = 1 << ncore_shift; in t4_init_devlog_ncores_params()
10465 dparams->memtype = G_PCIE_FW_PF_DEVLOG_MEMTYPE(pf_dparams); in t4_init_devlog_ncores_params()
10466 dparams->start = G_PCIE_FW_PF_DEVLOG_ADDR16(pf_dparams) << 4; in t4_init_devlog_ncores_params()
10469 dparams->size = nentries * sizeof(struct fw_devlog_e); in t4_init_devlog_ncores_params()
10477 adap->params.ncores = 1; in t4_init_devlog_ncores_params()
10485 return -ENXIO; in t4_init_devlog_ncores_params()
10493 ret = t4_wr_mbox(adap, adap->mbox, &devlog_cmd, sizeof(devlog_cmd), in t4_init_devlog_ncores_params()
10500 dparams->memtype = G_FW_DEVLOG_CMD_MEMTYPE_DEVLOG(devlog_meminfo); in t4_init_devlog_ncores_params()
10501 dparams->start = G_FW_DEVLOG_CMD_MEMADDR16_DEVLOG(devlog_meminfo) << 4; in t4_init_devlog_ncores_params()
10502 dparams->size = be32_to_cpu(devlog_cmd.memsize_devlog); in t4_init_devlog_ncores_params()
10508 * t4_init_sge_params - initialize adap->params.sge
10516 struct sge_params *sp = &adapter->params.sge; in t4_init_sge_params()
10520 sp->counter_val[0] = G_THRESHOLD_0(r); in t4_init_sge_params()
10521 sp->counter_val[1] = G_THRESHOLD_1(r); in t4_init_sge_params()
10522 sp->counter_val[2] = G_THRESHOLD_2(r); in t4_init_sge_params()
10523 sp->counter_val[3] = G_THRESHOLD_3(r); in t4_init_sge_params()
10535 sp->timer_val[0] = core_ticks_to_us(adapter, G_TIMERVALUE0(r)) * tscale; in t4_init_sge_params()
10536 sp->timer_val[1] = core_ticks_to_us(adapter, G_TIMERVALUE1(r)) * tscale; in t4_init_sge_params()
10538 sp->timer_val[2] = core_ticks_to_us(adapter, G_TIMERVALUE2(r)) * tscale; in t4_init_sge_params()
10539 sp->timer_val[3] = core_ticks_to_us(adapter, G_TIMERVALUE3(r)) * tscale; in t4_init_sge_params()
10541 sp->timer_val[4] = core_ticks_to_us(adapter, G_TIMERVALUE4(r)) * tscale; in t4_init_sge_params()
10542 sp->timer_val[5] = core_ticks_to_us(adapter, G_TIMERVALUE5(r)) * tscale; in t4_init_sge_params()
10545 sp->fl_starve_threshold = G_EGRTHRESHOLD(r) * 2 + 1; in t4_init_sge_params()
10547 sp->fl_starve_threshold2 = sp->fl_starve_threshold; in t4_init_sge_params()
10549 sp->fl_starve_threshold2 = G_EGRTHRESHOLDPACKING(r) * 2 + 1; in t4_init_sge_params()
10551 sp->fl_starve_threshold2 = G_T6_EGRTHRESHOLDPACKING(r) * 2 + 1; in t4_init_sge_params()
10556 (S_QUEUESPERPAGEPF1 - S_QUEUESPERPAGEPF0) * adapter->pf; in t4_init_sge_params()
10557 sp->eq_s_qpp = r & M_QUEUESPERPAGEPF0; in t4_init_sge_params()
10562 (S_QUEUESPERPAGEPF1 - S_QUEUESPERPAGEPF0) * adapter->pf; in t4_init_sge_params()
10563 sp->iq_s_qpp = r & M_QUEUESPERPAGEPF0; in t4_init_sge_params()
10567 (S_HOSTPAGESIZEPF1 - S_HOSTPAGESIZEPF0) * adapter->pf; in t4_init_sge_params()
10568 sp->page_shift = (r & M_HOSTPAGESIZEPF0) + 10; in t4_init_sge_params()
10571 sp->sge_control = r; in t4_init_sge_params()
10572 sp->spg_len = r & F_EGRSTATUSPAGESIZE ? 128 : 64; in t4_init_sge_params()
10573 sp->fl_pktshift = G_PKTSHIFT(r); in t4_init_sge_params()
10575 sp->pad_boundary = 1 << (G_INGPADBOUNDARY(r) + in t4_init_sge_params()
10578 sp->pad_boundary = 1 << (G_INGPADBOUNDARY(r) + in t4_init_sge_params()
10582 sp->pack_boundary = sp->pad_boundary; in t4_init_sge_params()
10586 sp->pack_boundary = 16; in t4_init_sge_params()
10588 sp->pack_boundary = 1 << (G_INGPACKBOUNDARY(r) + 5); in t4_init_sge_params()
10591 sp->sge_fl_buffer_size[i] = t4_read_reg(adapter, in t4_init_sge_params()
10617 mask = (1 << t4_filter_field_width(adap, i)) - 1; in hashmask_to_filtermask()
10634 struct tp_params *tpp = &adap->params.tp; in read_filter_mode_and_ingress_config()
10643 rc = -t4_query_params(adap, adap->mbox, adap->pf, 0, 2, param, val); in read_filter_mode_and_ingress_config()
10645 tpp->filter_mode = G_FW_PARAMS_PARAM_FILTER_MODE(val[0]); in read_filter_mode_and_ingress_config()
10646 tpp->filter_mask = G_FW_PARAMS_PARAM_FILTER_MASK(val[0]); in read_filter_mode_and_ingress_config()
10647 tpp->vnic_mode = val[1]; in read_filter_mode_and_ingress_config()
10654 tpp->filter_mode = v & 0xffff; in read_filter_mode_and_ingress_config()
10671 tpp->filter_mask = hashmask_to_filtermask(adap, hash_mask, in read_filter_mode_and_ingress_config()
10672 tpp->filter_mode); in read_filter_mode_and_ingress_config()
10676 tpp->vnic_mode = FW_VNIC_MODE_PF_VF; in read_filter_mode_and_ingress_config()
10678 tpp->vnic_mode = FW_VNIC_MODE_OUTER_VLAN; in read_filter_mode_and_ingress_config()
10687 tpp->ipsecidx_shift = t4_filter_field_shift(adap, F_IPSECIDX); in read_filter_mode_and_ingress_config()
10688 tpp->fcoe_shift = t4_filter_field_shift(adap, F_T7_FCOE); in read_filter_mode_and_ingress_config()
10689 tpp->port_shift = t4_filter_field_shift(adap, F_T7_PORT); in read_filter_mode_and_ingress_config()
10690 tpp->vnic_shift = t4_filter_field_shift(adap, F_T7_VNIC_ID); in read_filter_mode_and_ingress_config()
10691 tpp->vlan_shift = t4_filter_field_shift(adap, F_T7_VLAN); in read_filter_mode_and_ingress_config()
10692 tpp->tos_shift = t4_filter_field_shift(adap, F_T7_TOS); in read_filter_mode_and_ingress_config()
10693 tpp->protocol_shift = t4_filter_field_shift(adap, F_T7_PROTOCOL); in read_filter_mode_and_ingress_config()
10694 tpp->ethertype_shift = t4_filter_field_shift(adap, F_T7_ETHERTYPE); in read_filter_mode_and_ingress_config()
10695 tpp->macmatch_shift = t4_filter_field_shift(adap, F_T7_MACMATCH); in read_filter_mode_and_ingress_config()
10696 tpp->matchtype_shift = t4_filter_field_shift(adap, F_T7_MPSHITTYPE); in read_filter_mode_and_ingress_config()
10697 tpp->frag_shift = t4_filter_field_shift(adap, F_T7_FRAGMENTATION); in read_filter_mode_and_ingress_config()
10698 tpp->roce_shift = t4_filter_field_shift(adap, F_ROCE); in read_filter_mode_and_ingress_config()
10699 tpp->synonly_shift = t4_filter_field_shift(adap, F_SYNONLY); in read_filter_mode_and_ingress_config()
10700 tpp->tcpflags_shift = t4_filter_field_shift(adap, F_TCPFLAGS); in read_filter_mode_and_ingress_config()
10702 tpp->ipsecidx_shift = -1; in read_filter_mode_and_ingress_config()
10703 tpp->fcoe_shift = t4_filter_field_shift(adap, F_FCOE); in read_filter_mode_and_ingress_config()
10704 tpp->port_shift = t4_filter_field_shift(adap, F_PORT); in read_filter_mode_and_ingress_config()
10705 tpp->vnic_shift = t4_filter_field_shift(adap, F_VNIC_ID); in read_filter_mode_and_ingress_config()
10706 tpp->vlan_shift = t4_filter_field_shift(adap, F_VLAN); in read_filter_mode_and_ingress_config()
10707 tpp->tos_shift = t4_filter_field_shift(adap, F_TOS); in read_filter_mode_and_ingress_config()
10708 tpp->protocol_shift = t4_filter_field_shift(adap, F_PROTOCOL); in read_filter_mode_and_ingress_config()
10709 tpp->ethertype_shift = t4_filter_field_shift(adap, F_ETHERTYPE); in read_filter_mode_and_ingress_config()
10710 tpp->macmatch_shift = t4_filter_field_shift(adap, F_MACMATCH); in read_filter_mode_and_ingress_config()
10711 tpp->matchtype_shift = t4_filter_field_shift(adap, F_MPSHITTYPE); in read_filter_mode_and_ingress_config()
10712 tpp->frag_shift = t4_filter_field_shift(adap, F_FRAGMENTATION); in read_filter_mode_and_ingress_config()
10713 tpp->roce_shift = -1; in read_filter_mode_and_ingress_config()
10714 tpp->synonly_shift = -1; in read_filter_mode_and_ingress_config()
10715 tpp->tcpflags_shift = -1; in read_filter_mode_and_ingress_config()
10720 * t4_init_tp_params - initialize adap->params.tp
10728 struct tp_params *tpp = &adap->params.tp; in t4_init_tp_params()
10731 tpp->tre = G_TIMERRESOLUTION(v); in t4_init_tp_params()
10732 tpp->dack_re = G_DELAYEDACKRESOLUTION(v); in t4_init_tp_params()
10736 tpp->rx_pkt_encap = false; in t4_init_tp_params()
10737 tpp->lb_mode = 0; in t4_init_tp_params()
10738 tpp->lb_nchan = 1; in t4_init_tp_params()
10741 tpp->rx_pkt_encap = v & F_CRXPKTENC; in t4_init_tp_params()
10744 tpp->lb_mode = G_T7_LB_MODE(v); in t4_init_tp_params()
10745 if (tpp->lb_mode == 1) in t4_init_tp_params()
10746 tpp->lb_nchan = 4; in t4_init_tp_params()
10747 else if (tpp->lb_mode == 2) in t4_init_tp_params()
10748 tpp->lb_nchan = 2; in t4_init_tp_params()
10764 tpp->max_tx_pdu = tx_len; in t4_init_tp_params()
10765 tpp->max_rx_pdu = rx_len; in t4_init_tp_params()
10771 * t4_filter_field_width - returns the width of a filter field
10781 const int nopt = adap->chip_params->filter_num_opt; in t4_filter_field_width()
10818 * t4_filter_field_shift - calculate filter field shift
10828 const unsigned int filter_mode = adap->params.tp.filter_mode; in t4_filter_field_shift()
10833 return -1; in t4_filter_field_shift()
10924 u8 addr[6]; in t4_port_init() local
10928 struct vi_info *vi = &p->vi[0]; in t4_port_init()
10930 for (i = 0, j = -1; i <= p->port_id; i++) { in t4_port_init()
10933 } while ((adap->params.portvec & (1 << j)) == 0); in t4_port_init()
10936 p->hw_port = j; in t4_port_init()
10937 p->tx_chan = t4_get_tx_c_chan(adap, j); in t4_port_init()
10938 p->rx_chan = t4_get_rx_c_chan(adap, j); in t4_port_init()
10939 p->mps_bg_map = t4_get_mps_bg_map(adap, j); in t4_port_init()
10940 p->rx_e_chan_map = t4_get_rx_e_chan_map(adap, j); in t4_port_init()
10942 if (!(adap->flags & IS_VF) || in t4_port_init()
10943 adap->params.vfres.r_caps & FW_CMD_CAP_PORT) { in t4_port_init()
10947 ret = t4_alloc_vi(adap, mbox, j, pf, vf, 1, addr, &vi->rss_size, in t4_port_init()
10948 &vi->vfvld, &vi->vin); in t4_port_init()
10952 vi->viid = ret; in t4_port_init()
10953 t4_os_set_hw_addr(p, addr); in t4_port_init()
10957 V_FW_PARAMS_PARAM_YZ(vi->viid); in t4_port_init()
10960 vi->rss_base = 0xffff; in t4_port_init()
10963 vi->rss_base = val & 0xffff; in t4_port_init()
10977 /* value is in 512-byte units */ in t4_read_cimq_cfg_ibq_core()
10981 /* value is in 256-byte units */ in t4_read_cimq_cfg_ibq_core()
10992 *thres = G_QUEFULLTHRSH(v) * 8; /* 8-byte unit */ in t4_read_cimq_cfg_ibq_core()
11003 /* value is in 512-byte units */ in t4_read_cimq_cfg_obq_core()
11007 /* value is in 256-byte units */ in t4_read_cimq_cfg_obq_core()
11020 * t4_read_cimq_cfg_core - read CIM queue configuration on specific core
11033 unsigned int cim_num_ibq = adap->chip_params->cim_num_ibq; in t4_read_cimq_cfg_core()
11034 unsigned int cim_num_obq = adap->chip_params->cim_num_obq; in t4_read_cimq_cfg_core()
11044 static int t4_read_cim_ibq_data_core(struct adapter *adap, u8 coreid, u32 addr, in t4_read_cim_ibq_data_core() argument
11050 /* It might take 3-10ms before the IBQ debug read access is allowed. in t4_read_cim_ibq_data_core()
11056 v = V_T7_IBQDBGADDR(addr) | V_IBQDBGCORE(coreid); in t4_read_cim_ibq_data_core()
11058 v = V_IBQDBGADDR(addr); in t4_read_cim_ibq_data_core()
11071 * t4_read_cim_ibq_core - read the contents of a CIM inbound queue on
11077 * @n: capacity of @data in 32-bit words
11081 * of 4. Returns < 0 on error and the number of 32-bit words actually
11087 unsigned int cim_num_ibq = adap->chip_params->cim_num_ibq; in t4_read_cim_ibq_core()
11088 u16 i, addr, nwords; in t4_read_cim_ibq_core() local
11091 if (qid > (cim_num_ibq - 1) || (n & 3)) in t4_read_cim_ibq_core()
11092 return -EINVAL; in t4_read_cim_ibq_core()
11094 t4_read_cimq_cfg_ibq_core(adap, coreid, qid, &addr, &nwords, NULL); in t4_read_cim_ibq_core()
11095 addr >>= sizeof(u16); in t4_read_cim_ibq_core()
11100 for (i = 0; i < n; i++, addr++, data++) { in t4_read_cim_ibq_core()
11101 ret = t4_read_cim_ibq_data_core(adap, coreid, addr, data); in t4_read_cim_ibq_core()
11110 static int t4_read_cim_obq_data_core(struct adapter *adap, u8 coreid, u32 addr, in t4_read_cim_obq_data_core() argument
11117 v = V_T7_OBQDBGADDR(addr) | V_OBQDBGCORE(coreid); in t4_read_cim_obq_data_core()
11119 v = V_OBQDBGADDR(addr); in t4_read_cim_obq_data_core()
11131 * t4_read_cim_obq_core - read the contents of a CIM outbound queue on
11137 * @n: capacity of @data in 32-bit words
11141 * of 4. Returns < 0 on error and the number of 32-bit words actually
11147 unsigned int cim_num_obq = adap->chip_params->cim_num_obq; in t4_read_cim_obq_core()
11148 u16 i, addr, nwords; in t4_read_cim_obq_core() local
11151 if ((qid > (cim_num_obq - 1)) || (n & 3)) in t4_read_cim_obq_core()
11152 return -EINVAL; in t4_read_cim_obq_core()
11154 t4_read_cimq_cfg_obq_core(adap, coreid, qid, &addr, &nwords); in t4_read_cim_obq_core()
11155 addr >>= sizeof(u16); in t4_read_cim_obq_core()
11160 for (i = 0; i < n; i++, addr++, data++) { in t4_read_cim_obq_core()
11161 ret = t4_read_cim_obq_data_core(adap, coreid, addr, data); in t4_read_cim_obq_core()
11171 * t4_cim_read_core - read a block from CIM internal address space
11176 * @addr: the start address within the CIM address space
11180 * Reads a block of 4-byte words from the CIM intenal address space
11184 unsigned int addr, unsigned int n, in t4_cim_read_core() argument
11198 return -EBUSY; in t4_cim_read_core()
11200 for ( ; !ret && n--; addr += 4) { in t4_cim_read_core()
11201 t4_write_reg(adap, A_CIM_HOST_ACC_CTRL, addr | v); in t4_cim_read_core()
11212 * t4_cim_write_core - write a block into CIM internal address space
11217 * @addr: the start address within the CIM address space
11221 * Writes a block of 4-byte words into the CIM intenal address space
11225 unsigned int addr, unsigned int n, in t4_cim_write_core() argument
11241 return -EBUSY; in t4_cim_write_core()
11243 for ( ; !ret && n--; addr += 4) { in t4_cim_write_core()
11245 t4_write_reg(adap, A_CIM_HOST_ACC_CTRL, addr | v); in t4_cim_write_core()
11254 * t4_cim_read_la_core - read CIM LA capture buffer on specific core
11291 for (i = 0; i < adap->params.cim_la_size; i++) { in t4_cim_read_la_core()
11302 ret = -ETIMEDOUT; in t4_cim_read_la_core()
11310 /* Bits 0-3 of UpDbgLaRdPtr can be between 0000 to 1001 to in t4_cim_read_la_core()
11311 * identify the 32-bit portion of the full 312-bit data in t4_cim_read_la_core()
11335 * t4_tp_read_la - read TP LA capture buffer
11352 adap->params.tp.la_mask | (cfg ^ F_DBGLAENABLE)); in t4_tp_read_la()
11364 val |= adap->params.tp.la_mask; in t4_tp_read_la()
11374 la_buf[TPLA_SIZE - 1] = ~0ULL; in t4_tp_read_la()
11378 cfg | adap->params.tp.la_mask); in t4_tp_read_la()
11393 * t4_idma_monitor_init - initialize SGE Ingress DMA Monitor
11395 * @idma: the adapter IDMA Monitor state
11400 struct sge_idma_monitor_state *idma) in t4_idma_monitor_init() argument
11414 idma->idma_1s_thresh = core_ticks_per_usec(adapter) * 1000000; /* 1s */ in t4_idma_monitor_init()
11415 idma->idma_stalled[0] = idma->idma_stalled[1] = 0; in t4_idma_monitor_init()
11419 * t4_idma_monitor - monitor SGE Ingress DMA state
11421 * @idma: the adapter IDMA Monitor state
11423 * @ticks: number of ticks since the last IDMA Monitor call
11426 struct sge_idma_monitor_state *idma, in t4_idma_monitor() argument
11436 * threshold they'll stay above that till the IDMA state changes. in t4_idma_monitor()
11451 if (idma_same_state_cnt[i] < idma->idma_1s_thresh) { in t4_idma_monitor()
11452 if (idma->idma_stalled[i] >= SGE_IDMA_WARN_THRESH*hz) in t4_idma_monitor()
11453 CH_WARN(adapter, "SGE idma%d, queue %u, " in t4_idma_monitor()
11455 i, idma->idma_qid[i], in t4_idma_monitor()
11456 idma->idma_stalled[i]/hz); in t4_idma_monitor()
11457 idma->idma_stalled[i] = 0; in t4_idma_monitor()
11470 if (idma->idma_stalled[i] == 0) { in t4_idma_monitor()
11471 idma->idma_stalled[i] = hz; in t4_idma_monitor()
11472 idma->idma_warn[i] = 0; in t4_idma_monitor()
11474 idma->idma_stalled[i] += ticks; in t4_idma_monitor()
11475 idma->idma_warn[i] -= ticks; in t4_idma_monitor()
11478 if (idma->idma_stalled[i] < SGE_IDMA_WARN_THRESH*hz) in t4_idma_monitor()
11483 if (idma->idma_warn[i] > 0) in t4_idma_monitor()
11485 idma->idma_warn[i] = SGE_IDMA_WARN_REPEAT*hz; in t4_idma_monitor()
11487 /* Read and save the SGE IDMA State and Queue ID information. in t4_idma_monitor()
11493 idma->idma_state[i] = (debug0 >> (i * 9)) & 0x3f; in t4_idma_monitor()
11497 idma->idma_qid[i] = (debug11 >> (i * 16)) & 0xffff; in t4_idma_monitor()
11499 CH_WARN(adapter, "SGE idma%u, queue %u, potentially stuck in " in t4_idma_monitor()
11501 i, idma->idma_qid[i], idma->idma_state[i], in t4_idma_monitor()
11502 idma->idma_stalled[i]/hz, in t4_idma_monitor()
11504 t4_sge_decode_idma_state(adapter, idma->idma_state[i]); in t4_idma_monitor()
11509 * t4_set_vf_mac - Set MAC address for the specified VF
11514 * @addr: the MAC address(es) to be set to the specified VF
11517 unsigned int naddr, u8 *addr) in t4_set_vf_mac() argument
11534 memcpy(cmd.macaddr3, addr, sizeof(cmd.macaddr3)); in t4_set_vf_mac()
11537 memcpy(cmd.macaddr2, addr, sizeof(cmd.macaddr2)); in t4_set_vf_mac()
11540 memcpy(cmd.macaddr1, addr, sizeof(cmd.macaddr1)); in t4_set_vf_mac()
11543 memcpy(cmd.macaddr0, addr, sizeof(cmd.macaddr0)); in t4_set_vf_mac()
11547 return t4_wr_mbox(adapter, adapter->mbox, &cmd, sizeof(cmd), &cmd); in t4_set_vf_mac()
11551 * t4_read_pace_tbl - read the pace table
11569 * t4_get_tx_sched - get the configuration of a Tx HW traffic scheduler
11580 unsigned int v, addr, bpt, cpt; in t4_get_tx_sched() local
11583 addr = A_TP_TX_MOD_Q1_Q0_RATE_LIMIT - sched / 2; in t4_get_tx_sched()
11584 t4_tp_tm_pio_read(adap, &v, 1, addr, sleep_ok); in t4_get_tx_sched()
11592 v = (adap->params.vpd.cclk * 1000) / cpt; /* ticks/s */ in t4_get_tx_sched()
11597 addr = A_TP_TX_MOD_Q1_Q0_TIMER_SEPARATOR - sched / 2; in t4_get_tx_sched()
11598 t4_tp_tm_pio_read(adap, &v, 1, addr, sleep_ok); in t4_get_tx_sched()
11607 * t4_load_cfg - download config file
11617 unsigned int addr, len; in t4_load_cfg() local
11626 return -EFBIG; in t4_load_cfg()
11632 flash_cfg_start_sec + i - 1); in t4_load_cfg()
11635 * with the on-adapter Firmware Configuration File. in t4_load_cfg()
11641 addr = cfg_addr; in t4_load_cfg()
11643 n = min(size - i, SF_PAGE_SIZE); in t4_load_cfg()
11644 ret = t4_write_flash(adap, addr, n, cfg_data, 1); in t4_load_cfg()
11647 addr += SF_PAGE_SIZE; in t4_load_cfg()
11659 * t5_fw_init_extern_mem - initialize the external memory
11675 ret = t4_set_params_timeout(adap, adap->mbox, adap->pf, 0, 1, params, val, in t5_fw_init_extern_mem()
11710 * 0x2-0xFFFF: Reserved
11731 * 0x00: Intel IA-32, PC-AT compatible. Legacy
11733 * 0x02: Hewlett-Packard PA RISC. HP reserved
11735 * 0x04-0xFF: Reserved.
11753 * modify_device_id - Modifies the device ID of the Boot BIOS image
11771 le16_to_cpu(*(u16*)header->pcir_offset)]; in modify_device_id()
11778 * 0x04-0xFF: Do not modify in modify_device_id()
11780 if (pcir_header->code_type == 0x00) { in modify_device_id()
11787 *(u16*) pcir_header->device_id = device_id; in modify_device_id()
11793 header->cksum = 0x0; in modify_device_id()
11798 for (i = 0; i < (header->size512 * 512); i++) in modify_device_id()
11805 boot_data[cur_header + 7] = -csum; in modify_device_id()
11807 } else if (pcir_header->code_type == 0x03) { in modify_device_id()
11812 *(u16*) pcir_header->device_id = device_id; in modify_device_id()
11821 if (pcir_header->indicator & 0x80) in modify_device_id()
11827 cur_header += header->size512 * 512; in modify_device_id()
11832 * t4_load_boot - download boot flash
11839 * The boot image has the following sections: a 28-byte header and the
11848 int ret, addr; in t4_load_boot() local
11860 return -EFBIG; in t4_load_boot()
11864 * The boot sector is comprised of the Expansion-ROM boot, iSCSI boot, in t4_load_boot()
11870 (boot_sector >> 16) + i - 1); in t4_load_boot()
11874 * with the on-adapter option ROM file in t4_load_boot()
11881 pcir_offset = le16_to_cpu(*(u16 *)header->pcir_offset); in t4_load_boot()
11892 return -EFBIG; in t4_load_boot()
11899 if (le16_to_cpu(*(u16*)header->signature) != BOOT_SIGNATURE ) { in t4_load_boot()
11901 return -EINVAL; in t4_load_boot()
11907 if (le32_to_cpu(*(u32*)pcir_header->signature) != PCIR_SIGNATURE) { in t4_load_boot()
11909 return -EINVAL; in t4_load_boot()
11915 if (le16_to_cpu(*(u16*)pcir_header->vendor_id) != VENDOR_ID) { in t4_load_boot()
11917 return -EINVAL; in t4_load_boot()
11931 if (le16_to_cpu(*(u16*)pcir_header->device_id) != device_id) { in t4_load_boot()
11945 addr = boot_sector; in t4_load_boot()
11946 for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) { in t4_load_boot()
11947 addr += SF_PAGE_SIZE; in t4_load_boot()
11949 ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, boot_data, 0); in t4_load_boot()
11964 * t4_flash_bootcfg_addr - return the address of the flash optionrom configuration
11980 if (adapter->params.sf_size < start + len) in t4_flash_bootcfg_addr()
11981 return -ENOSPC; in t4_flash_bootcfg_addr()
11990 unsigned int addr, len; in t4_load_bootcfg() local
11999 return -EFBIG; in t4_load_bootcfg()
12005 flash_cfg_start_sec + i - 1); in t4_load_bootcfg()
12009 * with the on-adapter OptionROM Configuration File. in t4_load_bootcfg()
12015 addr = cfg_addr; in t4_load_bootcfg()
12017 n = min(size - i, SF_PAGE_SIZE); in t4_load_bootcfg()
12018 ret = t4_write_flash(adap, addr, n, cfg_data, 0); in t4_load_bootcfg()
12021 addr += SF_PAGE_SIZE; in t4_load_bootcfg()
12033 * t4_set_filter_cfg - set up filter mode/mask and ingress config.
12049 const int maxbits = adap->chip_params->filter_opt_len; in t4_set_filter_cfg()
12050 const int nopt = adap->chip_params->filter_num_opt; in t4_set_filter_cfg()
12053 if (mode != -1 || mask != -1) { in t4_set_filter_cfg()
12054 if (mode != -1) { in t4_set_filter_cfg()
12066 return -E2BIG; in t4_set_filter_cfg()
12087 fmask = fmode & adap->params.tp.filter_mask; in t4_set_filter_cfg()
12088 if (fmask != adap->params.tp.filter_mask) { in t4_set_filter_cfg()
12092 adap->params.tp.filter_mask, fmask, fmode); in t4_set_filter_cfg()
12095 fmode = adap->params.tp.filter_mode; in t4_set_filter_cfg()
12101 return -EINVAL; in t4_set_filter_cfg()
12110 rc = t4_set_params(adap, adap->mbox, adap->pf, 0, 1, ¶m, in t4_set_filter_cfg()
12116 if (vnic_mode != -1) { in t4_set_filter_cfg()
12121 rc = t4_set_params(adap, adap->mbox, adap->pf, 0, 1, ¶m, in t4_set_filter_cfg()
12134 * t4_clr_port_stats - clear port statistics
12146 port_id = adap->port_map[idx]; in t4_clr_port_stats()
12147 MPASS(port_id >= 0 && port_id <= adap->params.nports); in t4_clr_port_stats()
12148 pi = adap->port[port_id]; in t4_clr_port_stats()
12150 for (tx_chan = pi->tx_chan; in t4_clr_port_stats()
12151 tx_chan < pi->tx_chan + adap->params.tp.lb_nchan; tx_chan++) { in t4_clr_port_stats()
12161 bgmap = pi->mps_bg_map; in t4_clr_port_stats()
12172 * t4_i2c_io - read/write I2C data from adapter
12174 * @port: Port number if per-port device; <0 if not
12175 * @devid: per-port device ID or absolute device ID
12193 return -EINVAL; in t4_i2c_io()
12197 return -EINVAL; in t4_i2c_io()
12227 len -= i2c_len; in t4_i2c_io()
12250 * t4_sge_ctxt_rd - read an SGE context through FW
12296 * t4_sge_ctxt_rd_bd - read an SGE context bypassing FW
12336 return t4_wr_mbox_meat(adapter,adapter->mbox, &cmd, sizeof(cmd), in t4_sched_config()
12367 return t4_wr_mbox_meat(adapter,adapter->mbox, &cmd, sizeof(cmd), in t4_sched_params()
12389 return t4_wr_mbox_meat(adapter,adapter->mbox, &cmd, sizeof(cmd), in t4_sched_params_ch_rl()
12399 return -EINVAL; in t4_sched_params_cl_wrr()
12414 return t4_wr_mbox_meat(adapter,adapter->mbox, &cmd, sizeof(cmd), in t4_sched_params_cl_wrr()
12440 return t4_wr_mbox_meat(adapter,adapter->mbox, &cmd, sizeof(cmd), in t4_sched_params_cl_rl_kbps()
12445 * t4_config_watchdog - configure (enable/disable) a watchdog timer
12454 * action. Configure one of the watchdog timers by setting a non-zero
12467 * "tick" if the timeout is non-zero but the conversion results in 0 in t4_config_watchdog()
12496 ret = t4_wr_mbox(adapter, adapter->mbox, &devlog_cmd, in t4_get_devlog_level()
12515 return t4_wr_mbox(adapter, adapter->mbox, &devlog_cmd, in t4_set_devlog_level()
12524 adap->params.smac_add_support = 0; in t4_configure_add_smac()
12533 ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1, ¶m, &val); in t4_configure_add_smac()
12538 ret = t4_set_params(adap, adap->mbox, adap->pf, 0, 1, in t4_configure_add_smac()
12544 adap->params.smac_add_support = 1; in t4_configure_add_smac()
12562 ret = t4_query_params(adap, adap->mbox, adap->pf, 0, 1, ¶m, &val); in t4_configure_ringbb()
12574 ret = t4_set_params(adap, adap->mbox, adap->pf, 0, 1, ¶m, &val); in t4_configure_ringbb()
12586 * t4_set_vlan_acl - Set a VLAN id for the specified VF
12619 return t4_wr_mbox(adap, adap->mbox, &vlan_cmd, sizeof(vlan_cmd), NULL); in t4_set_vlan_acl()
12623 * t4_del_mac - Removes the exact-match filter for a MAC address
12627 * @addr: the MAC address value
12630 * Modifies an exact-match filter and sets it to the new MAC address if
12638 const u8 *addr, bool smac) in t4_del_mac() argument
12643 unsigned int max_mac_addr = adap->chip_params->mps_tcam_size; in t4_del_mac()
12653 memcpy(p->macaddr, addr, sizeof(p->macaddr)); in t4_del_mac()
12654 p->valid_to_idx = cpu_to_be16( in t4_del_mac()
12660 ret = G_FW_VI_MAC_CMD_IDX(be16_to_cpu(p->valid_to_idx)); in t4_del_mac()
12662 return -ENOMEM; in t4_del_mac()
12669 * t4_add_mac - Adds an exact-match filter for a MAC address
12673 * @idx: index of existing filter for old value of MAC address, or -1
12674 * @addr: the new MAC address value
12679 * Modifies an exact-match filter and sets it to the new MAC address if
12687 int idx, const u8 *addr, bool persist, u8 *smt_idx, bool smac) in t4_add_mac() argument
12692 unsigned int max_mac_addr = adap->chip_params->mps_tcam_size; in t4_add_mac()
12705 p->valid_to_idx = cpu_to_be16(F_FW_VI_MAC_CMD_VALID | in t4_add_mac()
12708 memcpy(p->macaddr, addr, sizeof(p->macaddr)); in t4_add_mac()
12712 ret = G_FW_VI_MAC_CMD_IDX(be16_to_cpu(p->valid_to_idx)); in t4_add_mac()
12714 return -ENOMEM; in t4_add_mac()
12717 if (adap->params.viid_smt_extn_support) in t4_add_mac()