forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/ethernet/mellanox/mlx4/en_tx.c
....@@ -43,6 +43,7 @@
4343 #include <linux/ip.h>
4444 #include <linux/ipv6.h>
4545 #include <linux/moduleparam.h>
46
+#include <linux/indirect_call_wrapper.h>
4647
4748 #include "mlx4_en.h"
4849
....@@ -57,11 +58,8 @@
5758
5859 ring = kzalloc_node(sizeof(*ring), GFP_KERNEL, node);
5960 if (!ring) {
60
- ring = kzalloc(sizeof(*ring), GFP_KERNEL);
61
- if (!ring) {
62
- en_err(priv, "Failed allocating TX ring\n");
63
- return -ENOMEM;
64
- }
61
+ en_err(priv, "Failed allocating TX ring\n");
62
+ return -ENOMEM;
6563 }
6664
6765 ring->size = size;
....@@ -264,6 +262,10 @@
264262 }
265263 }
266264
265
+INDIRECT_CALLABLE_DECLARE(u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
266
+ struct mlx4_en_tx_ring *ring,
267
+ int index, u64 timestamp,
268
+ int napi_mode));
267269
268270 u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
269271 struct mlx4_en_tx_ring *ring,
....@@ -331,6 +333,11 @@
331333
332334 return tx_info->nr_txbb;
333335 }
336
+
337
+INDIRECT_CALLABLE_DECLARE(u32 mlx4_en_recycle_tx_desc(struct mlx4_en_priv *priv,
338
+ struct mlx4_en_tx_ring *ring,
339
+ int index, u64 timestamp,
340
+ int napi_mode));
334341
335342 u32 mlx4_en_recycle_tx_desc(struct mlx4_en_priv *priv,
336343 struct mlx4_en_tx_ring *ring,
....@@ -414,8 +421,8 @@
414421 queue_work(mdev->workqueue, &priv->restart_task);
415422 }
416423
417
-bool mlx4_en_process_tx_cq(struct net_device *dev,
418
- struct mlx4_en_cq *cq, int napi_budget)
424
+int mlx4_en_process_tx_cq(struct net_device *dev,
425
+ struct mlx4_en_cq *cq, int napi_budget)
419426 {
420427 struct mlx4_en_priv *priv = netdev_priv(dev);
421428 struct mlx4_cq *mcq = &cq->mcq;
....@@ -437,7 +444,7 @@
437444 u32 ring_cons;
438445
439446 if (unlikely(!priv->port_up))
440
- return true;
447
+ return 0;
441448
442449 netdev_txq_bql_complete_prefetchw(ring->tx_queue);
443450
....@@ -478,7 +485,9 @@
478485 timestamp = mlx4_en_get_cqe_ts(cqe);
479486
480487 /* free next descriptor */
481
- last_nr_txbb = ring->free_tx_desc(
488
+ last_nr_txbb = INDIRECT_CALL_2(ring->free_tx_desc,
489
+ mlx4_en_free_tx_desc,
490
+ mlx4_en_recycle_tx_desc,
482491 priv, ring, ring_index,
483492 timestamp, napi_budget);
484493
....@@ -509,7 +518,7 @@
509518 WRITE_ONCE(ring->cons, ring_cons + txbbs_skipped);
510519
511520 if (cq->type == TX_XDP)
512
- return done < budget;
521
+ return done;
513522
514523 netdev_tx_completed_queue(ring->tx_queue, packets, bytes);
515524
....@@ -521,7 +530,7 @@
521530 ring->wake_queue++;
522531 }
523532
524
- return done < budget;
533
+ return done;
525534 }
526535
527536 void mlx4_en_tx_irq(struct mlx4_cq *mcq)
....@@ -541,14 +550,14 @@
541550 struct mlx4_en_cq *cq = container_of(napi, struct mlx4_en_cq, napi);
542551 struct net_device *dev = cq->dev;
543552 struct mlx4_en_priv *priv = netdev_priv(dev);
544
- bool clean_complete;
553
+ int work_done;
545554
546
- clean_complete = mlx4_en_process_tx_cq(dev, cq, budget);
547
- if (!clean_complete)
555
+ work_done = mlx4_en_process_tx_cq(dev, cq, budget);
556
+ if (work_done >= budget)
548557 return budget;
549558
550
- napi_complete(napi);
551
- mlx4_en_arm_cq(priv, cq);
559
+ if (napi_complete_done(napi, work_done))
560
+ mlx4_en_arm_cq(priv, cq);
552561
553562 return 0;
554563 }
....@@ -714,16 +723,15 @@
714723 }
715724
716725 u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb,
717
- struct net_device *sb_dev,
718
- select_queue_fallback_t fallback)
726
+ struct net_device *sb_dev)
719727 {
720728 struct mlx4_en_priv *priv = netdev_priv(dev);
721729 u16 rings_p_up = priv->num_tx_rings_p_up;
722730
723731 if (netdev_get_num_tc(dev))
724
- return fallback(dev, skb, NULL);
732
+ return netdev_pick_tx(dev, skb, NULL);
725733
726
- return fallback(dev, skb, NULL) % rings_p_up;
734
+ return netdev_pick_tx(dev, skb, NULL) % rings_p_up;
727735 }
728736
729737 static void mlx4_bf_copy(void __iomem *dst, const void *src,
....@@ -802,9 +810,7 @@
802810
803811 /* Map fragments if any */
804812 for (i_frag = shinfo->nr_frags - 1; i_frag >= 0; i_frag--) {
805
- const struct skb_frag_struct *frag;
806
-
807
- frag = &shinfo->frags[i_frag];
813
+ const skb_frag_t *frag = &shinfo->frags[i_frag];
808814 byte_count = skb_frag_size(frag);
809815 dma = skb_frag_dma_map(ddev, frag,
810816 0, byte_count,
....@@ -1032,7 +1038,6 @@
10321038 ring->packets++;
10331039 }
10341040 ring->bytes += tx_info->nr_bytes;
1035
- netdev_tx_sent_queue(ring->tx_queue, tx_info->nr_bytes);
10361041 AVG_PERF_COUNTER(priv->pstats.tx_pktsz_avg, skb->len);
10371042
10381043 if (tx_info->inl)
....@@ -1070,7 +1075,10 @@
10701075 netif_tx_stop_queue(ring->tx_queue);
10711076 ring->queue_stopped++;
10721077 }
1073
- send_doorbell = !skb->xmit_more || netif_xmit_stopped(ring->tx_queue);
1078
+
1079
+ send_doorbell = __netdev_tx_sent_queue(ring->tx_queue,
1080
+ tx_info->nr_bytes,
1081
+ netdev_xmit_more());
10741082
10751083 real_size = (real_size / 16) & 0x3f;
10761084
....@@ -1093,7 +1101,6 @@
10931101 */
10941102 smp_rmb();
10951103
1096
- ring_cons = READ_ONCE(ring->cons);
10971104 if (unlikely(!mlx4_en_is_tx_ring_full(ring))) {
10981105 netif_tx_wake_queue(ring->tx_queue);
10991106 ring->wake_queue++;