60 u32 val = t4_read_reg(adapter, reg);
62 if (!!(val & mask) == polarity) {
74 static inline int t4_wait_op_done(
struct adapter *adapter,
int reg,
u32 mask,
75 int polarity,
int attempts,
int delay)
77 return t4_wait_op_done_val(adapter, reg, mask, polarity, attempts,
94 u32 v = t4_read_reg(adapter, addr) & ~mask;
96 t4_write_reg(adapter, addr, v | val);
97 (
void) t4_read_reg(adapter, addr);
112 static void t4_read_indirect(
struct adapter *adap,
unsigned int addr_reg,
113 unsigned int data_reg,
u32 *vals,
114 unsigned int nregs,
unsigned int start_idx)
117 t4_write_reg(adap, addr_reg, start_idx);
118 *vals++ = t4_read_reg(adap, data_reg);
136 unsigned int data_reg,
const u32 *vals,
137 unsigned int nregs,
unsigned int start_idx)
140 t4_write_reg(adap, addr_reg, start_idx++);
141 t4_write_reg(adap, data_reg, *vals++);
148 static void get_mbox_rpl(
struct adapter *adap,
__be64 *rpl,
int nflit,
151 for ( ; nflit; nflit--, mbox_addr += 8)
152 *rpl++ =
cpu_to_be64(t4_read_reg64(adap, mbox_addr));
158 static void fw_asrt(
struct adapter *adap,
u32 mbox_addr)
162 get_mbox_rpl(adap, (
__be64 *)&asrt,
sizeof(asrt) / 8, mbox_addr);
164 "FW assertion at %.16s:%u, val0 %#x, val1 %#x\n",
165 asrt.u.assert.filename_0_7,
ntohl(asrt.u.assert.line),
166 ntohl(asrt.u.assert.x),
ntohl(asrt.u.assert.y));
169 static void dump_mbox(
struct adapter *adap,
int mbox,
u32 data_reg)
172 "mbox %d: %llx %llx %llx %llx %llx %llx %llx %llx\n", mbox,
173 (
unsigned long long)t4_read_reg64(adap, data_reg),
174 (
unsigned long long)t4_read_reg64(adap, data_reg + 8),
175 (
unsigned long long)t4_read_reg64(adap, data_reg + 16),
176 (
unsigned long long)t4_read_reg64(adap, data_reg + 24),
177 (
unsigned long long)t4_read_reg64(adap, data_reg + 32),
178 (
unsigned long long)t4_read_reg64(adap, data_reg + 40),
179 (
unsigned long long)t4_read_reg64(adap, data_reg + 48),
180 (
unsigned long long)t4_read_reg64(adap, data_reg + 56));
206 void *rpl,
bool sleep_ok)
208 static const int delay[] = {
209 1, 1, 3, 5, 10, 10, 20, 50, 100, 200
214 int i,
ms, delay_idx;
236 for (i = 0; i <
size; i += 8)
237 t4_write_reg64(adap, data_reg + i,
be64_to_cpu(*p++));
240 t4_read_reg(adap, ctl_reg);
247 ms = delay[delay_idx];
254 v = t4_read_reg(adap, ctl_reg);
257 t4_write_reg(adap, ctl_reg, 0);
261 res = t4_read_reg64(adap, data_reg);
263 fw_asrt(adap, data_reg);
266 get_mbox_rpl(adap, rpl, size / 8, data_reg);
269 dump_mbox(adap, mbox, data_reg);
270 t4_write_reg(adap, ctl_reg, 0);
275 dump_mbox(adap, mbox, data_reg);
277 *(
const u8 *)cmd, mbox);
303 i = t4_wait_op_done(adap,
MC_BIST_CMD, START_BIST, 0, 10, 1);
307 #define MC_DATA(i) MC_BIST_STATUS_REG(MC_BIST_STATUS_RDATA, i)
309 for (i = 15; i >= 0; i--)
312 *ecc = t4_read_reg64(adap,
MC_DATA(16));
341 i = t4_wait_op_done(adap,
EDC_BIST_CMD + idx, START_BIST, 0, 10, 1);
345 #define EDC_DATA(i) (EDC_BIST_STATUS_REG(EDC_BIST_STATUS_RDATA, i) + idx)
347 for (i = 15; i >= 0; i--)
350 *ecc = t4_read_reg64(adap,
EDC_DATA(16));
409 static int t4_memory_rw(
struct adapter *adap,
int mtype,
u32 addr,
u32 len,
419 if ((addr & 0x3) || (len & 0x3))
422 data =
vmalloc(MEMWIN0_APERTURE);
432 memoffset = (mtype * (5 * 1024 * 1024));
435 addr = addr + memoffset;
443 start = addr & ~(MEMWIN0_APERTURE-1);
444 end = (addr + len + MEMWIN0_APERTURE-1) & ~(MEMWIN0_APERTURE-1);
458 if (offset || len < MEMWIN0_APERTURE) {
459 ret = t4_mem_win_rw(adap, pos, data, 1);
463 while (offset < (MEMWIN0_APERTURE/
sizeof(
__be32)) &&
465 data[offset++] = *buf++;
473 ret = t4_mem_win_rw(adap, pos, data, dir);
482 while (offset < (MEMWIN0_APERTURE/
sizeof(
__be32)) &&
484 *buf++ = data[offset++];
496 return t4_memory_rw(adap, mtype, addr, len, buf, 0);
499 #define EEPROM_STAT_ADDR 0x7bfc
512 unsigned int v = enable ? 0xc : 0;
514 return ret < 0 ? ret : 0;
526 u32 cclk_param, cclk_val;
530 unsigned int vpdr_len, kw_offset, id_len;
546 id_len = pci_vpd_lrdt_size(vpd);
557 vpdr_len = pci_vpd_lrdt_size(&vpd[i]);
559 if (vpdr_len + kw_offset >
VPD_LEN) {
565 #define FIND_VPD_KW(var, name) do { \
566 var = pci_vpd_find_info_keyword(vpd, kw_offset, vpdr_len, name); \
568 dev_err(adapter->pdev_dev, "missing VPD keyword " name "\n"); \
572 var += PCI_VPD_INFO_FLD_HDR_SIZE; \
576 for (csum = 0; i >= 0; i--)
581 "corrupted VPD EEPROM, actual csum %u\n", csum);
590 memcpy(p->
id, vpd + PCI_VPD_LRDT_TAG_SIZE, id_len);
605 1, &cclk_param, &cclk_val);
644 static int sf1_read(
struct adapter *adapter,
unsigned int byte_cnt,
int cont,
649 if (!byte_cnt || byte_cnt > 4)
655 t4_write_reg(adapter,
SF_OP, lock | cont |
BYTECNT(byte_cnt - 1));
658 *valp = t4_read_reg(adapter,
SF_DATA);
674 static int sf1_write(
struct adapter *adapter,
unsigned int byte_cnt,
int cont,
677 if (!byte_cnt || byte_cnt > 4)
683 t4_write_reg(adapter,
SF_DATA, val);
684 t4_write_reg(adapter,
SF_OP, lock |
697 static int flash_wait_op(
struct adapter *adapter,
int attempts,
int delay)
703 if ((ret = sf1_write(adapter, 1, 1, 1,
SF_RD_STATUS)) != 0 ||
704 (ret = sf1_read(adapter, 1, 0, 1, &status)) != 0)
728 static int t4_read_flash(
struct adapter *adapter,
unsigned int addr,
729 unsigned int nwords,
u32 *data,
int byte_oriented)
733 if (addr + nwords *
sizeof(
u32) > adapter->
params.sf_size || (addr & 3))
738 if ((ret = sf1_write(adapter, 4, 1, 0, addr)) != 0 ||
739 (ret = sf1_read(adapter, 1, 1, 0, data)) != 0)
742 for ( ; nwords; nwords--, data++) {
743 ret = sf1_read(adapter, 4, nwords > 1, nwords == 1, data);
745 t4_write_reg(adapter,
SF_OP, 0);
764 static int t4_write_flash(
struct adapter *adapter,
unsigned int addr,
765 unsigned int n,
const u8 *data)
769 unsigned int i,
c,
left,
val, offset = addr & 0xff;
776 if ((ret = sf1_write(adapter, 1, 0, 1,
SF_WR_ENABLE)) != 0 ||
777 (ret = sf1_write(adapter, 4, 1, 1, val)) != 0)
780 for (left = n;
left; left -=
c) {
782 for (val = 0, i = 0; i <
c; ++
i)
783 val = (val << 8) + *data++;
785 ret = sf1_write(adapter, c, c != left, 1, val);
789 ret = flash_wait_op(adapter, 8, 1);
793 t4_write_reg(adapter,
SF_OP, 0);
796 ret = t4_read_flash(adapter, addr & ~0xff,
ARRAY_SIZE(buf), buf, 1);
800 if (
memcmp(data - n, (
u8 *)buf + offset, n)) {
802 "failed to correctly write the flash page at %#x\n",
809 t4_write_reg(adapter,
SF_OP, 0);
820 static int get_fw_version(
struct adapter *adapter,
u32 *vers)
822 return t4_read_flash(adapter, adapter->
params.sf_fw_start +
833 static int get_tp_version(
struct adapter *adapter,
u32 *vers)
835 return t4_read_flash(adapter, adapter->
params.sf_fw_start +
854 ret = get_fw_version(adapter, &adapter->
params.fw_vers);
856 ret = get_tp_version(adapter, &adapter->
params.tp_vers);
858 ret = t4_read_flash(adapter, adapter->
params.sf_fw_start +
868 sizeof(adapter->
params.api_vers));
872 "card FW has major version %u, driver wants %u\n",
892 static int t4_flash_erase_sectors(
struct adapter *adapter,
int start,
int end)
896 while (start <= end) {
897 if ((ret = sf1_write(adapter, 1, 0, 1,
SF_WR_ENABLE)) != 0 ||
898 (ret = sf1_write(adapter, 4, 0, 1,
900 (ret = flash_wait_op(adapter, 14, 500)) != 0) {
902 "erase of flash sector %d failed, error %d\n",
908 t4_write_reg(adapter,
SF_OP, 0);
921 if (adapter->
params.sf_size == 0x100000)
939 unsigned int flash_cfg_start_sec;
940 unsigned int sf_sec_size = adap->
params.sf_size / adap->
params.sf_nsec;
953 ret = t4_flash_erase_sectors(adap, flash_cfg_start_sec,
954 flash_cfg_start_sec + i - 1);
959 if (ret || size == 0)
968 ret = t4_write_flash(adap, addr, n, cfg_data);
979 (size == 0 ?
"clear" :
"download"), ret);
999 unsigned int sf_sec_size = adap->
params.sf_size / adap->
params.sf_nsec;
1000 unsigned int fw_img_start = adap->
params.sf_fw_start;
1001 unsigned int fw_start_sec = fw_img_start / sf_sec_size;
1009 "FW image size not multiple of 512 bytes\n");
1014 "FW image size differs from size in FW header\n");
1023 for (csum = 0, i = 0; i < size /
sizeof(
csum); i++)
1024 csum +=
ntohl(p[i]);
1026 if (csum != 0xffffffff) {
1028 "corrupted firmware image, checksum %#x\n", csum);
1033 ret = t4_flash_erase_sectors(adap, fw_start_sec, fw_start_sec + i - 1);
1043 ((
struct fw_hdr *)first_page)->fw_ver =
htonl(0xffffffff);
1044 ret = t4_write_flash(adap, fw_img_start,
SF_PAGE_SIZE, first_page);
1048 addr = fw_img_start;
1052 ret = t4_write_flash(adap, addr,
SF_PAGE_SIZE, fw_data);
1057 ret = t4_write_flash(adap,
1067 #define ADVERT_MASK (FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G |\
1068 FW_PORT_CAP_SPEED_10G | FW_PORT_CAP_ANEG)
1095 memset(&c, 0,
sizeof(c));
1110 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
1125 memset(&c, 0,
sizeof(c));
1131 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
1140 unsigned short fatal;
1157 static int t4_handle_intr_status(
struct adapter *adapter,
unsigned int reg,
1161 unsigned int mask = 0;
1162 unsigned int status = t4_read_reg(adapter, reg);
1164 for ( ; acts->
mask; ++acts) {
1165 if (!(status & acts->
mask))
1169 dev_alert(adapter->
pdev_dev,
"%s (0x%x)\n", acts->
msg,
1170 status & acts->
mask);
1171 }
else if (acts->
msg && printk_ratelimit())
1173 status & acts->
mask);
1180 t4_write_reg(adapter, reg, status);
1187 static void pcie_intr_handler(
struct adapter *adapter)
1189 static const struct intr_info sysbus_intr_info[] = {
1190 {
RNPP,
"RXNP array parity error", -1, 1 },
1191 {
RPCP,
"RXPC array parity error", -1, 1 },
1192 {
RCIP,
"RXCIF array parity error", -1, 1 },
1193 {
RCCP,
"Rx completions control array parity error", -1, 1 },
1194 {
RFTP,
"RXFT array parity error", -1, 1 },
1197 static const struct intr_info pcie_port_intr_info[] = {
1198 {
TPCP,
"TXPC array parity error", -1, 1 },
1199 {
TNPP,
"TXNP array parity error", -1, 1 },
1200 {
TFTP,
"TXFT array parity error", -1, 1 },
1201 {
TCAP,
"TXCA array parity error", -1, 1 },
1202 {
TCIP,
"TXCIF array parity error", -1, 1 },
1203 {
RCAP,
"RXCA array parity error", -1, 1 },
1204 {
OTDD,
"outbound request TLP discarded", -1, 1 },
1205 {
RDPE,
"Rx data parity error", -1, 1 },
1206 {
TDUE,
"Tx uncorrectable data error", -1, 1 },
1209 static const struct intr_info pcie_intr_info[] = {
1216 {
MSIXDIPERR,
"MSI-X DI parity error", -1, 1 },
1217 {
PIOCPLPERR,
"PCI PIO completion FIFO parity error", -1, 1 },
1218 {
PIOREQPERR,
"PCI PIO request FIFO parity error", -1, 1 },
1219 {
TARTAGPERR,
"PCI PCI target tag FIFO parity error", -1, 1 },
1220 {
CCNTPERR,
"PCI CMD channel count parity error", -1, 1 },
1221 {
CREQPERR,
"PCI CMD channel request parity error", -1, 1 },
1222 {
CRSPPERR,
"PCI CMD channel response parity error", -1, 1 },
1223 {
DCNTPERR,
"PCI DMA channel count parity error", -1, 1 },
1224 {
DREQPERR,
"PCI DMA channel request parity error", -1, 1 },
1225 {
DRSPPERR,
"PCI DMA channel response parity error", -1, 1 },
1226 {
HCNTPERR,
"PCI HMA channel count parity error", -1, 1 },
1227 {
HREQPERR,
"PCI HMA channel request parity error", -1, 1 },
1228 {
HRSPPERR,
"PCI HMA channel response parity error", -1, 1 },
1229 {
CFGSNPPERR,
"PCI config snoop FIFO parity error", -1, 1 },
1230 {
FIDPERR,
"PCI FID parity error", -1, 1 },
1231 {
INTXCLRPERR,
"PCI INTx clear parity error", -1, 1 },
1232 {
MATAGPERR,
"PCI MA tag parity error", -1, 1 },
1233 {
PIOTAGPERR,
"PCI PIO tag parity error", -1, 1 },
1234 {
RXCPLPERR,
"PCI Rx completion parity error", -1, 1 },
1235 {
RXWRPERR,
"PCI Rx write parity error", -1, 1 },
1236 {
RPLPERR,
"PCI replay buffer parity error", -1, 1 },
1237 {
PCIESINT,
"PCI core secondary fault", -1, 1 },
1238 {
PCIEPINT,
"PCI core primary fault", -1, 1 },
1239 {
UNXSPLCPLERR,
"PCI unexpected split completion error", -1, 0 },
1245 fat = t4_handle_intr_status(adapter,
1248 t4_handle_intr_status(adapter,
1250 pcie_port_intr_info) +
1259 static void tp_intr_handler(
struct adapter *adapter)
1261 static const struct intr_info tp_intr_info[] = {
1262 { 0x3fffffff,
"TP parity error", -1, 1 },
1267 if (t4_handle_intr_status(adapter,
TP_INT_CAUSE, tp_intr_info))
1274 static void sge_intr_handler(
struct adapter *adapter)
1278 static const struct intr_info sge_intr_info[] = {
1280 "SGE received CPL exceeding IQE size", -1, 1 },
1282 "SGE GTS CIDX increment too large", -1, 0 },
1288 "SGE IQID > 1023 received CPL for FL", -1, 0 },
1298 "SGE too many priority ingress contexts", -1, 0 },
1300 "SGE too many priority egress contexts", -1, 0 },
1309 dev_alert(adapter->
pdev_dev,
"SGE parity error (%#llx)\n",
1310 (
unsigned long long)v);
1315 if (t4_handle_intr_status(adapter,
SGE_INT_CAUSE3, sge_intr_info) ||
1323 static void cim_intr_handler(
struct adapter *adapter)
1325 static const struct intr_info cim_intr_info[] = {
1326 {
PREFDROPINT,
"CIM control register prefetch drop", -1, 1 },
1327 {
OBQPARERR,
"CIM OBQ parity error", -1, 1 },
1328 {
IBQPARERR,
"CIM IBQ parity error", -1, 1 },
1329 {
MBUPPARERR,
"CIM mailbox uP parity error", -1, 1 },
1330 {
MBHOSTPARERR,
"CIM mailbox host parity error", -1, 1 },
1335 static const struct intr_info cim_upintr_info[] = {
1337 {
ILLTRANSINT,
"CIM illegal transaction", -1, 1 },
1338 {
ILLWRINT,
"CIM illegal write", -1, 1 },
1339 {
ILLRDINT,
"CIM illegal read", -1, 1 },
1340 {
ILLRDBEINT,
"CIM illegal read BE", -1, 1 },
1341 {
ILLWRBEINT,
"CIM illegal write BE", -1, 1 },
1342 {
SGLRDBOOTINT,
"CIM single read from boot space", -1, 1 },
1343 {
SGLWRBOOTINT,
"CIM single write to boot space", -1, 1 },
1344 {
BLKWRBOOTINT,
"CIM block write to boot space", -1, 1 },
1345 {
SGLRDFLASHINT,
"CIM single read from flash space", -1, 1 },
1346 {
SGLWRFLASHINT,
"CIM single write to flash space", -1, 1 },
1352 {
SGLRDCTLINT ,
"CIM single read from CTL space", -1, 1 },
1353 {
SGLWRCTLINT ,
"CIM single write to CTL space", -1, 1 },
1354 {
BLKRDCTLINT ,
"CIM block read from CTL space", -1, 1 },
1355 {
BLKWRCTLINT ,
"CIM block write to CTL space", -1, 1 },
1356 {
SGLRDPLINT ,
"CIM single read from PL space", -1, 1 },
1357 {
SGLWRPLINT ,
"CIM single write to PL space", -1, 1 },
1358 {
BLKRDPLINT ,
"CIM block read from PL space", -1, 1 },
1359 {
BLKWRPLINT ,
"CIM block write to PL space", -1, 1 },
1380 static void ulprx_intr_handler(
struct adapter *adapter)
1382 static const struct intr_info ulprx_intr_info[] = {
1383 { 0x1800000,
"ULPRX context error", -1, 1 },
1384 { 0x7fffff,
"ULPRX parity error", -1, 1 },
1395 static void ulptx_intr_handler(
struct adapter *adapter)
1397 static const struct intr_info ulptx_intr_info[] = {
1406 { 0xfffffff,
"ULPTX parity error", -1, 1 },
1417 static void pmtx_intr_handler(
struct adapter *adapter)
1419 static const struct intr_info pmtx_intr_info[] = {
1439 static void pmrx_intr_handler(
struct adapter *adapter)
1441 static const struct intr_info pmrx_intr_info[] = {
1458 static void cplsw_intr_handler(
struct adapter *adapter)
1460 static const struct intr_info cplsw_intr_info[] = {
1470 if (t4_handle_intr_status(adapter,
CPL_INTR_CAUSE, cplsw_intr_info))
1477 static void le_intr_handler(
struct adapter *adap)
1479 static const struct intr_info le_intr_info[] = {
1480 {
LIPMISS,
"LE LIP miss", -1, 0 },
1481 {
LIP0,
"LE 0 LIP error", -1, 0 },
1482 {
PARITYERR,
"LE parity error", -1, 1 },
1484 {
REQQPARERR,
"LE request queue parity error", -1, 1 },
1495 static void mps_intr_handler(
struct adapter *adapter)
1497 static const struct intr_info mps_rx_intr_info[] = {
1498 { 0xffffff,
"MPS Rx parity error", -1, 1 },
1501 static const struct intr_info mps_tx_intr_info[] = {
1502 {
TPFIFO,
"MPS Tx TP FIFO parity error", -1, 1 },
1503 {
NCSIFIFO,
"MPS Tx NC-SI FIFO parity error", -1, 1 },
1504 {
TXDATAFIFO,
"MPS Tx data FIFO parity error", -1, 1 },
1505 {
TXDESCFIFO,
"MPS Tx desc FIFO parity error", -1, 1 },
1506 {
BUBBLE,
"MPS Tx underflow", -1, 1 },
1507 {
SECNTERR,
"MPS Tx SOP/EOP error", -1, 1 },
1508 {
FRMERR,
"MPS Tx framing error", -1, 1 },
1511 static const struct intr_info mps_trc_intr_info[] = {
1512 {
FILTMEM,
"MPS TRC filter parity error", -1, 1 },
1513 {
PKTFIFO,
"MPS TRC packet FIFO parity error", -1, 1 },
1514 {
MISCPERR,
"MPS TRC misc parity error", -1, 1 },
1517 static const struct intr_info mps_stat_sram_intr_info[] = {
1518 { 0x1fffff,
"MPS statistics SRAM parity error", -1, 1 },
1521 static const struct intr_info mps_stat_tx_intr_info[] = {
1522 { 0xfffff,
"MPS statistics Tx FIFO parity error", -1, 1 },
1525 static const struct intr_info mps_stat_rx_intr_info[] = {
1526 { 0xffffff,
"MPS statistics Rx FIFO parity error", -1, 1 },
1529 static const struct intr_info mps_cls_intr_info[] = {
1530 {
MATCHSRAM,
"MPS match SRAM parity error", -1, 1 },
1531 {
MATCHTCAM,
"MPS match TCAM parity error", -1, 1 },
1532 {
HASHSRAM,
"MPS hash SRAM parity error", -1, 1 },
1543 mps_trc_intr_info) +
1545 mps_stat_sram_intr_info) +
1547 mps_stat_tx_intr_info) +
1549 mps_stat_rx_intr_info) +
1560 #define MEM_INT_MASK (PERR_INT_CAUSE | ECC_CE_INT_CAUSE | ECC_UE_INT_CAUSE)
1565 static void mem_intr_handler(
struct adapter *adapter,
int idx)
1567 static const char name[3][5] = {
"EDC0",
"EDC1",
"MC" };
1569 unsigned int addr, cnt_addr,
v;
1581 dev_alert(adapter->
pdev_dev,
"%s FIFO parity error\n",
1587 if (printk_ratelimit())
1589 "%u %s correctable ECC data error%s\n",
1590 cnt, name[idx], cnt > 1 ?
"s" :
"");
1594 "%s uncorrectable ECC data error\n", name[idx]);
1596 t4_write_reg(adapter, addr, v);
1597 if (v & (PERR_INT_CAUSE | ECC_UE_INT_CAUSE))
1604 static void ma_intr_handler(
struct adapter *adap)
1610 "MA parity error, parity status %#x\n",
1614 dev_alert(adap->
pdev_dev,
"MA address wrap-around error by "
1615 "client %u to address %#x\n",
1626 static void smb_intr_handler(
struct adapter *adap)
1628 static const struct intr_info smb_intr_info[] = {
1635 if (t4_handle_intr_status(adap,
SMB_INT_CAUSE, smb_intr_info))
1642 static void ncsi_intr_handler(
struct adapter *adap)
1644 static const struct intr_info ncsi_intr_info[] = {
1659 static void xgmac_intr_handler(
struct adapter *adap,
int port)
1668 dev_alert(adap->
pdev_dev,
"XGMAC %d Tx FIFO parity error\n",
1671 dev_alert(adap->
pdev_dev,
"XGMAC %d Rx FIFO parity error\n",
1680 static void pl_intr_handler(
struct adapter *adap)
1682 static const struct intr_info pl_intr_info[] = {
1683 {
FATALPERR,
"T4 fatal parity error", -1, 1 },
1684 {
PERRVFID,
"PL VFID_MAP parity error", -1, 1 },
1692 #define PF_INTR_MASK (PFSW)
1693 #define GLBL_INTR_MASK (CIM | MPS | PL | PCIE | MC | EDC0 | \
1694 EDC1 | LE | TP | MA | PM_TX | PM_RX | ULP_RX | \
1695 CPL_SWITCH | SGE | ULP_TX)
1712 cim_intr_handler(adapter);
1714 mps_intr_handler(adapter);
1716 ncsi_intr_handler(adapter);
1718 pl_intr_handler(adapter);
1720 smb_intr_handler(adapter);
1722 xgmac_intr_handler(adapter, 0);
1724 xgmac_intr_handler(adapter, 1);
1726 xgmac_intr_handler(adapter, 2);
1728 xgmac_intr_handler(adapter, 3);
1730 pcie_intr_handler(adapter);
1732 mem_intr_handler(adapter,
MEM_MC);
1734 mem_intr_handler(adapter,
MEM_EDC0);
1736 mem_intr_handler(adapter,
MEM_EDC1);
1738 le_intr_handler(adapter);
1740 tp_intr_handler(adapter);
1742 ma_intr_handler(adapter);
1744 pmtx_intr_handler(adapter);
1746 pmrx_intr_handler(adapter);
1748 ulprx_intr_handler(adapter);
1750 cplsw_intr_handler(adapter);
1752 sge_intr_handler(adapter);
1754 ulptx_intr_handler(adapter);
1757 t4_write_reg(adapter,
PL_INT_CAUSE, cause & GLBL_INTR_MASK);
1815 static int hash_mac_addr(
const u8 *addr)
1817 u32 a = ((
u32)addr[0] << 16) | ((
u32)addr[1] << 8) | addr[2];
1818 u32 b = ((
u32)addr[3] << 16) | ((
u32)addr[4] << 8) | addr[5];
1843 int start,
int n,
const u16 *rspq,
unsigned int nrspq)
1847 const u16 *rsp_end = rspq + nrspq;
1850 memset(&cmd, 0,
sizeof(cmd));
1858 int nq =
min(n, 32);
1871 if (++rsp >= rsp_end)
1874 if (++rsp >= rsp_end)
1877 if (++rsp >= rsp_end)
1884 ret = t4_wr_mbox(adapter, mbox, &cmd,
sizeof(cmd),
NULL);
1905 memset(&c, 0,
sizeof(c));
1917 return t4_wr_mbox(adapter, mbox, &c,
sizeof(c),
NULL);
1934 #define STAT_IDX(x) ((TP_MIB_TCP_##x) - TP_MIB_TCP_OUT_RST)
1935 #define STAT(x) val[STAT_IDX(x)]
1936 #define STAT64(x) (((u64)STAT(x##_HI) << 32) | STAT(x##_LO))
1972 for (i = 0; i <
NMTUS; ++
i) {
1992 unsigned int mask,
unsigned int val)
2006 static void __devinit init_cong_ctrl(
unsigned short *
a,
unsigned short *
b)
2008 a[0] = a[1] = a[2] = a[3] = a[4] = a[5] = a[6] = a[7] = a[8] = 1;
2033 b[0] = b[1] = b[2] = b[3] = b[4] = b[5] = b[6] = b[7] = b[8] = 0;
2036 b[13] = b[14] = b[15] = b[16] = 3;
2037 b[17] = b[18] = b[19] = b[20] = b[21] = 4;
2038 b[22] = b[23] = b[24] = b[25] = b[26] = b[27] = 5;
2044 #define CC_MIN_INCR 2U
2059 const unsigned short *
alpha,
const unsigned short *beta)
2061 static const unsigned int avg_pkts[
NCCTRL_WIN] = {
2062 2, 6, 10, 14, 20, 28, 40, 56, 80, 112, 160, 224, 320, 448, 640,
2063 896, 1281, 1792, 2560, 3584, 5120, 7168, 10240, 14336, 20480,
2064 28672, 40960, 57344, 81920, 114688, 163840, 229376
2069 for (i = 0; i <
NMTUS; ++
i) {
2070 unsigned int mtu = mtus[
i];
2071 unsigned int log2 = fls(mtu);
2073 if (!(mtu & ((1 << log2) >> 2)))
2081 inc =
max(((mtu - 40) * alpha[w]) / avg_pkts[w],
2085 (w << 16) | (beta[w] << 13) | inc);
2099 static unsigned int get_mps_bg_map(
struct adapter *adap,
int idx)
2104 return idx == 0 ? 0xf : 0;
2106 return idx < 2 ? (3 << (2 *
idx)) : 0;
2120 u32 bgmap = get_mps_bg_map(adap, idx);
2122 #define GET_STAT(name) \
2123 t4_read_reg64(adap, PORT_REG(idx, MPS_PORT_STAT_##name##_L))
2124 #define GET_STAT_COM(name) t4_read_reg64(adap, MPS_STAT_##name##_L)
2204 (addr[2] << 24) | (addr[3] << 16) |
2205 (addr[4] << 8) | addr[5]);
2207 (addr[0] << 8) | addr[1]);
2241 #define EPIO_REG(name) PORT_REG(port, XGMAC_PORT_EPIO_##name)
2245 t4_write_reg(adap,
EPIO_REG(DATA3), mask1 >> 32);
2247 for (i = 0; i < NWOL_PAT; i++, map >>= 1) {
2271 #define INIT_CMD(var, cmd, rd_wr) do { \
2272 (var).op_to_write = htonl(FW_CMD_OP(FW_##cmd##_CMD) | \
2273 FW_CMD_REQUEST | FW_CMD_##rd_wr); \
2274 (var).retval_len16 = htonl(FW_LEN16(var)); \
2282 memset(&c, 0,
sizeof(c));
2290 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
2313 if ((addr & 3) || (len + off) > MEMWIN0_APERTURE)
2319 for (i = 0; i < len; i += 4)
2337 int t4_mdio_rd(
struct adapter *adap,
unsigned int mbox,
unsigned int phy_addr,
2338 unsigned int mmd,
unsigned int reg,
u16 *valp)
2343 memset(&c, 0,
sizeof(c));
2351 ret = t4_wr_mbox(adap, mbox, &c,
sizeof(c), &c);
2368 int t4_mdio_wr(
struct adapter *adap,
unsigned int mbox,
unsigned int phy_addr,
2369 unsigned int mmd,
unsigned int reg,
u16 val)
2373 memset(&c, 0,
sizeof(c));
2382 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
2396 int t4_fw_hello(
struct adapter *adap,
unsigned int mbox,
unsigned int evt_mbox,
2402 unsigned int master_mbox;
2406 memset(&c, 0,
sizeof(c));
2422 ret = t4_wr_mbox(adap, mbox, &c,
sizeof(c), &c);
2452 master_mbox != mbox) {
2522 memset(&c, 0,
sizeof(c));
2524 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
2539 memset(&c, 0,
sizeof(c));
2541 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
2556 memset(&c, 0,
sizeof(c));
2559 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
2589 memset(&c, 0,
sizeof(c));
2593 ret = t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
2609 if (ret == 0 || force) {
2709 const struct fw_hdr *
fw_hdr = (
const struct fw_hdr *)fw_data;
2713 if (ret < 0 && !force)
2760 unsigned int mtype,
unsigned int maddr,
2761 u32 *finiver,
u32 *finicsum,
u32 *cfcsum)
2772 memset(&caps_cmd, 0,
sizeof(caps_cmd));
2782 ret = t4_wr_mbox(adap, mbox, &caps_cmd,
sizeof(caps_cmd), &caps_cmd);
2801 return t4_wr_mbox(adap, mbox, &caps_cmd,
sizeof(caps_cmd),
NULL);
2817 unsigned int page_shift = fls(page_size) - 1;
2818 unsigned int sge_hps = page_shift - 10;
2819 unsigned int stat_len = cache_line_size > 64 ? 128 : 64;
2821 unsigned int fl_align_log = fls(fl_align) - 1;
2885 memset(&c, 0,
sizeof(c));
2887 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
2904 unsigned int vf,
unsigned int nparams,
const u32 *
params,
2914 memset(&c, 0,
sizeof(c));
2919 for (i = 0; i < nparams; i++, p += 2)
2920 *p =
htonl(*params++);
2922 ret = t4_wr_mbox(adap, mbox, &c,
sizeof(c), &c);
2924 for (i = 0, p = &c.
param[0].val; i < nparams; i++, p += 2)
2943 unsigned int vf,
unsigned int nparams,
const u32 *
params,
2952 memset(&c, 0,
sizeof(c));
2958 *p++ =
htonl(*params++);
2959 *p++ =
htonl(*val++);
2962 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
2987 unsigned int vf,
unsigned int txq,
unsigned int txq_eth_ctrl,
2988 unsigned int rxqi,
unsigned int rxq,
unsigned int tc,
2989 unsigned int vi,
unsigned int cmask,
unsigned int pmask,
2990 unsigned int nexact,
unsigned int rcaps,
unsigned int wxcaps)
2994 memset(&c, 0,
sizeof(c));
3009 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
3029 int t4_alloc_vi(
struct adapter *adap,
unsigned int mbox,
unsigned int port,
3030 unsigned int pf,
unsigned int vf,
unsigned int nmac,
u8 *
mac,
3031 unsigned int *rss_size)
3036 memset(&c, 0,
sizeof(c));
3044 ret = t4_wr_mbox(adap, mbox, &c,
sizeof(c), &c);
3081 int mtu,
int promisc,
int all_multi,
int bcast,
int vlanex,
3098 memset(&c, 0,
sizeof(c));
3133 unsigned int viid,
bool free,
unsigned int naddr,
3138 struct fw_vi_mac_exact *
p;
3143 memset(&c, 0,
sizeof(c));
3150 for (i = 0, p = c.
u.
exact; i < naddr; i++, p++) {
3153 memcpy(p->macaddr, addr[i],
sizeof(p->macaddr));
3160 for (i = 0, p = c.
u.
exact; i < naddr; i++, p++) {
3168 *hash |= (1ULL << hash_mac_addr(addr[i]));
3193 int idx,
const u8 *addr,
bool persist,
bool add_smt)
3197 struct fw_vi_mac_exact *
p = c.
u.
exact;
3203 memset(&c, 0,
sizeof(c));
3210 memcpy(p->macaddr, addr,
sizeof(p->macaddr));
3212 ret = t4_wr_mbox(adap, mbox, &c,
sizeof(c), &c);
3233 bool ucast,
u64 vec,
bool sleep_ok)
3237 memset(&c, 0,
sizeof(c));
3257 int t4_enable_vi(
struct adapter *adap,
unsigned int mbox,
unsigned int viid,
3258 bool rx_en,
bool tx_en)
3262 memset(&c, 0,
sizeof(c));
3267 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
3280 unsigned int nblinks)
3284 memset(&c, 0,
sizeof(c));
3289 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
3306 unsigned int vf,
unsigned int iqtype,
unsigned int iqid,
3307 unsigned int fl0id,
unsigned int fl1id)
3311 memset(&c, 0,
sizeof(c));
3320 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
3334 unsigned int vf,
unsigned int eqid)
3338 memset(&c, 0,
sizeof(c));
3344 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
3358 unsigned int vf,
unsigned int eqid)
3362 memset(&c, 0,
sizeof(c));
3368 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
3382 unsigned int vf,
unsigned int eqid)
3386 memset(&c, 0,
sizeof(c));
3392 return t4_wr_mbox(adap, mbox, &c,
sizeof(c),
NULL);
3411 struct port_info *pi = adap2pinfo(adap, port);
3443 static void __devinit get_pci_mode(
struct adapter *adapter,
3448 if (pci_is_pcie(adapter->
pdev)) {
3482 if (t4_read_reg(adap,
PL_WHOAMI) != 0xffffffff)
3485 return t4_read_reg(adap,
PL_WHOAMI) != 0xffffffff ? 0 : -
EIO;
3488 static int __devinit get_flash_params(
struct adapter *adap)
3493 ret = sf1_write(adap, 1, 1, 0,
SF_RD_ID);
3495 ret = sf1_read(adap, 3, 0, 1, &info);
3496 t4_write_reg(adap,
SF_OP, 0);
3500 if ((info & 0xff) != 0x20)
3503 if (info >= 0x14 && info < 0x18)
3504 adap->
params.sf_nsec = 1 << (info - 16);
3505 else if (info == 0x18)
3506 adap->
params.sf_nsec = 64;
3510 adap->
params.sf_fw_start =
3532 get_pci_mode(adapter, &adapter->
params.pci);
3535 ret = get_flash_params(adapter);
3541 init_cong_ctrl(adapter->
params.a_wnd, adapter->
params.b_wnd);
3546 adapter->
params.nports = 1;
3547 adapter->
params.portvec = 1;
3548 adapter->
params.vpd.cclk = 50000;
3559 memset(&c, 0,
sizeof(c));
3560 memset(&rvc, 0,
sizeof(rvc));
3563 unsigned int rss_size;
3564 struct port_info *p = adap2pinfo(adap, i);
3566 while ((adap->
params.portvec & (1 << j)) == 0)
3575 ret = t4_wr_mbox(adap, mbox, &c,
sizeof(c), &c);
3579 ret =
t4_alloc_vi(adap, mbox, j, pf, vf, 1, addr, &rss_size);
3589 adap->
port[
i]->dev_id =
j;
3601 ret = t4_wr_mbox(adap, mbox, &rvc,
sizeof(rvc), &rvc);