forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c
....@@ -27,7 +27,6 @@
2727 #include <net/tcp.h>
2828 #include <net/ipv6.h>
2929 #include <net/ip6_checksum.h>
30
-#include <net/busy_poll.h>
3130 #include <linux/prefetch.h>
3231 #include "bnx2x_cmn.h"
3332 #include "bnx2x_init.h"
....@@ -505,6 +504,7 @@
505504 * @len_on_bd: total length of the first packet for the
506505 * aggregation.
507506 * @pkt_len: length of all segments
507
+ * @num_of_coalesced_segs: count of segments
508508 *
509509 * Approximate value of the MSS for this aggregation calculated using
510510 * the first packet of it.
....@@ -688,7 +688,7 @@
688688 if (unlikely(gfpflags_allow_blocking(gfp_mask)))
689689 return (void *)__get_free_page(gfp_mask);
690690
691
- return netdev_alloc_frag(fp->rx_frag_size);
691
+ return napi_alloc_frag(fp->rx_frag_size);
692692 }
693693
694694 return kmalloc(fp->rx_buf_size + NET_SKB_PAD, gfp_mask);
....@@ -788,6 +788,7 @@
788788 BNX2X_ERR("skb_put is about to fail... pad %d len %d rx_buf_size %d\n",
789789 pad, len, fp->rx_buf_size);
790790 bnx2x_panic();
791
+ bnx2x_frag_free(fp, new_data);
791792 return;
792793 }
793794 #endif
....@@ -1913,8 +1914,7 @@
19131914 }
19141915
19151916 u16 bnx2x_select_queue(struct net_device *dev, struct sk_buff *skb,
1916
- struct net_device *sb_dev,
1917
- select_queue_fallback_t fallback)
1917
+ struct net_device *sb_dev)
19181918 {
19191919 struct bnx2x *bp = netdev_priv(dev);
19201920
....@@ -1936,7 +1936,8 @@
19361936 }
19371937
19381938 /* select a non-FCoE queue */
1939
- return fallback(dev, skb, NULL) % (BNX2X_NUM_ETH_QUEUES(bp));
1939
+ return netdev_pick_tx(dev, skb, NULL) %
1940
+ (BNX2X_NUM_ETH_QUEUES(bp) * bp->max_cos);
19401941 }
19411942
19421943 void bnx2x_set_num_queues(struct bnx2x *bp)
....@@ -1959,6 +1960,7 @@
19591960 * bnx2x_set_real_num_queues - configure netdev->real_num_[tx,rx]_queues
19601961 *
19611962 * @bp: Driver handle
1963
+ * @include_cnic: handle cnic case
19621964 *
19631965 * We currently support for at most 16 Tx queues for each CoS thus we will
19641966 * allocate a multiple of 16 for ETH L2 rings according to the value of the
....@@ -2362,26 +2364,30 @@
23622364 /* is another pf loaded on this engine? */
23632365 if (load_code != FW_MSG_CODE_DRV_LOAD_COMMON_CHIP &&
23642366 load_code != FW_MSG_CODE_DRV_LOAD_COMMON) {
2365
- /* build my FW version dword */
2366
- u32 my_fw = (BCM_5710_FW_MAJOR_VERSION) +
2367
- (BCM_5710_FW_MINOR_VERSION << 8) +
2368
- (BCM_5710_FW_REVISION_VERSION << 16) +
2369
- (BCM_5710_FW_ENGINEERING_VERSION << 24);
2367
+ u8 loaded_fw_major, loaded_fw_minor, loaded_fw_rev, loaded_fw_eng;
2368
+ u32 loaded_fw;
23702369
23712370 /* read loaded FW from chip */
2372
- u32 loaded_fw = REG_RD(bp, XSEM_REG_PRAM);
2371
+ loaded_fw = REG_RD(bp, XSEM_REG_PRAM);
23732372
2374
- DP(BNX2X_MSG_SP, "loaded fw %x, my fw %x\n",
2375
- loaded_fw, my_fw);
2373
+ loaded_fw_major = loaded_fw & 0xff;
2374
+ loaded_fw_minor = (loaded_fw >> 8) & 0xff;
2375
+ loaded_fw_rev = (loaded_fw >> 16) & 0xff;
2376
+ loaded_fw_eng = (loaded_fw >> 24) & 0xff;
2377
+
2378
+ DP(BNX2X_MSG_SP, "loaded fw 0x%x major 0x%x minor 0x%x rev 0x%x eng 0x%x\n",
2379
+ loaded_fw, loaded_fw_major, loaded_fw_minor, loaded_fw_rev, loaded_fw_eng);
23762380
23772381 /* abort nic load if version mismatch */
2378
- if (my_fw != loaded_fw) {
2382
+ if (loaded_fw_major != BCM_5710_FW_MAJOR_VERSION ||
2383
+ loaded_fw_minor != BCM_5710_FW_MINOR_VERSION ||
2384
+ loaded_fw_eng != BCM_5710_FW_ENGINEERING_VERSION ||
2385
+ loaded_fw_rev < BCM_5710_FW_REVISION_VERSION_V15) {
23792386 if (print_err)
2380
- BNX2X_ERR("bnx2x with FW %x was already loaded which mismatches my %x FW. Aborting\n",
2381
- loaded_fw, my_fw);
2387
+ BNX2X_ERR("loaded FW incompatible. Aborting\n");
23822388 else
2383
- BNX2X_DEV_INFO("bnx2x with FW %x was already loaded which mismatches my %x FW, possibly due to MF UNDI\n",
2384
- loaded_fw, my_fw);
2389
+ BNX2X_DEV_INFO("loaded FW incompatible, possibly due to MF UNDI\n");
2390
+
23852391 return -EBUSY;
23862392 }
23872393 }
....@@ -2846,6 +2852,7 @@
28462852 bnx2x_set_rx_mode_inner(bp);
28472853
28482854 if (bp->flags & PTP_SUPPORTED) {
2855
+ bnx2x_register_phc(bp);
28492856 bnx2x_init_ptp(bp);
28502857 bnx2x_configure_ptp_filters(bp);
28512858 }
....@@ -4173,8 +4180,6 @@
41734180
41744181 DOORBELL_RELAXED(bp, txdata->cid, txdata->tx_db.raw);
41754182
4176
- mmiowb();
4177
-
41784183 txdata->tx_bd_prod += nbd;
41794184
41804185 if (unlikely(bnx2x_tx_avail(bp, txdata) < MAX_DESC_PER_TX_PKT)) {
....@@ -4232,8 +4237,8 @@
42324237 /**
42334238 * bnx2x_setup_tc - routine to configure net_device for multi tc
42344239 *
4235
- * @netdev: net device to configure
4236
- * @tc: number of traffic classes to enable
4240
+ * @dev: net device to configure
4241
+ * @num_tc: number of traffic classes to enable
42374242 *
42384243 * callback connected to the ndo_setup_tc function pointer
42394244 */
....@@ -4973,7 +4978,7 @@
49734978 return 0;
49744979 }
49754980
4976
-void bnx2x_tx_timeout(struct net_device *dev)
4981
+void bnx2x_tx_timeout(struct net_device *dev, unsigned int txqueue)
49774982 {
49784983 struct bnx2x *bp = netdev_priv(dev);
49794984
....@@ -4991,8 +4996,9 @@
49914996 bnx2x_schedule_sp_rtnl(bp, BNX2X_SP_RTNL_TX_TIMEOUT, 0);
49924997 }
49934998
4994
-int bnx2x_suspend(struct pci_dev *pdev, pm_message_t state)
4999
+static int __maybe_unused bnx2x_suspend(struct device *dev_d)
49955000 {
5001
+ struct pci_dev *pdev = to_pci_dev(dev_d);
49965002 struct net_device *dev = pci_get_drvdata(pdev);
49975003 struct bnx2x *bp;
49985004
....@@ -5004,8 +5010,6 @@
50045010
50055011 rtnl_lock();
50065012
5007
- pci_save_state(pdev);
5008
-
50095013 if (!netif_running(dev)) {
50105014 rtnl_unlock();
50115015 return 0;
....@@ -5015,15 +5019,14 @@
50155019
50165020 bnx2x_nic_unload(bp, UNLOAD_CLOSE, false);
50175021
5018
- bnx2x_set_power_state(bp, pci_choose_state(pdev, state));
5019
-
50205022 rtnl_unlock();
50215023
50225024 return 0;
50235025 }
50245026
5025
-int bnx2x_resume(struct pci_dev *pdev)
5027
+static int __maybe_unused bnx2x_resume(struct device *dev_d)
50265028 {
5029
+ struct pci_dev *pdev = to_pci_dev(dev_d);
50275030 struct net_device *dev = pci_get_drvdata(pdev);
50285031 struct bnx2x *bp;
50295032 int rc;
....@@ -5041,14 +5044,11 @@
50415044
50425045 rtnl_lock();
50435046
5044
- pci_restore_state(pdev);
5045
-
50465047 if (!netif_running(dev)) {
50475048 rtnl_unlock();
50485049 return 0;
50495050 }
50505051
5051
- bnx2x_set_power_state(bp, PCI_D0);
50525052 netif_device_attach(dev);
50535053
50545054 rc = bnx2x_nic_load(bp, LOAD_OPEN);
....@@ -5058,6 +5058,8 @@
50585058 return rc;
50595059 }
50605060
5061
+SIMPLE_DEV_PM_OPS(bnx2x_pm_ops, bnx2x_suspend, bnx2x_resume);
5062
+
50615063 void bnx2x_set_ctx_validation(struct bnx2x *bp, struct eth_context *cxt,
50625064 u32 cid)
50635065 {