18 #include <linux/module.h>
32 if (be_error(adapter))
45 static inline bool be_mcc_compl_is_new(
struct be_mcc_compl *compl)
47 if (compl->
flags != 0) {
57 static inline void be_mcc_compl_use(
struct be_mcc_compl *compl)
67 addr = ((addr << 16) << 16) | tag0;
71 static int be_mcc_compl_process(
struct be_adapter *adapter,
74 u16 compl_status, extd_status;
85 resp_hdr = be_decode_resp_hdr(compl->
tag0, compl->
tag1);
110 adapter->
drv_stats.be_on_die_temperature =
123 "VF is not privileged to issue opcode %d-%d\n",
129 "opcode %d-%d failed:status %d-%d\n",
130 opcode, subsystem, compl_status, extd_status);
138 static void be_async_link_state_process(
struct be_adapter *adapter,
142 adapter->
phy.link_speed = -1;
157 static void be_async_grp5_cos_priority_process(
struct be_adapter *adapter,
169 static void be_async_grp5_qos_speed_process(
struct be_adapter *adapter,
172 if (adapter->
phy.link_speed >= 0 &&
178 static void be_async_grp5_pvid_state_process(
struct be_adapter *adapter,
187 static void be_async_grp5_evt_process(
struct be_adapter *adapter,
195 switch (event_type) {
197 be_async_grp5_cos_priority_process(adapter,
201 be_async_grp5_qos_speed_process(adapter,
205 be_async_grp5_pvid_state_process(adapter,
214 static inline bool is_link_state_evt(
u32 trailer)
221 static inline bool is_grp5_evt(
u32 trailer)
233 if (be_mcc_compl_is_new(compl)) {
234 queue_tail_inc(mcc_cq);
245 adapter->
mcc_obj.rearm_cq =
true;
252 adapter->
mcc_obj.rearm_cq =
false;
262 while ((compl = be_mcc_compl_get(adapter))) {
265 if (is_link_state_evt(compl->
flags))
266 be_async_link_state_process(adapter,
268 else if (is_grp5_evt(compl->
flags))
269 be_async_grp5_evt_process(adapter,
270 compl->
flags, compl);
272 status = be_mcc_compl_process(adapter, compl);
275 be_mcc_compl_use(compl);
287 static int be_mcc_wait_compl(
struct be_adapter *adapter)
289 #define mcc_timeout 120000
294 if (be_error(adapter))
305 if (i == mcc_timeout) {
306 dev_err(&adapter->
pdev->dev,
"FW not responding\n");
314 static int be_mcc_notify_wait(
struct be_adapter *adapter)
322 index_dec(&index, mcc_obj->
q.len);
323 wrb = queue_index_node(&mcc_obj->
q, index);
325 resp = be_decode_resp_hdr(wrb->
tag0, wrb->
tag1);
327 be_mcc_notify(adapter);
329 status = be_mcc_wait_compl(adapter);
344 if (be_error(adapter))
348 if (ready == 0xffffffff)
356 dev_err(&adapter->
pdev->dev,
"FW not responding\n");
373 static int be_mbox_notify_wait(
struct be_adapter *adapter)
383 status = be_mbox_db_ready_wait(adapter, db);
393 status = be_mbox_db_ready_wait(adapter, db);
399 val |= (
u32)(mbox_mem->
dma >> 4) << 2;
402 status = be_mbox_db_ready_wait(adapter, db);
407 if (be_mcc_compl_is_new(compl)) {
408 status = be_mcc_compl_process(adapter, &mbox->
compl);
409 be_mcc_compl_use(compl);
413 dev_err(&adapter->
pdev->dev,
"invalid mailbox completion\n");
419 static int be_POST_stage_get(
struct be_adapter *adapter,
u16 *stage)
437 #define SLIPORT_READY_TIMEOUT 30
449 if (i == SLIPORT_READY_TIMEOUT)
458 u32 sliport_status,
err, reset_needed;
464 if (err && reset_needed) {
472 sliport_status &= (SLIPORT_STATUS_ERR_MASK |
474 if (status || sliport_status)
476 }
else if (err || reset_needed) {
495 status = be_POST_stage_get(adapter, &stage);
497 dev_err(dev,
"POST error; stage=0x%x\n", stage);
501 dev_err(dev,
"Waiting for POST aborted\n");
508 }
while (timeout < 60);
510 dev_err(dev,
"POST timeout; stage=0x%x\n", stage);
523 static void be_wrb_cmd_hdr_prepare(
struct be_cmd_req_hdr *req_hdr,
528 unsigned long addr = (
unsigned long)req_hdr;
536 wrb->
tag0 = req_addr & 0xFFFFFFFF;
543 sge = nonembedded_sgl(wrb);
558 for (i = 0; i < buf_pages; i++) {
568 #define MAX_INTR_RATE 651042
569 const u32 round = 10;
577 if (interrupt_rate == 0)
581 multiplier /= interrupt_rate;
583 multiplier = (multiplier + round/2) / round;
584 multiplier =
min(multiplier, (
u32)1023);
595 memset(wrb, 0,
sizeof(*wrb));
605 dev_err(&adapter->
pdev->dev,
"Out of MCCQ wrbs\n");
609 wrb = queue_head_node(mccq);
610 queue_head_inc(mccq);
612 memset(wrb, 0,
sizeof(*wrb));
630 wrb = (
u8 *)wrb_from_mbox(adapter);
640 status = be_mbox_notify_wait(adapter);
660 wrb = (
u8 *)wrb_from_mbox(adapter);
670 status = be_mbox_notify_wait(adapter);
687 wrb = wrb_from_mbox(adapter);
688 req = embedded_payload(wrb);
699 __ilog2_u32(eq->
len/256));
701 eq_delay_to_mult(eq_delay));
706 status = be_mbox_notify_wait(adapter);
719 bool permanent,
u32 if_handle,
u32 pmac_id)
727 wrb = wrb_from_mccq(adapter);
732 req = embedded_payload(wrb);
745 status = be_mcc_notify_wait(adapter);
766 wrb = wrb_from_mccq(adapter);
771 req = embedded_payload(wrb);
776 req->
hdr.domain = domain;
780 status = be_mcc_notify_wait(adapter);
807 wrb = wrb_from_mccq(adapter);
812 req = embedded_payload(wrb);
817 req->
hdr.domain = dom;
821 status = be_mcc_notify_wait(adapter);
841 wrb = wrb_from_mbox(adapter);
842 req = embedded_payload(wrb);
850 req->
hdr.version = 2;
855 __ilog2_u32(cq->
len/256));
867 __ilog2_u32(cq->
len/256));
877 status = be_mbox_notify_wait(adapter);
889 static u32 be_encoded_q_len(
int q_len)
891 u32 len_encoded = fls(q_len);
892 if (len_encoded == 16)
910 wrb = wrb_from_mbox(adapter);
911 req = embedded_payload(wrb);
919 req->
hdr.version = 1;
923 be_encoded_q_len(mccq->
len));
933 be_encoded_q_len(mccq->
len));
943 status = be_mbox_notify_wait(adapter);
967 wrb = wrb_from_mbox(adapter);
968 req = embedded_payload(wrb);
978 be_encoded_q_len(mccq->
len));
985 status = be_mbox_notify_wait(adapter);
1004 dev_warn(&adapter->
pdev->dev,
"Upgrade to F/W ver 2.102.235.0 "
1005 "or newer to avoid conflicting priorities between NIC "
1006 "and FCoE traffic");
1024 wrb = wrb_from_mccq(adapter);
1030 req = embedded_payload(wrb);
1037 req->
hdr.version = 1;
1047 be_encoded_q_len(txq->
len));
1055 status = be_mcc_notify_wait(adapter);
1063 spin_unlock_bh(&adapter->
mcc_lock);
1080 wrb = wrb_from_mccq(adapter);
1085 req = embedded_payload(wrb);
1098 status = be_mcc_notify_wait(adapter);
1107 spin_unlock_bh(&adapter->
mcc_lock);
1119 u8 subsys = 0, opcode = 0;
1125 wrb = wrb_from_mbox(adapter);
1126 req = embedded_payload(wrb);
1128 switch (queue_type) {
1153 be_wrb_cmd_hdr_prepare(&req->
hdr, subsys, opcode,
sizeof(*req), wrb,
1157 status = be_mbox_notify_wait(adapter);
1174 wrb = wrb_from_mccq(adapter);
1179 req = embedded_payload(wrb);
1185 status = be_mcc_notify_wait(adapter);
1190 spin_unlock_bh(&adapter->
mcc_lock);
1198 u32 *if_handle,
u32 domain)
1206 wrb = wrb_from_mccq(adapter);
1211 req = embedded_payload(wrb);
1215 req->
hdr.domain = domain;
1221 status = be_mcc_notify_wait(adapter);
1228 spin_unlock_bh(&adapter->
mcc_lock);
1239 if (interface_id == -1)
1244 wrb = wrb_from_mccq(adapter);
1249 req = embedded_payload(wrb);
1253 req->
hdr.domain = domain;
1256 status = be_mcc_notify_wait(adapter);
1258 spin_unlock_bh(&adapter->
mcc_lock);
1274 wrb = wrb_from_mccq(adapter);
1279 hdr = nonemb_cmd->
va;
1287 be_mcc_notify(adapter);
1291 spin_unlock_bh(&adapter->
mcc_lock);
1306 wrb = wrb_from_mccq(adapter);
1311 req = nonemb_cmd->
va;
1320 be_mcc_notify(adapter);
1324 spin_unlock_bh(&adapter->
mcc_lock);
1328 static int be_mac_to_link_speed(
int mac_speed)
1330 switch (mac_speed) {
1360 wrb = wrb_from_mccq(adapter);
1365 req = embedded_payload(wrb);
1371 req->
hdr.version = 1;
1373 req->
hdr.domain = dom;
1375 status = be_mcc_notify_wait(adapter);
1391 spin_unlock_bh(&adapter->
mcc_lock);
1404 wrb = wrb_from_mccq(adapter);
1409 req = embedded_payload(wrb);
1415 be_mcc_notify(adapter);
1418 spin_unlock_bh(&adapter->
mcc_lock);
1431 wrb = wrb_from_mccq(adapter);
1436 req = embedded_payload(wrb);
1441 status = be_mcc_notify_wait(adapter);
1449 spin_unlock_bh(&adapter->
mcc_lock);
1471 if (!get_fat_cmd.
va) {
1474 "Memory allocation failure while retrieving FAT data\n");
1484 wrb = wrb_from_mccq(adapter);
1489 req = get_fat_cmd.
va;
1501 status = be_mcc_notify_wait(adapter);
1508 dev_err(&adapter->
pdev->dev,
"FAT Table Retrieve error\n");
1518 spin_unlock_bh(&adapter->
mcc_lock);
1531 wrb = wrb_from_mccq(adapter);
1537 req = embedded_payload(wrb);
1541 status = be_mcc_notify_wait(adapter);
1549 spin_unlock_bh(&adapter->
mcc_lock);
1564 wrb = wrb_from_mccq(adapter);
1569 req = embedded_payload(wrb);
1576 req->
delay[0].phase = 0;
1579 be_mcc_notify(adapter);
1582 spin_unlock_bh(&adapter->
mcc_lock);
1588 u32 num,
bool untagged,
bool promiscuous)
1596 wrb = wrb_from_mccq(adapter);
1601 req = embedded_payload(wrb);
1612 req->
num_vlan *
sizeof(vtag_array[0]));
1615 status = be_mcc_notify_wait(adapter);
1618 spin_unlock_bh(&adapter->
mcc_lock);
1631 wrb = wrb_from_mccq(adapter);
1636 memset(req, 0,
sizeof(*req));
1670 status = be_mcc_notify_wait(adapter);
1672 spin_unlock_bh(&adapter->
mcc_lock);
1685 wrb = wrb_from_mccq(adapter);
1690 req = embedded_payload(wrb);
1698 status = be_mcc_notify_wait(adapter);
1701 spin_unlock_bh(&adapter->
mcc_lock);
1714 wrb = wrb_from_mccq(adapter);
1719 req = embedded_payload(wrb);
1724 status = be_mcc_notify_wait(adapter);
1727 embedded_payload(wrb);
1733 spin_unlock_bh(&adapter->
mcc_lock);
1748 wrb = wrb_from_mbox(adapter);
1749 req = embedded_payload(wrb);
1754 status = be_mbox_notify_wait(adapter);
1782 "Adapter in non recoverable error\n");
1790 wrb = wrb_from_mbox(adapter);
1791 req = embedded_payload(wrb);
1796 status = be_mbox_notify_wait(adapter);
1806 u32 myhash[10] = {0x15d43fa5, 0x2534685a, 0x5f87693a, 0x5668494e,
1807 0x33cf6a53, 0x383334c6, 0x76ac4257, 0x59b242b2,
1808 0x3ea83c02, 0x4a110304};
1814 wrb = wrb_from_mbox(adapter);
1815 req = embedded_payload(wrb);
1825 req->
hdr.version = 1;
1835 status = be_mbox_notify_wait(adapter);
1851 wrb = wrb_from_mccq(adapter);
1856 req = embedded_payload(wrb);
1866 status = be_mcc_notify_wait(adapter);
1869 spin_unlock_bh(&adapter->
mcc_lock);
1882 wrb = wrb_from_mccq(adapter);
1887 req = embedded_payload(wrb);
1894 status = be_mcc_notify_wait(adapter);
1897 embedded_payload(wrb);
1902 spin_unlock_bh(&adapter->
mcc_lock);
1908 const char *obj_name,
u32 *data_written,
1909 u8 *change_status,
u8 *addn_status)
1920 wrb = wrb_from_mccq(adapter);
1926 req = embedded_payload(wrb);
1935 write_length, ctxt, data_size);
1955 be_mcc_notify(adapter);
1956 spin_unlock_bh(&adapter->
mcc_lock);
1964 resp = embedded_payload(wrb);
1975 spin_unlock_bh(&adapter->
mcc_lock);
1981 u32 *data_read,
u32 *eof,
u8 *addn_status)
1990 wrb = wrb_from_mccq(adapter);
1996 req = embedded_payload(wrb);
2011 status = be_mcc_notify_wait(adapter);
2013 resp = embedded_payload(wrb);
2022 spin_unlock_bh(&adapter->
mcc_lock);
2036 wrb = wrb_from_mccq(adapter);
2050 be_mcc_notify(adapter);
2051 spin_unlock_bh(&adapter->
mcc_lock);
2062 spin_unlock_bh(&adapter->
mcc_lock);
2075 wrb = wrb_from_mccq(adapter);
2080 req = embedded_payload(wrb);
2090 status = be_mcc_notify_wait(adapter);
2095 spin_unlock_bh(&adapter->
mcc_lock);
2108 wrb = wrb_from_mccq(adapter);
2113 req = nonemb_cmd->
va;
2120 status = be_mcc_notify_wait(adapter);
2123 spin_unlock_bh(&adapter->
mcc_lock);
2136 wrb = wrb_from_mccq(adapter);
2142 req = embedded_payload(wrb);
2153 status = be_mcc_notify_wait(adapter);
2155 spin_unlock_bh(&adapter->
mcc_lock);
2168 wrb = wrb_from_mccq(adapter);
2174 req = embedded_payload(wrb);
2187 status = be_mcc_notify_wait(adapter);
2194 spin_unlock_bh(&adapter->
mcc_lock);
2208 wrb = wrb_from_mccq(adapter);
2219 for (i = 0; i < byte_cnt; i++) {
2226 status = be_mcc_notify_wait(adapter);
2238 spin_unlock_bh(&adapter->
mcc_lock);
2252 wrb = wrb_from_mccq(adapter);
2257 req = nonemb_cmd->
va;
2258 sge = nonembedded_sgl(wrb);
2264 status = be_mcc_notify_wait(adapter);
2267 spin_unlock_bh(&adapter->
mcc_lock);
2280 wrb = wrb_from_mccq(adapter);
2289 dev_err(&adapter->
pdev->dev,
"Memory alloc failure\n");
2300 status = be_mcc_notify_wait(adapter);
2305 adapter->
phy.interface_type =
2307 adapter->
phy.auto_speeds_supported =
2309 adapter->
phy.fixed_speeds_supported =
2311 adapter->
phy.misc_params =
2317 spin_unlock_bh(&adapter->
mcc_lock);
2329 wrb = wrb_from_mccq(adapter);
2335 req = embedded_payload(wrb);
2340 req->
hdr.domain = domain;
2344 status = be_mcc_notify_wait(adapter);
2347 spin_unlock_bh(&adapter->
mcc_lock);
2365 if (!attribs_cmd.
va) {
2367 "Memory allocation failure\n");
2374 wrb = wrb_from_mbox(adapter);
2379 req = attribs_cmd.
va;
2385 status = be_mbox_notify_wait(adapter);
2408 wrb = wrb_from_mbox(adapter);
2414 req = embedded_payload(wrb);
2423 status = be_mbox_notify_wait(adapter);
2430 "adapter not in advanced mode\n");
2439 bool *pmac_id_active,
u32 *pmac_id,
u8 domain)
2451 get_mac_list_cmd.
size,
2452 &get_mac_list_cmd.
dma);
2454 if (!get_mac_list_cmd.
va) {
2456 "Memory allocation failure during GET_MAC_LIST\n");
2462 wrb = wrb_from_mccq(adapter);
2468 req = get_mac_list_cmd.
va;
2472 wrb, &get_mac_list_cmd);
2474 req->
hdr.domain = domain;
2478 status = be_mcc_notify_wait(adapter);
2481 get_mac_list_cmd.
va;
2488 for (i = 0; i < mac_count; i++) {
2498 if (mac_addr_size ==
sizeof(
u32)) {
2499 *pmac_id_active =
true;
2506 *pmac_id_active =
false;
2512 spin_unlock_bh(&adapter->
mcc_lock);
2514 get_mac_list_cmd.
va, get_mac_list_cmd.
dma);
2520 u8 mac_count,
u32 domain)
2532 dev_err(&adapter->
pdev->dev,
"Memory alloc failure\n");
2538 wrb = wrb_from_mccq(adapter);
2549 req->
hdr.domain = domain;
2554 status = be_mcc_notify_wait(adapter);
2559 spin_unlock_bh(&adapter->
mcc_lock);
2573 wrb = wrb_from_mccq(adapter);
2579 req = embedded_payload(wrb);
2585 req->
hdr.domain = domain;
2593 status = be_mcc_notify_wait(adapter);
2596 spin_unlock_bh(&adapter->
mcc_lock);
2612 wrb = wrb_from_mccq(adapter);
2618 req = embedded_payload(wrb);
2624 req->
hdr.domain = domain;
2630 status = be_mcc_notify_wait(adapter);
2633 embedded_payload(wrb);
2642 spin_unlock_bh(&adapter->
mcc_lock);
2660 "Memory allocation failure\n");
2667 wrb = wrb_from_mbox(adapter);
2677 payload_len, wrb, &cmd);
2679 req->
hdr.version = 1;
2682 status = be_mbox_notify_wait(adapter);
2689 if (resp->
hdr.response_length < payload_len) {
2711 wrb = wrb_from_mbox(adapter);
2720 cmd->
size, wrb, cmd);
2723 status = be_mbox_notify_wait(adapter);
2739 wrb = wrb_from_mccq(adapter);
2749 cmd->
size, wrb, cmd);
2751 status = be_mcc_notify_wait(adapter);
2753 spin_unlock_bh(&adapter->
mcc_lock);
2770 wrb = wrb_from_mccq(adapter);
2776 req = embedded_payload(wrb);
2781 req->
hdr.version = 1;
2783 status = be_mcc_notify_wait(adapter);
2791 spin_unlock_bh(&adapter->
mcc_lock);
2798 struct be_adapter *adapter = netdev_priv(netdev_handle);
2807 wrb = wrb_from_mccq(adapter);
2812 req = embedded_payload(wrb);
2813 resp = embedded_payload(wrb);
2815 be_wrb_cmd_hdr_prepare(req, hdr->
subsystem,
2817 memcpy(req, wrb_payload, wrb_payload_size);
2820 status = be_mcc_notify_wait(adapter);
2822 *cmd_status = (status & 0xffff);
2828 spin_unlock_bh(&adapter->
mcc_lock);