aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/emulex
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ethernet/emulex')
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h186
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.c27
-rw-r--r--drivers/net/ethernet/emulex/benet/be_cmds.h332
-rw-r--r--drivers/net/ethernet/emulex/benet/be_ethtool.c40
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c333
5 files changed, 639 insertions, 279 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index db020230bd0b..f4825db5d179 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -34,7 +34,7 @@
34#include "be_hw.h" 34#include "be_hw.h"
35#include "be_roce.h" 35#include "be_roce.h"
36 36
37#define DRV_VER "4.9.134.0u" 37#define DRV_VER "4.9.224.0u"
38#define DRV_NAME "be2net" 38#define DRV_NAME "be2net"
39#define BE_NAME "Emulex BladeEngine2" 39#define BE_NAME "Emulex BladeEngine2"
40#define BE3_NAME "Emulex BladeEngine3" 40#define BE3_NAME "Emulex BladeEngine3"
@@ -89,7 +89,7 @@ static inline char *nic_name(struct pci_dev *pdev)
89 89
90#define BE_NUM_VLANS_SUPPORTED 64 90#define BE_NUM_VLANS_SUPPORTED 64
91#define BE_UMC_NUM_VLANS_SUPPORTED 15 91#define BE_UMC_NUM_VLANS_SUPPORTED 15
92#define BE_MAX_EQD 96u 92#define BE_MAX_EQD 128u
93#define BE_MAX_TX_FRAG_COUNT 30 93#define BE_MAX_TX_FRAG_COUNT 30
94 94
95#define EVNT_Q_LEN 1024 95#define EVNT_Q_LEN 1024
@@ -199,8 +199,37 @@ struct be_eq_obj {
199 u16 spurious_intr; 199 u16 spurious_intr;
200 struct napi_struct napi; 200 struct napi_struct napi;
201 struct be_adapter *adapter; 201 struct be_adapter *adapter;
202
203#ifdef CONFIG_NET_RX_BUSY_POLL
204#define BE_EQ_IDLE 0
205#define BE_EQ_NAPI 1 /* napi owns this EQ */
206#define BE_EQ_POLL 2 /* poll owns this EQ */
207#define BE_EQ_LOCKED (BE_EQ_NAPI | BE_EQ_POLL)
208#define BE_EQ_NAPI_YIELD 4 /* napi yielded this EQ */
209#define BE_EQ_POLL_YIELD 8 /* poll yielded this EQ */
210#define BE_EQ_YIELD (BE_EQ_NAPI_YIELD | BE_EQ_POLL_YIELD)
211#define BE_EQ_USER_PEND (BE_EQ_POLL | BE_EQ_POLL_YIELD)
212 unsigned int state;
213 spinlock_t lock; /* lock to serialize napi and busy-poll */
214#endif /* CONFIG_NET_RX_BUSY_POLL */
202} ____cacheline_aligned_in_smp; 215} ____cacheline_aligned_in_smp;
203 216
217struct be_aic_obj { /* Adaptive interrupt coalescing (AIC) info */
218 bool enable;
219 u32 min_eqd; /* in usecs */
220 u32 max_eqd; /* in usecs */
221 u32 prev_eqd; /* in usecs */
222 u32 et_eqd; /* configured val when aic is off */
223 ulong jiffies;
224 u64 rx_pkts_prev; /* Used to calculate RX pps */
225 u64 tx_reqs_prev; /* Used to calculate TX pps */
226};
227
228enum {
229 NAPI_POLLING,
230 BUSY_POLLING
231};
232
204struct be_mcc_obj { 233struct be_mcc_obj {
205 struct be_queue_info q; 234 struct be_queue_info q;
206 struct be_queue_info cq; 235 struct be_queue_info cq;
@@ -215,6 +244,7 @@ struct be_tx_stats {
215 u64 tx_compl; 244 u64 tx_compl;
216 ulong tx_jiffies; 245 ulong tx_jiffies;
217 u32 tx_stops; 246 u32 tx_stops;
247 u32 tx_drv_drops; /* pkts dropped by driver */
218 struct u64_stats_sync sync; 248 struct u64_stats_sync sync;
219 struct u64_stats_sync sync_compl; 249 struct u64_stats_sync sync_compl;
220}; 250};
@@ -239,15 +269,12 @@ struct be_rx_page_info {
239struct be_rx_stats { 269struct be_rx_stats {
240 u64 rx_bytes; 270 u64 rx_bytes;
241 u64 rx_pkts; 271 u64 rx_pkts;
242 u64 rx_pkts_prev;
243 ulong rx_jiffies;
244 u32 rx_drops_no_skbs; /* skb allocation errors */ 272 u32 rx_drops_no_skbs; /* skb allocation errors */
245 u32 rx_drops_no_frags; /* HW has no fetched frags */ 273 u32 rx_drops_no_frags; /* HW has no fetched frags */
246 u32 rx_post_fail; /* page post alloc failures */ 274 u32 rx_post_fail; /* page post alloc failures */
247 u32 rx_compl; 275 u32 rx_compl;
248 u32 rx_mcast_pkts; 276 u32 rx_mcast_pkts;
249 u32 rx_compl_err; /* completions with err set */ 277 u32 rx_compl_err; /* completions with err set */
250 u32 rx_pps; /* pkts per second */
251 struct u64_stats_sync sync; 278 struct u64_stats_sync sync;
252}; 279};
253 280
@@ -316,6 +343,11 @@ struct be_drv_stats {
316 u32 rx_input_fifo_overflow_drop; 343 u32 rx_input_fifo_overflow_drop;
317 u32 pmem_fifo_overflow_drop; 344 u32 pmem_fifo_overflow_drop;
318 u32 jabber_events; 345 u32 jabber_events;
346 u32 rx_roce_bytes_lsd;
347 u32 rx_roce_bytes_msd;
348 u32 rx_roce_frames;
349 u32 roce_drops_payload_len;
350 u32 roce_drops_crc;
319}; 351};
320 352
321struct be_vf_cfg { 353struct be_vf_cfg {
@@ -405,6 +437,7 @@ struct be_adapter {
405 u32 big_page_size; /* Compounded page size shared by rx wrbs */ 437 u32 big_page_size; /* Compounded page size shared by rx wrbs */
406 438
407 struct be_drv_stats drv_stats; 439 struct be_drv_stats drv_stats;
440 struct be_aic_obj aic_obj[MAX_EVT_QS];
408 u16 vlans_added; 441 u16 vlans_added;
409 u8 vlan_tag[VLAN_N_VID]; 442 u8 vlan_tag[VLAN_N_VID];
410 u8 vlan_prio_bmap; /* Available Priority BitMap */ 443 u8 vlan_prio_bmap; /* Available Priority BitMap */
@@ -437,7 +470,6 @@ struct be_adapter {
437 u32 rx_fc; /* Rx flow control */ 470 u32 rx_fc; /* Rx flow control */
438 u32 tx_fc; /* Tx flow control */ 471 u32 tx_fc; /* Tx flow control */
439 bool stats_cmd_sent; 472 bool stats_cmd_sent;
440 u32 if_type;
441 struct { 473 struct {
442 u32 size; 474 u32 size;
443 u32 total_size; 475 u32 total_size;
@@ -472,8 +504,8 @@ struct be_adapter {
472 504
473#define be_physfn(adapter) (!adapter->virtfn) 505#define be_physfn(adapter) (!adapter->virtfn)
474#define sriov_enabled(adapter) (adapter->num_vfs > 0) 506#define sriov_enabled(adapter) (adapter->num_vfs > 0)
475#define sriov_want(adapter) (be_max_vfs(adapter) && num_vfs && \ 507#define sriov_want(adapter) (be_physfn(adapter) && \
476 be_physfn(adapter)) 508 (num_vfs || pci_num_vf(adapter->pdev)))
477#define for_all_vfs(adapter, vf_cfg, i) \ 509#define for_all_vfs(adapter, vf_cfg, i) \
478 for (i = 0, vf_cfg = &adapter->vf_cfg[i]; i < adapter->num_vfs; \ 510 for (i = 0, vf_cfg = &adapter->vf_cfg[i]; i < adapter->num_vfs; \
479 i++, vf_cfg++) 511 i++, vf_cfg++)
@@ -546,6 +578,10 @@ extern const struct ethtool_ops be_ethtool_ops;
546 for (i = 0, eqo = &adapter->eq_obj[i]; i < adapter->num_evt_qs; \ 578 for (i = 0, eqo = &adapter->eq_obj[i]; i < adapter->num_evt_qs; \
547 i++, eqo++) 579 i++, eqo++)
548 580
581#define for_all_rx_queues_on_eq(adapter, eqo, rxo, i) \
582 for (i = eqo->idx, rxo = &adapter->rx_obj[i]; i < adapter->num_rx_qs;\
583 i += adapter->num_evt_qs, rxo += adapter->num_evt_qs)
584
549#define is_mcc_eqo(eqo) (eqo->idx == 0) 585#define is_mcc_eqo(eqo) (eqo->idx == 0)
550#define mcc_eqo(adapter) (&adapter->eq_obj[0]) 586#define mcc_eqo(adapter) (&adapter->eq_obj[0])
551 587
@@ -696,27 +732,137 @@ static inline int qnq_async_evt_rcvd(struct be_adapter *adapter)
696 return adapter->flags & BE_FLAGS_QNQ_ASYNC_EVT_RCVD; 732 return adapter->flags & BE_FLAGS_QNQ_ASYNC_EVT_RCVD;
697} 733}
698 734
699extern void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm, 735#ifdef CONFIG_NET_RX_BUSY_POLL
700 u16 num_popped); 736static inline bool be_lock_napi(struct be_eq_obj *eqo)
701extern void be_link_status_update(struct be_adapter *adapter, u8 link_status); 737{
702extern void be_parse_stats(struct be_adapter *adapter); 738 bool status = true;
703extern int be_load_fw(struct be_adapter *adapter, u8 *func); 739
704extern bool be_is_wol_supported(struct be_adapter *adapter); 740 spin_lock(&eqo->lock); /* BH is already disabled */
705extern bool be_pause_supported(struct be_adapter *adapter); 741 if (eqo->state & BE_EQ_LOCKED) {
706extern u32 be_get_fw_log_level(struct be_adapter *adapter); 742 WARN_ON(eqo->state & BE_EQ_NAPI);
743 eqo->state |= BE_EQ_NAPI_YIELD;
744 status = false;
745 } else {
746 eqo->state = BE_EQ_NAPI;
747 }
748 spin_unlock(&eqo->lock);
749 return status;
750}
751
752static inline void be_unlock_napi(struct be_eq_obj *eqo)
753{
754 spin_lock(&eqo->lock); /* BH is already disabled */
755
756 WARN_ON(eqo->state & (BE_EQ_POLL | BE_EQ_NAPI_YIELD));
757 eqo->state = BE_EQ_IDLE;
758
759 spin_unlock(&eqo->lock);
760}
761
762static inline bool be_lock_busy_poll(struct be_eq_obj *eqo)
763{
764 bool status = true;
765
766 spin_lock_bh(&eqo->lock);
767 if (eqo->state & BE_EQ_LOCKED) {
768 eqo->state |= BE_EQ_POLL_YIELD;
769 status = false;
770 } else {
771 eqo->state |= BE_EQ_POLL;
772 }
773 spin_unlock_bh(&eqo->lock);
774 return status;
775}
776
777static inline void be_unlock_busy_poll(struct be_eq_obj *eqo)
778{
779 spin_lock_bh(&eqo->lock);
780
781 WARN_ON(eqo->state & (BE_EQ_NAPI));
782 eqo->state = BE_EQ_IDLE;
783
784 spin_unlock_bh(&eqo->lock);
785}
786
787static inline void be_enable_busy_poll(struct be_eq_obj *eqo)
788{
789 spin_lock_init(&eqo->lock);
790 eqo->state = BE_EQ_IDLE;
791}
792
793static inline void be_disable_busy_poll(struct be_eq_obj *eqo)
794{
795 local_bh_disable();
796
797 /* It's enough to just acquire napi lock on the eqo to stop
798 * be_busy_poll() from processing any queueus.
799 */
800 while (!be_lock_napi(eqo))
801 mdelay(1);
802
803 local_bh_enable();
804}
805
806#else /* CONFIG_NET_RX_BUSY_POLL */
807
808static inline bool be_lock_napi(struct be_eq_obj *eqo)
809{
810 return true;
811}
812
813static inline void be_unlock_napi(struct be_eq_obj *eqo)
814{
815}
816
817static inline bool be_lock_busy_poll(struct be_eq_obj *eqo)
818{
819 return false;
820}
821
822static inline void be_unlock_busy_poll(struct be_eq_obj *eqo)
823{
824}
825
826static inline void be_enable_busy_poll(struct be_eq_obj *eqo)
827{
828}
829
830static inline void be_disable_busy_poll(struct be_eq_obj *eqo)
831{
832}
833#endif /* CONFIG_NET_RX_BUSY_POLL */
834
835void be_cq_notify(struct be_adapter *adapter, u16 qid, bool arm,
836 u16 num_popped);
837void be_link_status_update(struct be_adapter *adapter, u8 link_status);
838void be_parse_stats(struct be_adapter *adapter);
839int be_load_fw(struct be_adapter *adapter, u8 *func);
840bool be_is_wol_supported(struct be_adapter *adapter);
841bool be_pause_supported(struct be_adapter *adapter);
842u32 be_get_fw_log_level(struct be_adapter *adapter);
843
844static inline int fw_major_num(const char *fw_ver)
845{
846 int fw_major = 0;
847
848 sscanf(fw_ver, "%d.", &fw_major);
849
850 return fw_major;
851}
852
707int be_update_queues(struct be_adapter *adapter); 853int be_update_queues(struct be_adapter *adapter);
708int be_poll(struct napi_struct *napi, int budget); 854int be_poll(struct napi_struct *napi, int budget);
709 855
710/* 856/*
711 * internal function to initialize-cleanup roce device. 857 * internal function to initialize-cleanup roce device.
712 */ 858 */
713extern void be_roce_dev_add(struct be_adapter *); 859void be_roce_dev_add(struct be_adapter *);
714extern void be_roce_dev_remove(struct be_adapter *); 860void be_roce_dev_remove(struct be_adapter *);
715 861
716/* 862/*
717 * internal function to open-close roce device during ifup-ifdown. 863 * internal function to open-close roce device during ifup-ifdown.
718 */ 864 */
719extern void be_roce_dev_open(struct be_adapter *); 865void be_roce_dev_open(struct be_adapter *);
720extern void be_roce_dev_close(struct be_adapter *); 866void be_roce_dev_close(struct be_adapter *);
721 867
722#endif /* BE_H */ 868#endif /* BE_H */
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index c08fd32bb8e5..7fb0edfe3d24 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -522,7 +522,7 @@ static u16 be_POST_stage_get(struct be_adapter *adapter)
522 return sem & POST_STAGE_MASK; 522 return sem & POST_STAGE_MASK;
523} 523}
524 524
525int lancer_wait_ready(struct be_adapter *adapter) 525static int lancer_wait_ready(struct be_adapter *adapter)
526{ 526{
527#define SLIPORT_READY_TIMEOUT 30 527#define SLIPORT_READY_TIMEOUT 30
528 u32 sliport_status; 528 u32 sliport_status;
@@ -1436,8 +1436,12 @@ int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd)
1436 OPCODE_ETH_GET_STATISTICS, nonemb_cmd->size, wrb, nonemb_cmd); 1436 OPCODE_ETH_GET_STATISTICS, nonemb_cmd->size, wrb, nonemb_cmd);
1437 1437
1438 /* version 1 of the cmd is not supported only by BE2 */ 1438 /* version 1 of the cmd is not supported only by BE2 */
1439 if (!BE2_chip(adapter)) 1439 if (BE2_chip(adapter))
1440 hdr->version = 0;
1441 if (BE3_chip(adapter) || lancer_chip(adapter))
1440 hdr->version = 1; 1442 hdr->version = 1;
1443 else
1444 hdr->version = 2;
1441 1445
1442 be_mcc_notify(adapter); 1446 be_mcc_notify(adapter);
1443 adapter->stats_cmd_sent = true; 1447 adapter->stats_cmd_sent = true;
@@ -1719,11 +1723,12 @@ err:
1719/* set the EQ delay interval of an EQ to specified value 1723/* set the EQ delay interval of an EQ to specified value
1720 * Uses async mcc 1724 * Uses async mcc
1721 */ 1725 */
1722int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd) 1726int be_cmd_modify_eqd(struct be_adapter *adapter, struct be_set_eqd *set_eqd,
1727 int num)
1723{ 1728{
1724 struct be_mcc_wrb *wrb; 1729 struct be_mcc_wrb *wrb;
1725 struct be_cmd_req_modify_eq_delay *req; 1730 struct be_cmd_req_modify_eq_delay *req;
1726 int status = 0; 1731 int status = 0, i;
1727 1732
1728 spin_lock_bh(&adapter->mcc_lock); 1733 spin_lock_bh(&adapter->mcc_lock);
1729 1734
@@ -1737,13 +1742,15 @@ int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd)
1737 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, 1742 be_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,
1738 OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req), wrb, NULL); 1743 OPCODE_COMMON_MODIFY_EQ_DELAY, sizeof(*req), wrb, NULL);
1739 1744
1740 req->num_eq = cpu_to_le32(1); 1745 req->num_eq = cpu_to_le32(num);
1741 req->delay[0].eq_id = cpu_to_le32(eq_id); 1746 for (i = 0; i < num; i++) {
1742 req->delay[0].phase = 0; 1747 req->set_eqd[i].eq_id = cpu_to_le32(set_eqd[i].eq_id);
1743 req->delay[0].delay_multiplier = cpu_to_le32(eqd); 1748 req->set_eqd[i].phase = 0;
1749 req->set_eqd[i].delay_multiplier =
1750 cpu_to_le32(set_eqd[i].delay_multiplier);
1751 }
1744 1752
1745 be_mcc_notify(adapter); 1753 be_mcc_notify(adapter);
1746
1747err: 1754err:
1748 spin_unlock_bh(&adapter->mcc_lock); 1755 spin_unlock_bh(&adapter->mcc_lock);
1749 return status; 1756 return status;
@@ -3520,7 +3527,7 @@ int be_cmd_enable_vf(struct be_adapter *adapter, u8 domain)
3520 struct be_cmd_enable_disable_vf *req; 3527 struct be_cmd_enable_disable_vf *req;
3521 int status; 3528 int status;
3522 3529
3523 if (!lancer_chip(adapter)) 3530 if (BEx_chip(adapter))
3524 return 0; 3531 return 0;
3525 3532
3526 spin_lock_bh(&adapter->mcc_lock); 3533 spin_lock_bh(&adapter->mcc_lock);
diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.h b/drivers/net/ethernet/emulex/benet/be_cmds.h
index 108ca8abf0af..edf3e8a0ff83 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.h
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.h
@@ -1057,14 +1057,16 @@ struct be_cmd_resp_get_flow_control {
1057} __packed; 1057} __packed;
1058 1058
1059/******************** Modify EQ Delay *******************/ 1059/******************** Modify EQ Delay *******************/
1060struct be_set_eqd {
1061 u32 eq_id;
1062 u32 phase;
1063 u32 delay_multiplier;
1064};
1065
1060struct be_cmd_req_modify_eq_delay { 1066struct be_cmd_req_modify_eq_delay {
1061 struct be_cmd_req_hdr hdr; 1067 struct be_cmd_req_hdr hdr;
1062 u32 num_eq; 1068 u32 num_eq;
1063 struct { 1069 struct be_set_eqd set_eqd[MAX_EVT_QS];
1064 u32 eq_id;
1065 u32 phase;
1066 u32 delay_multiplier;
1067 } delay[8];
1068} __packed; 1070} __packed;
1069 1071
1070struct be_cmd_resp_modify_eq_delay { 1072struct be_cmd_resp_modify_eq_delay {
@@ -1660,6 +1662,67 @@ struct be_erx_stats_v1 {
1660 u32 rsvd[4]; 1662 u32 rsvd[4];
1661}; 1663};
1662 1664
1665struct be_port_rxf_stats_v2 {
1666 u32 rsvd0[10];
1667 u32 roce_bytes_received_lsd;
1668 u32 roce_bytes_received_msd;
1669 u32 rsvd1[5];
1670 u32 roce_frames_received;
1671 u32 rx_crc_errors;
1672 u32 rx_alignment_symbol_errors;
1673 u32 rx_pause_frames;
1674 u32 rx_priority_pause_frames;
1675 u32 rx_control_frames;
1676 u32 rx_in_range_errors;
1677 u32 rx_out_range_errors;
1678 u32 rx_frame_too_long;
1679 u32 rx_address_filtered;
1680 u32 rx_dropped_too_small;
1681 u32 rx_dropped_too_short;
1682 u32 rx_dropped_header_too_small;
1683 u32 rx_dropped_tcp_length;
1684 u32 rx_dropped_runt;
1685 u32 rsvd2[10];
1686 u32 rx_ip_checksum_errs;
1687 u32 rx_tcp_checksum_errs;
1688 u32 rx_udp_checksum_errs;
1689 u32 rsvd3[7];
1690 u32 rx_switched_unicast_packets;
1691 u32 rx_switched_multicast_packets;
1692 u32 rx_switched_broadcast_packets;
1693 u32 rsvd4[3];
1694 u32 tx_pauseframes;
1695 u32 tx_priority_pauseframes;
1696 u32 tx_controlframes;
1697 u32 rsvd5[10];
1698 u32 rxpp_fifo_overflow_drop;
1699 u32 rx_input_fifo_overflow_drop;
1700 u32 pmem_fifo_overflow_drop;
1701 u32 jabber_events;
1702 u32 rsvd6[3];
1703 u32 rx_drops_payload_size;
1704 u32 rx_drops_clipped_header;
1705 u32 rx_drops_crc;
1706 u32 roce_drops_payload_len;
1707 u32 roce_drops_crc;
1708 u32 rsvd7[19];
1709};
1710
1711struct be_rxf_stats_v2 {
1712 struct be_port_rxf_stats_v2 port[4];
1713 u32 rsvd0[2];
1714 u32 rx_drops_no_pbuf;
1715 u32 rx_drops_no_txpb;
1716 u32 rx_drops_no_erx_descr;
1717 u32 rx_drops_no_tpre_descr;
1718 u32 rsvd1[6];
1719 u32 rx_drops_too_many_frags;
1720 u32 rx_drops_invalid_ring;
1721 u32 forwarded_packets;
1722 u32 rx_drops_mtu;
1723 u32 rsvd2[35];
1724};
1725
1663struct be_hw_stats_v1 { 1726struct be_hw_stats_v1 {
1664 struct be_rxf_stats_v1 rxf; 1727 struct be_rxf_stats_v1 rxf;
1665 u32 rsvd0[BE_TXP_SW_SZ]; 1728 u32 rsvd0[BE_TXP_SW_SZ];
@@ -1678,6 +1741,29 @@ struct be_cmd_resp_get_stats_v1 {
1678 struct be_hw_stats_v1 hw_stats; 1741 struct be_hw_stats_v1 hw_stats;
1679}; 1742};
1680 1743
1744struct be_erx_stats_v2 {
1745 u32 rx_drops_no_fragments[136]; /* dwordS 0 to 135*/
1746 u32 rsvd[3];
1747};
1748
1749struct be_hw_stats_v2 {
1750 struct be_rxf_stats_v2 rxf;
1751 u32 rsvd0[BE_TXP_SW_SZ];
1752 struct be_erx_stats_v2 erx;
1753 struct be_pmem_stats pmem;
1754 u32 rsvd1[18];
1755};
1756
1757struct be_cmd_req_get_stats_v2 {
1758 struct be_cmd_req_hdr hdr;
1759 u8 rsvd[sizeof(struct be_hw_stats_v2)];
1760};
1761
1762struct be_cmd_resp_get_stats_v2 {
1763 struct be_cmd_resp_hdr hdr;
1764 struct be_hw_stats_v2 hw_stats;
1765};
1766
1681/************** get fat capabilites *******************/ 1767/************** get fat capabilites *******************/
1682#define MAX_MODULES 27 1768#define MAX_MODULES 27
1683#define MAX_MODES 4 1769#define MAX_MODES 4
@@ -1865,137 +1951,119 @@ struct be_cmd_resp_get_iface_list {
1865 struct be_if_desc if_desc; 1951 struct be_if_desc if_desc;
1866}; 1952};
1867 1953
1868extern int be_pci_fnum_get(struct be_adapter *adapter); 1954int be_pci_fnum_get(struct be_adapter *adapter);
1869extern int be_fw_wait_ready(struct be_adapter *adapter); 1955int be_fw_wait_ready(struct be_adapter *adapter);
1870extern int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr, 1956int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
1871 bool permanent, u32 if_handle, u32 pmac_id); 1957 bool permanent, u32 if_handle, u32 pmac_id);
1872extern int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, 1958int be_cmd_pmac_add(struct be_adapter *adapter, u8 *mac_addr, u32 if_id,
1873 u32 if_id, u32 *pmac_id, u32 domain); 1959 u32 *pmac_id, u32 domain);
1874extern int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, 1960int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, int pmac_id,
1875 int pmac_id, u32 domain); 1961 u32 domain);
1876extern int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, 1962int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
1877 u32 en_flags, u32 *if_handle, u32 domain); 1963 u32 *if_handle, u32 domain);
1878extern int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle, 1964int be_cmd_if_destroy(struct be_adapter *adapter, int if_handle, u32 domain);
1879 u32 domain); 1965int be_cmd_eq_create(struct be_adapter *adapter, struct be_eq_obj *eqo);
1880extern int be_cmd_eq_create(struct be_adapter *adapter, struct be_eq_obj *eqo); 1966int be_cmd_cq_create(struct be_adapter *adapter, struct be_queue_info *cq,
1881extern int be_cmd_cq_create(struct be_adapter *adapter, 1967 struct be_queue_info *eq, bool no_delay,
1882 struct be_queue_info *cq, struct be_queue_info *eq, 1968 int num_cqe_dma_coalesce);
1883 bool no_delay, int num_cqe_dma_coalesce); 1969int be_cmd_mccq_create(struct be_adapter *adapter, struct be_queue_info *mccq,
1884extern int be_cmd_mccq_create(struct be_adapter *adapter, 1970 struct be_queue_info *cq);
1885 struct be_queue_info *mccq, 1971int be_cmd_txq_create(struct be_adapter *adapter, struct be_tx_obj *txo);
1886 struct be_queue_info *cq); 1972int be_cmd_rxq_create(struct be_adapter *adapter, struct be_queue_info *rxq,
1887extern int be_cmd_txq_create(struct be_adapter *adapter, 1973 u16 cq_id, u16 frag_size, u32 if_id, u32 rss, u8 *rss_id);
1888 struct be_tx_obj *txo); 1974int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
1889extern int be_cmd_rxq_create(struct be_adapter *adapter, 1975 int type);
1890 struct be_queue_info *rxq, u16 cq_id, 1976int be_cmd_rxq_destroy(struct be_adapter *adapter, struct be_queue_info *q);
1891 u16 frag_size, u32 if_id, u32 rss, u8 *rss_id); 1977int be_cmd_link_status_query(struct be_adapter *adapter, u16 *link_speed,
1892extern int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q, 1978 u8 *link_status, u32 dom);
1893 int type); 1979int be_cmd_reset(struct be_adapter *adapter);
1894extern int be_cmd_rxq_destroy(struct be_adapter *adapter, 1980int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd);
1895 struct be_queue_info *q); 1981int lancer_cmd_get_pport_stats(struct be_adapter *adapter,
1896extern int be_cmd_link_status_query(struct be_adapter *adapter, u16 *link_speed, 1982 struct be_dma_mem *nonemb_cmd);
1897 u8 *link_status, u32 dom); 1983int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver,
1898extern int be_cmd_reset(struct be_adapter *adapter); 1984 char *fw_on_flash);
1899extern int be_cmd_get_stats(struct be_adapter *adapter, 1985int be_cmd_modify_eqd(struct be_adapter *adapter, struct be_set_eqd *, int num);
1900 struct be_dma_mem *nonemb_cmd); 1986int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
1901extern int lancer_cmd_get_pport_stats(struct be_adapter *adapter, 1987 u32 num, bool untagged, bool promiscuous);
1902 struct be_dma_mem *nonemb_cmd); 1988int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 status);
1903extern int be_cmd_get_fw_ver(struct be_adapter *adapter, char *fw_ver, 1989int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc);
1904 char *fw_on_flash); 1990int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc);
1905 1991int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num,
1906extern int be_cmd_modify_eqd(struct be_adapter *adapter, u32 eq_id, u32 eqd);
1907extern int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id,
1908 u16 *vtag_array, u32 num, bool untagged,
1909 bool promiscuous);
1910extern int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 status);
1911extern int be_cmd_set_flow_control(struct be_adapter *adapter,
1912 u32 tx_fc, u32 rx_fc);
1913extern int be_cmd_get_flow_control(struct be_adapter *adapter,
1914 u32 *tx_fc, u32 *rx_fc);
1915extern int be_cmd_query_fw_cfg(struct be_adapter *adapter, u32 *port_num,
1916 u32 *function_mode, u32 *function_caps, u16 *asic_rev); 1992 u32 *function_mode, u32 *function_caps, u16 *asic_rev);
1917extern int be_cmd_reset_function(struct be_adapter *adapter); 1993int be_cmd_reset_function(struct be_adapter *adapter);
1918extern int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable, 1994int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable,
1919 u32 rss_hash_opts, u16 table_size); 1995 u32 rss_hash_opts, u16 table_size);
1920extern int be_process_mcc(struct be_adapter *adapter); 1996int be_process_mcc(struct be_adapter *adapter);
1921extern int be_cmd_set_beacon_state(struct be_adapter *adapter, 1997int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num, u8 beacon,
1922 u8 port_num, u8 beacon, u8 status, u8 state); 1998 u8 status, u8 state);
1923extern int be_cmd_get_beacon_state(struct be_adapter *adapter, 1999int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num,
1924 u8 port_num, u32 *state); 2000 u32 *state);
1925extern int be_cmd_write_flashrom(struct be_adapter *adapter, 2001int be_cmd_write_flashrom(struct be_adapter *adapter, struct be_dma_mem *cmd,
1926 struct be_dma_mem *cmd, u32 flash_oper, 2002 u32 flash_oper, u32 flash_opcode, u32 buf_size);
1927 u32 flash_opcode, u32 buf_size); 2003int lancer_cmd_write_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
1928extern int lancer_cmd_write_object(struct be_adapter *adapter, 2004 u32 data_size, u32 data_offset,
1929 struct be_dma_mem *cmd, 2005 const char *obj_name, u32 *data_written,
1930 u32 data_size, u32 data_offset, 2006 u8 *change_status, u8 *addn_status);
1931 const char *obj_name,
1932 u32 *data_written, u8 *change_status,
1933 u8 *addn_status);
1934int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *cmd, 2007int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
1935 u32 data_size, u32 data_offset, const char *obj_name, 2008 u32 data_size, u32 data_offset, const char *obj_name,
1936 u32 *data_read, u32 *eof, u8 *addn_status); 2009 u32 *data_read, u32 *eof, u8 *addn_status);
1937int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc, 2010int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
1938 int offset); 2011 int offset);
1939extern int be_cmd_enable_magic_wol(struct be_adapter *adapter, u8 *mac, 2012int be_cmd_enable_magic_wol(struct be_adapter *adapter, u8 *mac,
1940 struct be_dma_mem *nonemb_cmd); 2013 struct be_dma_mem *nonemb_cmd);
1941extern int be_cmd_fw_init(struct be_adapter *adapter); 2014int be_cmd_fw_init(struct be_adapter *adapter);
1942extern int be_cmd_fw_clean(struct be_adapter *adapter); 2015int be_cmd_fw_clean(struct be_adapter *adapter);
1943extern void be_async_mcc_enable(struct be_adapter *adapter); 2016void be_async_mcc_enable(struct be_adapter *adapter);
1944extern void be_async_mcc_disable(struct be_adapter *adapter); 2017void be_async_mcc_disable(struct be_adapter *adapter);
1945extern int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num, 2018int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,
1946 u32 loopback_type, u32 pkt_size, 2019 u32 loopback_type, u32 pkt_size, u32 num_pkts,
1947 u32 num_pkts, u64 pattern); 2020 u64 pattern);
1948extern int be_cmd_ddr_dma_test(struct be_adapter *adapter, u64 pattern, 2021int be_cmd_ddr_dma_test(struct be_adapter *adapter, u64 pattern, u32 byte_cnt,
1949 u32 byte_cnt, struct be_dma_mem *cmd); 2022 struct be_dma_mem *cmd);
1950extern int be_cmd_get_seeprom_data(struct be_adapter *adapter, 2023int be_cmd_get_seeprom_data(struct be_adapter *adapter,
1951 struct be_dma_mem *nonemb_cmd); 2024 struct be_dma_mem *nonemb_cmd);
1952extern int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num, 2025int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num,
1953 u8 loopback_type, u8 enable); 2026 u8 loopback_type, u8 enable);
1954extern int be_cmd_get_phy_info(struct be_adapter *adapter); 2027int be_cmd_get_phy_info(struct be_adapter *adapter);
1955extern int be_cmd_set_qos(struct be_adapter *adapter, u32 bps, u32 domain); 2028int be_cmd_set_qos(struct be_adapter *adapter, u32 bps, u32 domain);
1956extern void be_detect_error(struct be_adapter *adapter); 2029void be_detect_error(struct be_adapter *adapter);
1957extern int be_cmd_get_die_temperature(struct be_adapter *adapter); 2030int be_cmd_get_die_temperature(struct be_adapter *adapter);
1958extern int be_cmd_get_cntl_attributes(struct be_adapter *adapter); 2031int be_cmd_get_cntl_attributes(struct be_adapter *adapter);
1959extern int be_cmd_req_native_mode(struct be_adapter *adapter); 2032int be_cmd_req_native_mode(struct be_adapter *adapter);
1960extern int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size); 2033int be_cmd_get_reg_len(struct be_adapter *adapter, u32 *log_size);
1961extern void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf); 2034void be_cmd_get_regs(struct be_adapter *adapter, u32 buf_len, void *buf);
1962extern int be_cmd_get_fn_privileges(struct be_adapter *adapter, 2035int be_cmd_get_fn_privileges(struct be_adapter *adapter, u32 *privilege,
1963 u32 *privilege, u32 domain); 2036 u32 domain);
1964extern int be_cmd_set_fn_privileges(struct be_adapter *adapter, 2037int be_cmd_set_fn_privileges(struct be_adapter *adapter, u32 privileges,
1965 u32 privileges, u32 vf_num); 2038 u32 vf_num);
1966extern int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac, 2039int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
1967 bool *pmac_id_active, u32 *pmac_id, 2040 bool *pmac_id_active, u32 *pmac_id, u8 domain);
1968 u8 domain); 2041int be_cmd_get_active_mac(struct be_adapter *adapter, u32 pmac_id, u8 *mac);
1969extern int be_cmd_get_active_mac(struct be_adapter *adapter, u32 pmac_id, 2042int be_cmd_get_perm_mac(struct be_adapter *adapter, u8 *mac);
1970 u8 *mac); 2043int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, u8 mac_count,
1971extern int be_cmd_get_perm_mac(struct be_adapter *adapter, u8 *mac); 2044 u32 domain);
1972extern int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array, 2045int be_cmd_set_mac(struct be_adapter *adapter, u8 *mac, int if_id, u32 dom);
1973 u8 mac_count, u32 domain); 2046int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid, u32 domain,
1974extern int be_cmd_set_mac(struct be_adapter *adapter, u8 *mac, int if_id, 2047 u16 intf_id, u16 hsw_mode);
1975 u32 dom); 2048int be_cmd_get_hsw_config(struct be_adapter *adapter, u16 *pvid, u32 domain,
1976extern int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid, 2049 u16 intf_id, u8 *mode);
1977 u32 domain, u16 intf_id, u16 hsw_mode); 2050int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter);
1978extern int be_cmd_get_hsw_config(struct be_adapter *adapter, u16 *pvid, 2051int be_cmd_get_ext_fat_capabilites(struct be_adapter *adapter,
1979 u32 domain, u16 intf_id, u8 *mode); 2052 struct be_dma_mem *cmd);
1980extern int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter); 2053int be_cmd_set_ext_fat_capabilites(struct be_adapter *adapter,
1981extern int be_cmd_get_ext_fat_capabilites(struct be_adapter *adapter, 2054 struct be_dma_mem *cmd,
1982 struct be_dma_mem *cmd); 2055 struct be_fat_conf_params *cfgs);
1983extern int be_cmd_set_ext_fat_capabilites(struct be_adapter *adapter, 2056int lancer_physdev_ctrl(struct be_adapter *adapter, u32 mask);
1984 struct be_dma_mem *cmd, 2057int lancer_initiate_dump(struct be_adapter *adapter);
1985 struct be_fat_conf_params *cfgs); 2058bool dump_present(struct be_adapter *adapter);
1986extern int lancer_wait_ready(struct be_adapter *adapter); 2059int lancer_test_and_set_rdy_state(struct be_adapter *adapter);
1987extern int lancer_physdev_ctrl(struct be_adapter *adapter, u32 mask); 2060int be_cmd_query_port_name(struct be_adapter *adapter, u8 *port_name);
1988extern int lancer_initiate_dump(struct be_adapter *adapter);
1989extern bool dump_present(struct be_adapter *adapter);
1990extern int lancer_test_and_set_rdy_state(struct be_adapter *adapter);
1991extern int be_cmd_query_port_name(struct be_adapter *adapter, u8 *port_name);
1992int be_cmd_get_func_config(struct be_adapter *adapter, 2061int be_cmd_get_func_config(struct be_adapter *adapter,
1993 struct be_resources *res); 2062 struct be_resources *res);
1994int be_cmd_get_profile_config(struct be_adapter *adapter, 2063int be_cmd_get_profile_config(struct be_adapter *adapter,
1995 struct be_resources *res, u8 domain); 2064 struct be_resources *res, u8 domain);
1996extern int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps, 2065int be_cmd_set_profile_config(struct be_adapter *adapter, u32 bps, u8 domain);
1997 u8 domain); 2066int be_cmd_get_if_id(struct be_adapter *adapter, struct be_vf_cfg *vf_cfg,
1998extern int be_cmd_get_if_id(struct be_adapter *adapter, 2067 int vf_num);
1999 struct be_vf_cfg *vf_cfg, int vf_num); 2068int be_cmd_enable_vf(struct be_adapter *adapter, u8 domain);
2000extern int be_cmd_enable_vf(struct be_adapter *adapter, u8 domain); 2069int be_cmd_intr_set(struct be_adapter *adapter, bool intr_enable);
2001extern int be_cmd_intr_set(struct be_adapter *adapter, bool intr_enable);
diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c
index b440a1fac77b..08330034d9ef 100644
--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c
+++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c
@@ -116,7 +116,12 @@ static const struct be_ethtool_stat et_stats[] = {
116 {DRVSTAT_INFO(rx_drops_mtu)}, 116 {DRVSTAT_INFO(rx_drops_mtu)},
117 /* Number of packets dropped due to random early drop function */ 117 /* Number of packets dropped due to random early drop function */
118 {DRVSTAT_INFO(eth_red_drops)}, 118 {DRVSTAT_INFO(eth_red_drops)},
119 {DRVSTAT_INFO(be_on_die_temperature)} 119 {DRVSTAT_INFO(be_on_die_temperature)},
120 {DRVSTAT_INFO(rx_roce_bytes_lsd)},
121 {DRVSTAT_INFO(rx_roce_bytes_msd)},
122 {DRVSTAT_INFO(rx_roce_frames)},
123 {DRVSTAT_INFO(roce_drops_payload_len)},
124 {DRVSTAT_INFO(roce_drops_crc)}
120}; 125};
121#define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats) 126#define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats)
122 127
@@ -155,7 +160,9 @@ static const struct be_ethtool_stat et_tx_stats[] = {
155 /* Number of times the TX queue was stopped due to lack 160 /* Number of times the TX queue was stopped due to lack
156 * of spaces in the TXQ. 161 * of spaces in the TXQ.
157 */ 162 */
158 {DRVSTAT_TX_INFO(tx_stops)} 163 {DRVSTAT_TX_INFO(tx_stops)},
164 /* Pkts dropped in the driver's transmit path */
165 {DRVSTAT_TX_INFO(tx_drv_drops)}
159}; 166};
160#define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats)) 167#define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats))
161 168
@@ -290,19 +297,19 @@ static int be_get_coalesce(struct net_device *netdev,
290 struct ethtool_coalesce *et) 297 struct ethtool_coalesce *et)
291{ 298{
292 struct be_adapter *adapter = netdev_priv(netdev); 299 struct be_adapter *adapter = netdev_priv(netdev);
293 struct be_eq_obj *eqo = &adapter->eq_obj[0]; 300 struct be_aic_obj *aic = &adapter->aic_obj[0];
294 301
295 302
296 et->rx_coalesce_usecs = eqo->cur_eqd; 303 et->rx_coalesce_usecs = aic->prev_eqd;
297 et->rx_coalesce_usecs_high = eqo->max_eqd; 304 et->rx_coalesce_usecs_high = aic->max_eqd;
298 et->rx_coalesce_usecs_low = eqo->min_eqd; 305 et->rx_coalesce_usecs_low = aic->min_eqd;
299 306
300 et->tx_coalesce_usecs = eqo->cur_eqd; 307 et->tx_coalesce_usecs = aic->prev_eqd;
301 et->tx_coalesce_usecs_high = eqo->max_eqd; 308 et->tx_coalesce_usecs_high = aic->max_eqd;
302 et->tx_coalesce_usecs_low = eqo->min_eqd; 309 et->tx_coalesce_usecs_low = aic->min_eqd;
303 310
304 et->use_adaptive_rx_coalesce = eqo->enable_aic; 311 et->use_adaptive_rx_coalesce = aic->enable;
305 et->use_adaptive_tx_coalesce = eqo->enable_aic; 312 et->use_adaptive_tx_coalesce = aic->enable;
306 313
307 return 0; 314 return 0;
308} 315}
@@ -314,14 +321,17 @@ static int be_set_coalesce(struct net_device *netdev,
314 struct ethtool_coalesce *et) 321 struct ethtool_coalesce *et)
315{ 322{
316 struct be_adapter *adapter = netdev_priv(netdev); 323 struct be_adapter *adapter = netdev_priv(netdev);
324 struct be_aic_obj *aic = &adapter->aic_obj[0];
317 struct be_eq_obj *eqo; 325 struct be_eq_obj *eqo;
318 int i; 326 int i;
319 327
320 for_all_evt_queues(adapter, eqo, i) { 328 for_all_evt_queues(adapter, eqo, i) {
321 eqo->enable_aic = et->use_adaptive_rx_coalesce; 329 aic->enable = et->use_adaptive_rx_coalesce;
322 eqo->max_eqd = min(et->rx_coalesce_usecs_high, BE_MAX_EQD); 330 aic->max_eqd = min(et->rx_coalesce_usecs_high, BE_MAX_EQD);
323 eqo->min_eqd = min(et->rx_coalesce_usecs_low, eqo->max_eqd); 331 aic->min_eqd = min(et->rx_coalesce_usecs_low, aic->max_eqd);
324 eqo->eqd = et->rx_coalesce_usecs; 332 aic->et_eqd = min(et->rx_coalesce_usecs, aic->max_eqd);
333 aic->et_eqd = max(aic->et_eqd, aic->min_eqd);
334 aic++;
325 } 335 }
326 336
327 return 0; 337 return 0;
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index edd75950855a..eaecaadfa8c5 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -22,6 +22,7 @@
22#include <asm/div64.h> 22#include <asm/div64.h>
23#include <linux/aer.h> 23#include <linux/aer.h>
24#include <linux/if_bridge.h> 24#include <linux/if_bridge.h>
25#include <net/busy_poll.h>
25 26
26MODULE_VERSION(DRV_VER); 27MODULE_VERSION(DRV_VER);
27MODULE_DEVICE_TABLE(pci, be_dev_ids); 28MODULE_DEVICE_TABLE(pci, be_dev_ids);
@@ -306,10 +307,14 @@ static void *hw_stats_from_cmd(struct be_adapter *adapter)
306 struct be_cmd_resp_get_stats_v0 *cmd = adapter->stats_cmd.va; 307 struct be_cmd_resp_get_stats_v0 *cmd = adapter->stats_cmd.va;
307 308
308 return &cmd->hw_stats; 309 return &cmd->hw_stats;
309 } else { 310 } else if (BE3_chip(adapter)) {
310 struct be_cmd_resp_get_stats_v1 *cmd = adapter->stats_cmd.va; 311 struct be_cmd_resp_get_stats_v1 *cmd = adapter->stats_cmd.va;
311 312
312 return &cmd->hw_stats; 313 return &cmd->hw_stats;
314 } else {
315 struct be_cmd_resp_get_stats_v2 *cmd = adapter->stats_cmd.va;
316
317 return &cmd->hw_stats;
313 } 318 }
314} 319}
315 320
@@ -320,10 +325,14 @@ static void *be_erx_stats_from_cmd(struct be_adapter *adapter)
320 struct be_hw_stats_v0 *hw_stats = hw_stats_from_cmd(adapter); 325 struct be_hw_stats_v0 *hw_stats = hw_stats_from_cmd(adapter);
321 326
322 return &hw_stats->erx; 327 return &hw_stats->erx;
323 } else { 328 } else if (BE3_chip(adapter)) {
324 struct be_hw_stats_v1 *hw_stats = hw_stats_from_cmd(adapter); 329 struct be_hw_stats_v1 *hw_stats = hw_stats_from_cmd(adapter);
325 330
326 return &hw_stats->erx; 331 return &hw_stats->erx;
332 } else {
333 struct be_hw_stats_v2 *hw_stats = hw_stats_from_cmd(adapter);
334
335 return &hw_stats->erx;
327 } 336 }
328} 337}
329 338
@@ -422,6 +431,60 @@ static void populate_be_v1_stats(struct be_adapter *adapter)
422 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops; 431 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops;
423} 432}
424 433
434static void populate_be_v2_stats(struct be_adapter *adapter)
435{
436 struct be_hw_stats_v2 *hw_stats = hw_stats_from_cmd(adapter);
437 struct be_pmem_stats *pmem_sts = &hw_stats->pmem;
438 struct be_rxf_stats_v2 *rxf_stats = &hw_stats->rxf;
439 struct be_port_rxf_stats_v2 *port_stats =
440 &rxf_stats->port[adapter->port_num];
441 struct be_drv_stats *drvs = &adapter->drv_stats;
442
443 be_dws_le_to_cpu(hw_stats, sizeof(*hw_stats));
444 drvs->pmem_fifo_overflow_drop = port_stats->pmem_fifo_overflow_drop;
445 drvs->rx_priority_pause_frames = port_stats->rx_priority_pause_frames;
446 drvs->rx_pause_frames = port_stats->rx_pause_frames;
447 drvs->rx_crc_errors = port_stats->rx_crc_errors;
448 drvs->rx_control_frames = port_stats->rx_control_frames;
449 drvs->rx_in_range_errors = port_stats->rx_in_range_errors;
450 drvs->rx_frame_too_long = port_stats->rx_frame_too_long;
451 drvs->rx_dropped_runt = port_stats->rx_dropped_runt;
452 drvs->rx_ip_checksum_errs = port_stats->rx_ip_checksum_errs;
453 drvs->rx_tcp_checksum_errs = port_stats->rx_tcp_checksum_errs;
454 drvs->rx_udp_checksum_errs = port_stats->rx_udp_checksum_errs;
455 drvs->rx_dropped_tcp_length = port_stats->rx_dropped_tcp_length;
456 drvs->rx_dropped_too_small = port_stats->rx_dropped_too_small;
457 drvs->rx_dropped_too_short = port_stats->rx_dropped_too_short;
458 drvs->rx_out_range_errors = port_stats->rx_out_range_errors;
459 drvs->rx_dropped_header_too_small =
460 port_stats->rx_dropped_header_too_small;
461 drvs->rx_input_fifo_overflow_drop =
462 port_stats->rx_input_fifo_overflow_drop;
463 drvs->rx_address_filtered = port_stats->rx_address_filtered;
464 drvs->rx_alignment_symbol_errors =
465 port_stats->rx_alignment_symbol_errors;
466 drvs->rxpp_fifo_overflow_drop = port_stats->rxpp_fifo_overflow_drop;
467 drvs->tx_pauseframes = port_stats->tx_pauseframes;
468 drvs->tx_controlframes = port_stats->tx_controlframes;
469 drvs->tx_priority_pauseframes = port_stats->tx_priority_pauseframes;
470 drvs->jabber_events = port_stats->jabber_events;
471 drvs->rx_drops_no_pbuf = rxf_stats->rx_drops_no_pbuf;
472 drvs->rx_drops_no_erx_descr = rxf_stats->rx_drops_no_erx_descr;
473 drvs->forwarded_packets = rxf_stats->forwarded_packets;
474 drvs->rx_drops_mtu = rxf_stats->rx_drops_mtu;
475 drvs->rx_drops_no_tpre_descr = rxf_stats->rx_drops_no_tpre_descr;
476 drvs->rx_drops_too_many_frags = rxf_stats->rx_drops_too_many_frags;
477 adapter->drv_stats.eth_red_drops = pmem_sts->eth_red_drops;
478 if (be_roce_supported(adapter)) {
479 drvs->rx_roce_bytes_lsd = port_stats->roce_bytes_received_lsd;
480 drvs->rx_roce_bytes_msd = port_stats->roce_bytes_received_msd;
481 drvs->rx_roce_frames = port_stats->roce_frames_received;
482 drvs->roce_drops_crc = port_stats->roce_drops_crc;
483 drvs->roce_drops_payload_len =
484 port_stats->roce_drops_payload_len;
485 }
486}
487
425static void populate_lancer_stats(struct be_adapter *adapter) 488static void populate_lancer_stats(struct be_adapter *adapter)
426{ 489{
427 490
@@ -489,7 +552,7 @@ static void populate_erx_stats(struct be_adapter *adapter,
489 552
490void be_parse_stats(struct be_adapter *adapter) 553void be_parse_stats(struct be_adapter *adapter)
491{ 554{
492 struct be_erx_stats_v1 *erx = be_erx_stats_from_cmd(adapter); 555 struct be_erx_stats_v2 *erx = be_erx_stats_from_cmd(adapter);
493 struct be_rx_obj *rxo; 556 struct be_rx_obj *rxo;
494 int i; 557 int i;
495 u32 erx_stat; 558 u32 erx_stat;
@@ -499,11 +562,13 @@ void be_parse_stats(struct be_adapter *adapter)
499 } else { 562 } else {
500 if (BE2_chip(adapter)) 563 if (BE2_chip(adapter))
501 populate_be_v0_stats(adapter); 564 populate_be_v0_stats(adapter);
502 else 565 else if (BE3_chip(adapter))
503 /* for BE3 and Skyhawk */ 566 /* for BE3 */
504 populate_be_v1_stats(adapter); 567 populate_be_v1_stats(adapter);
568 else
569 populate_be_v2_stats(adapter);
505 570
506 /* as erx_v1 is longer than v0, ok to use v1 for v0 access */ 571 /* erx_v2 is longer than v0, v1. use v2 for v0, v1 access */
507 for_all_rx_queues(adapter, rxo, i) { 572 for_all_rx_queues(adapter, rxo, i) {
508 erx_stat = erx->rx_drops_no_fragments[rxo->q.id]; 573 erx_stat = erx->rx_drops_no_fragments[rxo->q.id];
509 populate_erx_stats(adapter, rxo, erx_stat); 574 populate_erx_stats(adapter, rxo, erx_stat);
@@ -935,8 +1000,10 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
935 u32 start = txq->head; 1000 u32 start = txq->head;
936 1001
937 skb = be_xmit_workarounds(adapter, skb, &skip_hw_vlan); 1002 skb = be_xmit_workarounds(adapter, skb, &skip_hw_vlan);
938 if (!skb) 1003 if (!skb) {
1004 tx_stats(txo)->tx_drv_drops++;
939 return NETDEV_TX_OK; 1005 return NETDEV_TX_OK;
1006 }
940 1007
941 wrb_cnt = wrb_cnt_for_skb(adapter, skb, &dummy_wrb); 1008 wrb_cnt = wrb_cnt_for_skb(adapter, skb, &dummy_wrb);
942 1009
@@ -965,6 +1032,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
965 be_tx_stats_update(txo, wrb_cnt, copied, gso_segs, stopped); 1032 be_tx_stats_update(txo, wrb_cnt, copied, gso_segs, stopped);
966 } else { 1033 } else {
967 txq->head = start; 1034 txq->head = start;
1035 tx_stats(txo)->tx_drv_drops++;
968 dev_kfree_skb_any(skb); 1036 dev_kfree_skb_any(skb);
969 } 1037 }
970 return NETDEV_TX_OK; 1038 return NETDEV_TX_OK;
@@ -1275,53 +1343,79 @@ static int be_set_vf_tx_rate(struct net_device *netdev,
1275 return status; 1343 return status;
1276} 1344}
1277 1345
1278static void be_eqd_update(struct be_adapter *adapter, struct be_eq_obj *eqo) 1346static void be_aic_update(struct be_aic_obj *aic, u64 rx_pkts, u64 tx_pkts,
1347 ulong now)
1279{ 1348{
1280 struct be_rx_stats *stats = rx_stats(&adapter->rx_obj[eqo->idx]); 1349 aic->rx_pkts_prev = rx_pkts;
1281 ulong now = jiffies; 1350 aic->tx_reqs_prev = tx_pkts;
1282 ulong delta = now - stats->rx_jiffies; 1351 aic->jiffies = now;
1283 u64 pkts; 1352}
1284 unsigned int start, eqd;
1285 1353
1286 if (!eqo->enable_aic) { 1354static void be_eqd_update(struct be_adapter *adapter)
1287 eqd = eqo->eqd; 1355{
1288 goto modify_eqd; 1356 struct be_set_eqd set_eqd[MAX_EVT_QS];
1289 } 1357 int eqd, i, num = 0, start;
1358 struct be_aic_obj *aic;
1359 struct be_eq_obj *eqo;
1360 struct be_rx_obj *rxo;
1361 struct be_tx_obj *txo;
1362 u64 rx_pkts, tx_pkts;
1363 ulong now;
1364 u32 pps, delta;
1290 1365
1291 if (eqo->idx >= adapter->num_rx_qs) 1366 for_all_evt_queues(adapter, eqo, i) {
1292 return; 1367 aic = &adapter->aic_obj[eqo->idx];
1368 if (!aic->enable) {
1369 if (aic->jiffies)
1370 aic->jiffies = 0;
1371 eqd = aic->et_eqd;
1372 goto modify_eqd;
1373 }
1293 1374
1294 stats = rx_stats(&adapter->rx_obj[eqo->idx]); 1375 rxo = &adapter->rx_obj[eqo->idx];
1376 do {
1377 start = u64_stats_fetch_begin_bh(&rxo->stats.sync);
1378 rx_pkts = rxo->stats.rx_pkts;
1379 } while (u64_stats_fetch_retry_bh(&rxo->stats.sync, start));
1295 1380
1296 /* Wrapped around */ 1381 txo = &adapter->tx_obj[eqo->idx];
1297 if (time_before(now, stats->rx_jiffies)) { 1382 do {
1298 stats->rx_jiffies = now; 1383 start = u64_stats_fetch_begin_bh(&txo->stats.sync);
1299 return; 1384 tx_pkts = txo->stats.tx_reqs;
1300 } 1385 } while (u64_stats_fetch_retry_bh(&txo->stats.sync, start));
1301 1386
1302 /* Update once a second */
1303 if (delta < HZ)
1304 return;
1305 1387
1306 do { 1388 /* Skip, if wrapped around or first calculation */
1307 start = u64_stats_fetch_begin_bh(&stats->sync); 1389 now = jiffies;
1308 pkts = stats->rx_pkts; 1390 if (!aic->jiffies || time_before(now, aic->jiffies) ||
1309 } while (u64_stats_fetch_retry_bh(&stats->sync, start)); 1391 rx_pkts < aic->rx_pkts_prev ||
1310 1392 tx_pkts < aic->tx_reqs_prev) {
1311 stats->rx_pps = (unsigned long)(pkts - stats->rx_pkts_prev) / (delta / HZ); 1393 be_aic_update(aic, rx_pkts, tx_pkts, now);
1312 stats->rx_pkts_prev = pkts; 1394 continue;
1313 stats->rx_jiffies = now; 1395 }
1314 eqd = (stats->rx_pps / 110000) << 3; 1396
1315 eqd = min(eqd, eqo->max_eqd); 1397 delta = jiffies_to_msecs(now - aic->jiffies);
1316 eqd = max(eqd, eqo->min_eqd); 1398 pps = (((u32)(rx_pkts - aic->rx_pkts_prev) * 1000) / delta) +
1317 if (eqd < 10) 1399 (((u32)(tx_pkts - aic->tx_reqs_prev) * 1000) / delta);
1318 eqd = 0; 1400 eqd = (pps / 15000) << 2;
1401
1402 if (eqd < 8)
1403 eqd = 0;
1404 eqd = min_t(u32, eqd, aic->max_eqd);
1405 eqd = max_t(u32, eqd, aic->min_eqd);
1319 1406
1407 be_aic_update(aic, rx_pkts, tx_pkts, now);
1320modify_eqd: 1408modify_eqd:
1321 if (eqd != eqo->cur_eqd) { 1409 if (eqd != aic->prev_eqd) {
1322 be_cmd_modify_eqd(adapter, eqo->q.id, eqd); 1410 set_eqd[num].delay_multiplier = (eqd * 65)/100;
1323 eqo->cur_eqd = eqd; 1411 set_eqd[num].eq_id = eqo->q.id;
1412 aic->prev_eqd = eqd;
1413 num++;
1414 }
1324 } 1415 }
1416
1417 if (num)
1418 be_cmd_modify_eqd(adapter, set_eqd, num);
1325} 1419}
1326 1420
1327static void be_rx_stats_update(struct be_rx_obj *rxo, 1421static void be_rx_stats_update(struct be_rx_obj *rxo,
@@ -1463,7 +1557,7 @@ static void skb_fill_rx_data(struct be_rx_obj *rxo, struct sk_buff *skb,
1463} 1557}
1464 1558
1465/* Process the RX completion indicated by rxcp when GRO is disabled */ 1559/* Process the RX completion indicated by rxcp when GRO is disabled */
1466static void be_rx_compl_process(struct be_rx_obj *rxo, 1560static void be_rx_compl_process(struct be_rx_obj *rxo, struct napi_struct *napi,
1467 struct be_rx_compl_info *rxcp) 1561 struct be_rx_compl_info *rxcp)
1468{ 1562{
1469 struct be_adapter *adapter = rxo->adapter; 1563 struct be_adapter *adapter = rxo->adapter;
@@ -1488,7 +1582,7 @@ static void be_rx_compl_process(struct be_rx_obj *rxo,
1488 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]); 1582 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]);
1489 if (netdev->features & NETIF_F_RXHASH) 1583 if (netdev->features & NETIF_F_RXHASH)
1490 skb->rxhash = rxcp->rss_hash; 1584 skb->rxhash = rxcp->rss_hash;
1491 1585 skb_mark_napi_id(skb, napi);
1492 1586
1493 if (rxcp->vlanf) 1587 if (rxcp->vlanf)
1494 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), rxcp->vlan_tag); 1588 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), rxcp->vlan_tag);
@@ -1546,6 +1640,7 @@ static void be_rx_compl_process_gro(struct be_rx_obj *rxo,
1546 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]); 1640 skb_record_rx_queue(skb, rxo - &adapter->rx_obj[0]);
1547 if (adapter->netdev->features & NETIF_F_RXHASH) 1641 if (adapter->netdev->features & NETIF_F_RXHASH)
1548 skb->rxhash = rxcp->rss_hash; 1642 skb->rxhash = rxcp->rss_hash;
1643 skb_mark_napi_id(skb, napi);
1549 1644
1550 if (rxcp->vlanf) 1645 if (rxcp->vlanf)
1551 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), rxcp->vlan_tag); 1646 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), rxcp->vlan_tag);
@@ -1726,6 +1821,8 @@ static void be_post_rx_frags(struct be_rx_obj *rxo, gfp_t gfp)
1726 1821
1727 if (posted) { 1822 if (posted) {
1728 atomic_add(posted, &rxq->used); 1823 atomic_add(posted, &rxq->used);
1824 if (rxo->rx_post_starved)
1825 rxo->rx_post_starved = false;
1729 be_rxq_notify(adapter, rxq->id, posted); 1826 be_rxq_notify(adapter, rxq->id, posted);
1730 } else if (atomic_read(&rxq->used) == 0) { 1827 } else if (atomic_read(&rxq->used) == 0) {
1731 /* Let be_worker replenish when memory is available */ 1828 /* Let be_worker replenish when memory is available */
@@ -1928,6 +2025,7 @@ static void be_evt_queues_destroy(struct be_adapter *adapter)
1928 if (eqo->q.created) { 2025 if (eqo->q.created) {
1929 be_eq_clean(eqo); 2026 be_eq_clean(eqo);
1930 be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ); 2027 be_cmd_q_destroy(adapter, &eqo->q, QTYPE_EQ);
2028 napi_hash_del(&eqo->napi);
1931 netif_napi_del(&eqo->napi); 2029 netif_napi_del(&eqo->napi);
1932 } 2030 }
1933 be_queue_free(adapter, &eqo->q); 2031 be_queue_free(adapter, &eqo->q);
@@ -1938,6 +2036,7 @@ static int be_evt_queues_create(struct be_adapter *adapter)
1938{ 2036{
1939 struct be_queue_info *eq; 2037 struct be_queue_info *eq;
1940 struct be_eq_obj *eqo; 2038 struct be_eq_obj *eqo;
2039 struct be_aic_obj *aic;
1941 int i, rc; 2040 int i, rc;
1942 2041
1943 adapter->num_evt_qs = min_t(u16, num_irqs(adapter), 2042 adapter->num_evt_qs = min_t(u16, num_irqs(adapter),
@@ -1946,11 +2045,13 @@ static int be_evt_queues_create(struct be_adapter *adapter)
1946 for_all_evt_queues(adapter, eqo, i) { 2045 for_all_evt_queues(adapter, eqo, i) {
1947 netif_napi_add(adapter->netdev, &eqo->napi, be_poll, 2046 netif_napi_add(adapter->netdev, &eqo->napi, be_poll,
1948 BE_NAPI_WEIGHT); 2047 BE_NAPI_WEIGHT);
2048 napi_hash_add(&eqo->napi);
2049 aic = &adapter->aic_obj[i];
1949 eqo->adapter = adapter; 2050 eqo->adapter = adapter;
1950 eqo->tx_budget = BE_TX_BUDGET; 2051 eqo->tx_budget = BE_TX_BUDGET;
1951 eqo->idx = i; 2052 eqo->idx = i;
1952 eqo->max_eqd = BE_MAX_EQD; 2053 aic->max_eqd = BE_MAX_EQD;
1953 eqo->enable_aic = true; 2054 aic->enable = true;
1954 2055
1955 eq = &eqo->q; 2056 eq = &eqo->q;
1956 rc = be_queue_alloc(adapter, eq, EVNT_Q_LEN, 2057 rc = be_queue_alloc(adapter, eq, EVNT_Q_LEN,
@@ -2171,7 +2272,7 @@ static inline bool do_gro(struct be_rx_compl_info *rxcp)
2171} 2272}
2172 2273
2173static int be_process_rx(struct be_rx_obj *rxo, struct napi_struct *napi, 2274static int be_process_rx(struct be_rx_obj *rxo, struct napi_struct *napi,
2174 int budget) 2275 int budget, int polling)
2175{ 2276{
2176 struct be_adapter *adapter = rxo->adapter; 2277 struct be_adapter *adapter = rxo->adapter;
2177 struct be_queue_info *rx_cq = &rxo->cq; 2278 struct be_queue_info *rx_cq = &rxo->cq;
@@ -2202,10 +2303,12 @@ static int be_process_rx(struct be_rx_obj *rxo, struct napi_struct *napi,
2202 goto loop_continue; 2303 goto loop_continue;
2203 } 2304 }
2204 2305
2205 if (do_gro(rxcp)) 2306 /* Don't do gro when we're busy_polling */
2307 if (do_gro(rxcp) && polling != BUSY_POLLING)
2206 be_rx_compl_process_gro(rxo, napi, rxcp); 2308 be_rx_compl_process_gro(rxo, napi, rxcp);
2207 else 2309 else
2208 be_rx_compl_process(rxo, rxcp); 2310 be_rx_compl_process(rxo, napi, rxcp);
2311
2209loop_continue: 2312loop_continue:
2210 be_rx_stats_update(rxo, rxcp); 2313 be_rx_stats_update(rxo, rxcp);
2211 } 2314 }
@@ -2213,7 +2316,11 @@ loop_continue:
2213 if (work_done) { 2316 if (work_done) {
2214 be_cq_notify(adapter, rx_cq->id, true, work_done); 2317 be_cq_notify(adapter, rx_cq->id, true, work_done);
2215 2318
2216 if (atomic_read(&rxo->q.used) < RX_FRAGS_REFILL_WM) 2319 /* When an rx-obj gets into post_starved state, just
2320 * let be_worker do the posting.
2321 */
2322 if (atomic_read(&rxo->q.used) < RX_FRAGS_REFILL_WM &&
2323 !rxo->rx_post_starved)
2217 be_post_rx_frags(rxo, GFP_ATOMIC); 2324 be_post_rx_frags(rxo, GFP_ATOMIC);
2218 } 2325 }
2219 2326
@@ -2258,6 +2365,7 @@ int be_poll(struct napi_struct *napi, int budget)
2258 struct be_eq_obj *eqo = container_of(napi, struct be_eq_obj, napi); 2365 struct be_eq_obj *eqo = container_of(napi, struct be_eq_obj, napi);
2259 struct be_adapter *adapter = eqo->adapter; 2366 struct be_adapter *adapter = eqo->adapter;
2260 int max_work = 0, work, i, num_evts; 2367 int max_work = 0, work, i, num_evts;
2368 struct be_rx_obj *rxo;
2261 bool tx_done; 2369 bool tx_done;
2262 2370
2263 num_evts = events_get(eqo); 2371 num_evts = events_get(eqo);
@@ -2270,13 +2378,18 @@ int be_poll(struct napi_struct *napi, int budget)
2270 max_work = budget; 2378 max_work = budget;
2271 } 2379 }
2272 2380
2273 /* This loop will iterate twice for EQ0 in which 2381 if (be_lock_napi(eqo)) {
2274 * completions of the last RXQ (default one) are also processed 2382 /* This loop will iterate twice for EQ0 in which
2275 * For other EQs the loop iterates only once 2383 * completions of the last RXQ (default one) are also processed
2276 */ 2384 * For other EQs the loop iterates only once
2277 for (i = eqo->idx; i < adapter->num_rx_qs; i += adapter->num_evt_qs) { 2385 */
2278 work = be_process_rx(&adapter->rx_obj[i], napi, budget); 2386 for_all_rx_queues_on_eq(adapter, eqo, rxo, i) {
2279 max_work = max(work, max_work); 2387 work = be_process_rx(rxo, napi, budget, NAPI_POLLING);
2388 max_work = max(work, max_work);
2389 }
2390 be_unlock_napi(eqo);
2391 } else {
2392 max_work = budget;
2280 } 2393 }
2281 2394
2282 if (is_mcc_eqo(eqo)) 2395 if (is_mcc_eqo(eqo))
@@ -2292,6 +2405,28 @@ int be_poll(struct napi_struct *napi, int budget)
2292 return max_work; 2405 return max_work;
2293} 2406}
2294 2407
2408#ifdef CONFIG_NET_RX_BUSY_POLL
2409static int be_busy_poll(struct napi_struct *napi)
2410{
2411 struct be_eq_obj *eqo = container_of(napi, struct be_eq_obj, napi);
2412 struct be_adapter *adapter = eqo->adapter;
2413 struct be_rx_obj *rxo;
2414 int i, work = 0;
2415
2416 if (!be_lock_busy_poll(eqo))
2417 return LL_FLUSH_BUSY;
2418
2419 for_all_rx_queues_on_eq(adapter, eqo, rxo, i) {
2420 work = be_process_rx(rxo, napi, 4, BUSY_POLLING);
2421 if (work)
2422 break;
2423 }
2424
2425 be_unlock_busy_poll(eqo);
2426 return work;
2427}
2428#endif
2429
2295void be_detect_error(struct be_adapter *adapter) 2430void be_detect_error(struct be_adapter *adapter)
2296{ 2431{
2297 u32 ue_lo = 0, ue_hi = 0, ue_lo_mask = 0, ue_hi_mask = 0; 2432 u32 ue_lo = 0, ue_hi = 0, ue_lo_mask = 0, ue_hi_mask = 0;
@@ -2523,9 +2658,11 @@ static int be_close(struct net_device *netdev)
2523 2658
2524 be_roce_dev_close(adapter); 2659 be_roce_dev_close(adapter);
2525 2660
2526 if (adapter->flags & BE_FLAGS_NAPI_ENABLED) { 2661 for_all_evt_queues(adapter, eqo, i) {
2527 for_all_evt_queues(adapter, eqo, i) 2662 if (adapter->flags & BE_FLAGS_NAPI_ENABLED) {
2528 napi_disable(&eqo->napi); 2663 napi_disable(&eqo->napi);
2664 be_disable_busy_poll(eqo);
2665 }
2529 adapter->flags &= ~BE_FLAGS_NAPI_ENABLED; 2666 adapter->flags &= ~BE_FLAGS_NAPI_ENABLED;
2530 } 2667 }
2531 2668
@@ -2636,6 +2773,7 @@ static int be_open(struct net_device *netdev)
2636 2773
2637 for_all_evt_queues(adapter, eqo, i) { 2774 for_all_evt_queues(adapter, eqo, i) {
2638 napi_enable(&eqo->napi); 2775 napi_enable(&eqo->napi);
2776 be_enable_busy_poll(eqo);
2639 be_eq_notify(adapter, eqo->q.id, true, false, 0); 2777 be_eq_notify(adapter, eqo->q.id, true, false, 0);
2640 } 2778 }
2641 adapter->flags |= BE_FLAGS_NAPI_ENABLED; 2779 adapter->flags |= BE_FLAGS_NAPI_ENABLED;
@@ -2941,7 +3079,8 @@ static int be_vf_setup(struct be_adapter *adapter)
2941 goto err; 3079 goto err;
2942 vf_cfg->def_vid = def_vlan; 3080 vf_cfg->def_vid = def_vlan;
2943 3081
2944 be_cmd_enable_vf(adapter, vf + 1); 3082 if (!old_vfs)
3083 be_cmd_enable_vf(adapter, vf + 1);
2945 } 3084 }
2946 3085
2947 if (!old_vfs) { 3086 if (!old_vfs) {
@@ -2966,12 +3105,12 @@ static void BEx_get_resources(struct be_adapter *adapter,
2966 struct pci_dev *pdev = adapter->pdev; 3105 struct pci_dev *pdev = adapter->pdev;
2967 bool use_sriov = false; 3106 bool use_sriov = false;
2968 3107
2969 if (BE3_chip(adapter) && be_physfn(adapter)) { 3108 if (BE3_chip(adapter) && sriov_want(adapter)) {
2970 int max_vfs; 3109 int max_vfs;
2971 3110
2972 max_vfs = pci_sriov_get_totalvfs(pdev); 3111 max_vfs = pci_sriov_get_totalvfs(pdev);
2973 res->max_vfs = max_vfs > 0 ? min(MAX_VFS, max_vfs) : 0; 3112 res->max_vfs = max_vfs > 0 ? min(MAX_VFS, max_vfs) : 0;
2974 use_sriov = res->max_vfs && num_vfs; 3113 use_sriov = res->max_vfs;
2975 } 3114 }
2976 3115
2977 if (be_physfn(adapter)) 3116 if (be_physfn(adapter))
@@ -2987,8 +3126,9 @@ static void BEx_get_resources(struct be_adapter *adapter,
2987 res->max_vlans = BE_NUM_VLANS_SUPPORTED; 3126 res->max_vlans = BE_NUM_VLANS_SUPPORTED;
2988 res->max_mcast_mac = BE_MAX_MC; 3127 res->max_mcast_mac = BE_MAX_MC;
2989 3128
3129 /* For BE3 1Gb ports, F/W does not properly support multiple TXQs */
2990 if (BE2_chip(adapter) || use_sriov || be_is_mc(adapter) || 3130 if (BE2_chip(adapter) || use_sriov || be_is_mc(adapter) ||
2991 !be_physfn(adapter)) 3131 !be_physfn(adapter) || (adapter->port_num > 1))
2992 res->max_tx_qs = 1; 3132 res->max_tx_qs = 1;
2993 else 3133 else
2994 res->max_tx_qs = BE3_MAX_TX_QS; 3134 res->max_tx_qs = BE3_MAX_TX_QS;
@@ -3030,14 +3170,6 @@ static int be_get_resources(struct be_adapter *adapter)
3030 adapter->res = res; 3170 adapter->res = res;
3031 } 3171 }
3032 3172
3033 /* For BE3 only check if FW suggests a different max-txqs value */
3034 if (BE3_chip(adapter)) {
3035 status = be_cmd_get_profile_config(adapter, &res, 0);
3036 if (!status && res.max_tx_qs)
3037 adapter->res.max_tx_qs =
3038 min(adapter->res.max_tx_qs, res.max_tx_qs);
3039 }
3040
3041 /* For Lancer, SH etc read per-function resource limits from FW. 3173 /* For Lancer, SH etc read per-function resource limits from FW.
3042 * GET_FUNC_CONFIG returns per function guaranteed limits. 3174 * GET_FUNC_CONFIG returns per function guaranteed limits.
3043 * GET_PROFILE_CONFIG returns PCI-E related limits PF-pool limits 3175 * GET_PROFILE_CONFIG returns PCI-E related limits PF-pool limits
@@ -3251,6 +3383,12 @@ static int be_setup(struct be_adapter *adapter)
3251 3383
3252 be_cmd_get_fw_ver(adapter, adapter->fw_ver, adapter->fw_on_flash); 3384 be_cmd_get_fw_ver(adapter, adapter->fw_ver, adapter->fw_on_flash);
3253 3385
3386 if (BE2_chip(adapter) && fw_major_num(adapter->fw_ver) < 4) {
3387 dev_err(dev, "Firmware on card is old(%s), IRQs may not work.",
3388 adapter->fw_ver);
3389 dev_err(dev, "Please upgrade firmware to version >= 4.0\n");
3390 }
3391
3254 if (adapter->vlans_added) 3392 if (adapter->vlans_added)
3255 be_vid_config(adapter); 3393 be_vid_config(adapter);
3256 3394
@@ -3262,7 +3400,7 @@ static int be_setup(struct be_adapter *adapter)
3262 be_cmd_set_flow_control(adapter, adapter->tx_fc, 3400 be_cmd_set_flow_control(adapter, adapter->tx_fc,
3263 adapter->rx_fc); 3401 adapter->rx_fc);
3264 3402
3265 if (be_physfn(adapter) && num_vfs) { 3403 if (sriov_want(adapter)) {
3266 if (be_max_vfs(adapter)) 3404 if (be_max_vfs(adapter))
3267 be_vf_setup(adapter); 3405 be_vf_setup(adapter);
3268 else 3406 else
@@ -3904,6 +4042,9 @@ static const struct net_device_ops be_netdev_ops = {
3904#endif 4042#endif
3905 .ndo_bridge_setlink = be_ndo_bridge_setlink, 4043 .ndo_bridge_setlink = be_ndo_bridge_setlink,
3906 .ndo_bridge_getlink = be_ndo_bridge_getlink, 4044 .ndo_bridge_getlink = be_ndo_bridge_getlink,
4045#ifdef CONFIG_NET_RX_BUSY_POLL
4046 .ndo_busy_poll = be_busy_poll
4047#endif
3907}; 4048};
3908 4049
3909static void be_netdev_init(struct net_device *netdev) 4050static void be_netdev_init(struct net_device *netdev)
@@ -3964,11 +4105,6 @@ static int be_roce_map_pci_bars(struct be_adapter *adapter)
3964static int be_map_pci_bars(struct be_adapter *adapter) 4105static int be_map_pci_bars(struct be_adapter *adapter)
3965{ 4106{
3966 u8 __iomem *addr; 4107 u8 __iomem *addr;
3967 u32 sli_intf;
3968
3969 pci_read_config_dword(adapter->pdev, SLI_INTF_REG_OFFSET, &sli_intf);
3970 adapter->if_type = (sli_intf & SLI_INTF_IF_TYPE_MASK) >>
3971 SLI_INTF_IF_TYPE_SHIFT;
3972 4108
3973 if (BEx_chip(adapter) && be_physfn(adapter)) { 4109 if (BEx_chip(adapter) && be_physfn(adapter)) {
3974 adapter->csr = pci_iomap(adapter->pdev, 2, 0); 4110 adapter->csr = pci_iomap(adapter->pdev, 2, 0);
@@ -4081,9 +4217,11 @@ static int be_stats_init(struct be_adapter *adapter)
4081 cmd->size = sizeof(struct lancer_cmd_req_pport_stats); 4217 cmd->size = sizeof(struct lancer_cmd_req_pport_stats);
4082 else if (BE2_chip(adapter)) 4218 else if (BE2_chip(adapter))
4083 cmd->size = sizeof(struct be_cmd_req_get_stats_v0); 4219 cmd->size = sizeof(struct be_cmd_req_get_stats_v0);
4084 else 4220 else if (BE3_chip(adapter))
4085 /* BE3 and Skyhawk */
4086 cmd->size = sizeof(struct be_cmd_req_get_stats_v1); 4221 cmd->size = sizeof(struct be_cmd_req_get_stats_v1);
4222 else
4223 /* ALL non-BE ASICs */
4224 cmd->size = sizeof(struct be_cmd_req_get_stats_v2);
4087 4225
4088 cmd->va = dma_zalloc_coherent(&adapter->pdev->dev, cmd->size, &cmd->dma, 4226 cmd->va = dma_zalloc_coherent(&adapter->pdev->dev, cmd->size, &cmd->dma,
4089 GFP_KERNEL); 4227 GFP_KERNEL);
@@ -4117,7 +4255,6 @@ static void be_remove(struct pci_dev *pdev)
4117 4255
4118 pci_disable_pcie_error_reporting(pdev); 4256 pci_disable_pcie_error_reporting(pdev);
4119 4257
4120 pci_set_drvdata(pdev, NULL);
4121 pci_release_regions(pdev); 4258 pci_release_regions(pdev);
4122 pci_disable_device(pdev); 4259 pci_disable_device(pdev);
4123 4260
@@ -4266,7 +4403,6 @@ static void be_worker(struct work_struct *work)
4266 struct be_adapter *adapter = 4403 struct be_adapter *adapter =
4267 container_of(work, struct be_adapter, work.work); 4404 container_of(work, struct be_adapter, work.work);
4268 struct be_rx_obj *rxo; 4405 struct be_rx_obj *rxo;
4269 struct be_eq_obj *eqo;
4270 int i; 4406 int i;
4271 4407
4272 /* when interrupts are not yet enabled, just reap any pending 4408 /* when interrupts are not yet enabled, just reap any pending
@@ -4291,14 +4427,14 @@ static void be_worker(struct work_struct *work)
4291 be_cmd_get_die_temperature(adapter); 4427 be_cmd_get_die_temperature(adapter);
4292 4428
4293 for_all_rx_queues(adapter, rxo, i) { 4429 for_all_rx_queues(adapter, rxo, i) {
4294 if (rxo->rx_post_starved) { 4430 /* Replenish RX-queues starved due to memory
4295 rxo->rx_post_starved = false; 4431 * allocation failures.
4432 */
4433 if (rxo->rx_post_starved)
4296 be_post_rx_frags(rxo, GFP_KERNEL); 4434 be_post_rx_frags(rxo, GFP_KERNEL);
4297 }
4298 } 4435 }
4299 4436
4300 for_all_evt_queues(adapter, eqo, i) 4437 be_eqd_update(adapter);
4301 be_eqd_update(adapter, eqo);
4302 4438
4303reschedule: 4439reschedule:
4304 adapter->work_counter++; 4440 adapter->work_counter++;
@@ -4355,28 +4491,22 @@ static int be_probe(struct pci_dev *pdev, const struct pci_device_id *pdev_id)
4355 adapter->netdev = netdev; 4491 adapter->netdev = netdev;
4356 SET_NETDEV_DEV(netdev, &pdev->dev); 4492 SET_NETDEV_DEV(netdev, &pdev->dev);
4357 4493
4358 status = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); 4494 status = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
4359 if (!status) { 4495 if (!status) {
4360 status = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64));
4361 if (status < 0) {
4362 dev_err(&pdev->dev, "dma_set_coherent_mask failed\n");
4363 goto free_netdev;
4364 }
4365 netdev->features |= NETIF_F_HIGHDMA; 4496 netdev->features |= NETIF_F_HIGHDMA;
4366 } else { 4497 } else {
4367 status = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); 4498 status = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
4368 if (!status)
4369 status = dma_set_coherent_mask(&pdev->dev,
4370 DMA_BIT_MASK(32));
4371 if (status) { 4499 if (status) {
4372 dev_err(&pdev->dev, "Could not set PCI DMA Mask\n"); 4500 dev_err(&pdev->dev, "Could not set PCI DMA Mask\n");
4373 goto free_netdev; 4501 goto free_netdev;
4374 } 4502 }
4375 } 4503 }
4376 4504
4377 status = pci_enable_pcie_error_reporting(pdev); 4505 if (be_physfn(adapter)) {
4378 if (status) 4506 status = pci_enable_pcie_error_reporting(pdev);
4379 dev_info(&pdev->dev, "Could not use PCIe error reporting\n"); 4507 if (!status)
4508 dev_info(&pdev->dev, "PCIe error reporting enabled\n");
4509 }
4380 4510
4381 status = be_ctrl_init(adapter); 4511 status = be_ctrl_init(adapter);
4382 if (status) 4512 if (status)
@@ -4447,7 +4577,6 @@ ctrl_clean:
4447 be_ctrl_cleanup(adapter); 4577 be_ctrl_cleanup(adapter);
4448free_netdev: 4578free_netdev:
4449 free_netdev(netdev); 4579 free_netdev(netdev);
4450 pci_set_drvdata(pdev, NULL);
4451rel_reg: 4580rel_reg:
4452 pci_release_regions(pdev); 4581 pci_release_regions(pdev);
4453disable_dev: 4582disable_dev: