36 #include <linux/pci.h>
41 #include "../cxgb4/t4_regs.h"
42 #include "../cxgb4/t4fw_api.h"
52 const u32 notready1 = 0xffffffff;
53 const u32 notready2 = 0xeeeeeeee;
56 val = t4_read_reg(adapter, whoami);
57 if (val != notready1 && val != notready2)
60 val = t4_read_reg(adapter, whoami);
61 if (val != notready1 && val != notready2)
74 for ( ;
size; size -= 8, mbox_data += 8)
75 *rpl++ =
cpu_to_be64(t4_read_reg64(adapter, mbox_data));
81 static void dump_mbox(
struct adapter *adapter,
const char *
tag,
u32 mbox_data)
84 "mbox %s: %llx %llx %llx %llx %llx %llx %llx %llx\n", tag,
85 (
unsigned long long)t4_read_reg64(adapter, mbox_data + 0),
86 (
unsigned long long)t4_read_reg64(adapter, mbox_data + 8),
87 (
unsigned long long)t4_read_reg64(adapter, mbox_data + 16),
88 (
unsigned long long)t4_read_reg64(adapter, mbox_data + 24),
89 (
unsigned long long)t4_read_reg64(adapter, mbox_data + 32),
90 (
unsigned long long)t4_read_reg64(adapter, mbox_data + 40),
91 (
unsigned long long)t4_read_reg64(adapter, mbox_data + 48),
92 (
unsigned long long)t4_read_reg64(adapter, mbox_data + 56));
116 void *rpl,
bool sleep_ok)
118 static const int delay[] = {
119 1, 1, 3, 5, 10, 10, 20, 50, 100
123 int i,
ms, delay_idx;
132 if ((size % 16) != 0 ||
159 for (i = 0, p = cmd; i <
size; i += 8)
160 t4_write_reg64(adapter, mbox_data + i,
be64_to_cpu(*p++));
161 t4_read_reg(adapter, mbox_data);
163 t4_write_reg(adapter, mbox_ctl,
165 t4_read_reg(adapter, mbox_ctl);
175 ms = delay[delay_idx];
185 v = t4_read_reg(adapter, mbox_ctl);
192 t4_write_reg(adapter, mbox_ctl,
206 v = t4_read_reg(adapter, mbox_data);
208 dump_mbox(adapter,
"FW Error", mbox_data);
214 get_mbox_rpl(adapter, rpl, size, mbox_data);
216 & FW_CMD_REQUEST) != 0);
218 t4_write_reg(adapter, mbox_ctl,
227 dump_mbox(adapter,
"FW Timeout", mbox_data);
238 static int hash_mac_addr(
const u8 *
addr)
240 u32 a = ((
u32)addr[0] << 16) | ((
u32)addr[1] << 8) | addr[2];
241 u32 b = ((
u32)addr[3] << 16) | ((
u32)addr[4] << 8) | addr[5];
280 struct port_info *pi = adap2pinfo(adapter, pidx);
290 memset(&vi_cmd, 0,
sizeof(vi_cmd));
296 v = t4vf_wr_mbox(adapter, &vi_cmd,
sizeof(vi_cmd), &vi_rpl);
302 t4_os_set_hw_addr(adapter, pidx, vi_rpl.
mac);
311 memset(&port_cmd, 0,
sizeof(port_cmd));
319 v = t4vf_wr_mbox(adapter, &port_cmd,
sizeof(port_cmd), &port_rpl);
350 memset(&cmd, 0,
sizeof(cmd));
354 return t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd),
NULL);
372 struct fw_params_param *
p;
378 memset(&cmd, 0,
sizeof(cmd));
383 param[nparams].mnem), 16);
385 for (i = 0, p = &cmd.
param[0]; i < nparams; i++, p++)
386 p->mnem =
htonl(*params++);
388 ret = t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd), &rpl);
390 for (i = 0, p = &rpl.
param[0]; i < nparams; i++, p++)
410 struct fw_params_param *
p;
416 memset(&cmd, 0,
sizeof(cmd));
421 param[nparams]), 16);
423 for (i = 0, p = &cmd.
param[0]; i < nparams; i++, p++) {
428 return t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd),
NULL);
498 vpd_params->
cclk = vals[0];
523 dev_params->
fwrev = vals[0];
524 dev_params->
tprev = vals[1];
546 memset(&cmd, 0,
sizeof(cmd));
551 v = t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd), &rpl);
622 memset(&cmd, 0,
sizeof(cmd));
627 v = t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd), &rpl);
670 memset(&cmd, 0,
sizeof(cmd));
676 v = t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd), &rpl);
680 switch (adapter->
params.rss.mode) {
720 memset(&cmd, 0,
sizeof(cmd));
726 switch (adapter->
params.rss.mode) {
750 return t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd), &rpl);
769 int start,
int n,
const u16 *rspq,
int nrspq)
772 const u16 *rsp_end = rspq+nrspq;
778 memset(&cmd, 0,
sizeof(cmd));
823 int nqbuf =
min(3, nq);
826 qbuf[0] = qbuf[1] = qbuf[2] = 0;
842 ret = t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd),
NULL);
867 memset(&cmd, 0,
sizeof(cmd));
875 v = t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd), &rpl);
897 memset(&cmd, 0,
sizeof(cmd));
904 return t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd),
NULL);
917 bool rx_en,
bool tx_en)
921 memset(&cmd, 0,
sizeof(cmd));
929 return t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd),
NULL);
941 unsigned int nblinks)
945 memset(&cmd, 0,
sizeof(cmd));
953 return t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd),
NULL);
970 int mtu,
int promisc,
int all_multi,
int bcast,
int vlanex,
987 memset(&cmd, 0,
sizeof(cmd));
1028 unsigned nfilters = 0;
1029 unsigned int rem = naddr;
1035 for (offset = 0; offset < naddr; ) {
1040 u.exact[fw_naddr]), 16);
1041 struct fw_vi_mac_exact *
p;
1044 memset(&cmd, 0,
sizeof(cmd));
1054 for (i = 0, p = cmd.
u.
exact; i < fw_naddr; i++, p++) {
1058 memcpy(p->macaddr, addr[offset+i],
sizeof(p->macaddr));
1064 if (ret && ret != -
ENOMEM)
1067 for (i = 0, p = rpl.
u.
exact; i < fw_naddr; i++, p++) {
1079 *hash |= (1ULL << hash_mac_addr(addr[offset+i]));
1091 if (ret == 0 || ret == -
ENOMEM)
1119 struct fw_vi_mac_exact *
p = &cmd.
u.
exact[0];
1130 memset(&cmd, 0,
sizeof(cmd));
1138 memcpy(p->macaddr, addr,
sizeof(p->macaddr));
1140 ret = t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd), &rpl);
1161 bool ucast,
u64 vec,
bool sleep_ok)
1167 memset(&cmd, 0,
sizeof(cmd));
1190 struct port_info *pi = adap2pinfo(adapter, pidx);
1191 struct fw_vi_stats_vf fwstats;
1202 unsigned int nstats =
min(6
U, rem);
1205 sizeof(
struct fw_vi_stats_ctl));
1209 memset(&cmd, 0,
sizeof(cmd));
1215 cmd.
u.
ctl.nstats_ix =
1218 ret = t4vf_wr_mbox_ns(adapter, &cmd, len, &rpl);
1264 unsigned int iqid,
unsigned int fl0id,
unsigned int fl1id)
1268 memset(&cmd, 0,
sizeof(cmd));
1280 return t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd),
NULL);
1294 memset(&cmd, 0,
sizeof(cmd));
1301 return t4vf_wr_mbox(adapter, &cmd,
sizeof(cmd),
NULL);
1333 "Unknown firmware PORT reply action %x\n",
1363 struct port_info *pi = adap2pinfo(adapter, pidx);